From 22cef1b49700e63a80b169574b77fd08a30b141e Mon Sep 17 00:00:00 2001 From: Jitendra Purohit Date: Wed, 3 Sep 2014 18:54:48 +0530 Subject: [PATCH] Webtest Fix --- tests/phpunit/WebTest/Admin/CustomAddTest.php | 12 ++++++++---- .../Campaign/OnlineEventRegistrationTest.php | 12 ++++++------ .../WebTest/Case/CaseCustomFieldsTest.php | 6 +++--- .../WebTest/Event/PricesetMaxCountTest.php | 6 ++++-- .../WebTest/Import/ContactCustomDataTest.php | 8 +++++--- tests/phpunit/WebTest/Import/CustomDataTest.php | 16 ++++++++++------ 6 files changed, 36 insertions(+), 24 deletions(-) diff --git a/tests/phpunit/WebTest/Admin/CustomAddTest.php b/tests/phpunit/WebTest/Admin/CustomAddTest.php index 7336aebf15..fb0c220989 100644 --- a/tests/phpunit/WebTest/Admin/CustomAddTest.php +++ b/tests/phpunit/WebTest/Admin/CustomAddTest.php @@ -51,15 +51,19 @@ class WebTest_Admin_CustomAddTest extends CiviSeleniumTestCase { $this->click("//option[@value='Contact']"); $this->click("//form[@id='Group']/div[2]/div[3]/span[1]/input"); $this->waitForPageToLoad($this->getTimeoutMsec()); + $this->waitForElementPresent('newCustomField'); //Is custom group created? $this->waitForText('crm-notification-container', "Your custom field set '$customGroupTitle' has been added. You can add custom fields now."); + //add custom field - alphanumeric text + $this->click('newCustomField'); + $this->waitForElementPresent('_qf_Field_cancel-bottom'); $textFieldLabel = 'test_text_field' . substr(sha1(rand()), 0, 3); $this->click("header"); $this->type("label", $textFieldLabel); $this->click("_qf_Field_next_new-bottom"); - $this->waitForPageToLoad($this->getTimeoutMsec()); + $this->waitForElementPresent('_qf_Field_cancel-bottom'); $this->click("data_type[0]"); $this->select("data_type[0]", "value=0"); $this->click("//option[@value='0']"); @@ -98,7 +102,7 @@ class WebTest_Admin_CustomAddTest extends CiviSeleniumTestCase { //clicking save $this->click("_qf_Field_next_new-bottom"); - $this->waitForPageToLoad($this->getTimeoutMsec()); + $this->waitForElementPresent('_qf_Field_cancel-bottom'); //create another custom field - Number Radio $this->click("data_type[0]"); @@ -130,8 +134,8 @@ class WebTest_Admin_CustomAddTest extends CiviSeleniumTestCase { $this->click("is_searchable"); //clicking save - $this->click("_qf_Field_next-bottom"); - $this->waitForPageToLoad($this->getTimeoutMsec()); + $this->click("_qf_Field_done-bottom"); + $this->waitForElementPresent('newCustomField'); //On New Individual contact form $this->openCiviPage("contact/add", "ct=Individual&reset=1"); diff --git a/tests/phpunit/WebTest/Campaign/OnlineEventRegistrationTest.php b/tests/phpunit/WebTest/Campaign/OnlineEventRegistrationTest.php index a9a0110f54..d5d0d8ab19 100644 --- a/tests/phpunit/WebTest/Campaign/OnlineEventRegistrationTest.php +++ b/tests/phpunit/WebTest/Campaign/OnlineEventRegistrationTest.php @@ -92,9 +92,7 @@ class WebTest_Campaign_OnlineEventRegistrationTest extends CiviSeleniumTestCase $this->type("description", "This is a test campaign"); // include groups for the campaign - $this->addSelection("includeGroups-f", "label=$groupName"); - $this->click("//option[@value=4]"); - $this->click("add"); + $this->multiselect2("includeGroups", array("$groupName", "Advisory Board")); // fill the end date for campaign $this->webtestFillDate("end_date", "+1 year"); @@ -108,8 +106,8 @@ class WebTest_Campaign_OnlineEventRegistrationTest extends CiviSeleniumTestCase $this->waitForText('crm-notification-container', "Campaign $title"); - $this->waitForElementPresent("//div[@id='campaignList']/div[@id='campaigns_wrapper']/table/tbody/tr/td[text()='{$campaignTitle}']/../td[1]"); - $id = (int) $this->getText("//div[@id='campaignList']/div[@id='campaigns_wrapper']/table/tbody/tr/td[text()='{$campaignTitle}']/../td[1]"); + $this->waitForElementPresent("//div[@id='campaignList']/div[@class='dataTables_wrapper no-footer']/table/tbody/tr/td[text()='{$campaignTitle}']/../td[1]"); + $id = (int) $this->getText("//div[@id='campaignList']/div[@class='dataTables_wrapper no-footer']/table/tbody/tr/td[text()='{$campaignTitle}']/../td[1]"); $this->onlineParticipantAddTest($campaignTitle, $id); } @@ -197,6 +195,7 @@ class WebTest_Campaign_OnlineEventRegistrationTest extends CiviSeleniumTestCase $this->type("address_1_street_address", $streetAddress); $this->type("address_1_city", "San Francisco"); $this->type("address_1_postal_code", "94117"); + $this->select('address_1_country_id', 'United States'); $this->select("address_1_state_province_id", "value=1004"); $this->type("email_1_email", "info@civicrm.org"); @@ -249,13 +248,14 @@ class WebTest_Campaign_OnlineEventRegistrationTest extends CiviSeleniumTestCase $this->click("link=Online Registration"); $this->waitForElementPresent("_qf_Registration_upload-bottom"); - $this->check("is_online_registration"); + $this->click("is_online_registration"); $this->assertChecked("is_online_registration"); if ($multipleRegistrations) { $this->check("is_multiple_registrations"); $this->assertChecked("is_multiple_registrations"); } + $this->click('intro_text-plain'); $this->fillRichTextField("intro_text", $registerIntro); // enable confirmation email diff --git a/tests/phpunit/WebTest/Case/CaseCustomFieldsTest.php b/tests/phpunit/WebTest/Case/CaseCustomFieldsTest.php index 97b9da0901..71c68e7bb9 100644 --- a/tests/phpunit/WebTest/Case/CaseCustomFieldsTest.php +++ b/tests/phpunit/WebTest/Case/CaseCustomFieldsTest.php @@ -280,7 +280,7 @@ class WebTest_Case_CaseCustomFieldsTest extends CiviSeleniumTestCase { $this->type("label", $field3); $this->check("is_searchable"); - $this->click("_qf_Field_next-bottom"); + $this->click("_qf_Field_done-bottom"); $this->waitForPageToLoad($this->getTimeoutMsec()); // get id of custom fields @@ -440,9 +440,9 @@ class WebTest_Case_CaseCustomFieldsTest extends CiviSeleniumTestCase { $cusId_1 = 'custom_' . $customId[0] . '_1'; $cusId_2 = 'custom_' . $customId[1] . '_1'; - $this->clickLink("css=#{$customGrp1} a.button"); + $this->clickLink("css=#{$customGrp1} a.button", '_qf_CustomData_cancel-bottom', FALSE); - $this->assertElementContainsText("page-title", "Edit $customGrp1"); + $this->assertElementContainsText("xpath=//span[@class='ui-dialog-title']", "Edit $customGrp1"); $custFname = "Miky" . substr(sha1(rand()), 0, 7); $custLname = "Kristy" . substr(sha1(rand()), 0, 7); diff --git a/tests/phpunit/WebTest/Event/PricesetMaxCountTest.php b/tests/phpunit/WebTest/Event/PricesetMaxCountTest.php index eb664fdb55..5d7845cfa1 100644 --- a/tests/phpunit/WebTest/Event/PricesetMaxCountTest.php +++ b/tests/phpunit/WebTest/Event/PricesetMaxCountTest.php @@ -1049,7 +1049,7 @@ class WebTest_Event_PricesetMaxCountTest extends CiviSeleniumTestCase { $this->type('help_pre', 'This is test priceset.'); $this->assertChecked('is_active', 'Verify that Is Active checkbox is set.'); - $this->clickLink('_qf_Set_next-bottom', '_qf_Field_next-bottom'); + $this->clickLink('_qf_Set_next-bottom', 'newPriceField'); } /** @@ -1058,6 +1058,8 @@ class WebTest_Event_PricesetMaxCountTest extends CiviSeleniumTestCase { function _testAddPriceFields($fields) { $fieldCount = count($fields); $count = 1; + $this->click('newPriceField'); + $this->waitForElementPresent('label'); foreach ($fields as $label => $field) { $this->type('label', $label); $this->select('html_type', "value={$field['type']}"); @@ -1100,7 +1102,7 @@ class WebTest_Event_PricesetMaxCountTest extends CiviSeleniumTestCase { else { $this->click('_qf_Field_next-bottom'); } - $this->waitForPageToLoad($this->getTimeoutMsec()); + $this->waitForText('crm-notification-container', "Price Field '$label' has been saved."); $count++; } diff --git a/tests/phpunit/WebTest/Import/ContactCustomDataTest.php b/tests/phpunit/WebTest/Import/ContactCustomDataTest.php index 3bc1a317ea..0010dd2dc5 100644 --- a/tests/phpunit/WebTest/Import/ContactCustomDataTest.php +++ b/tests/phpunit/WebTest/Import/ContactCustomDataTest.php @@ -162,10 +162,12 @@ class WebTest_Import_ContactCustomDataTest extends ImportCiviSeleniumTestCase { $this->select('extends[0]', "value=Contact"); $this->click("//option[@value='Contact']"); $this->click('_qf_Group_next-bottom'); - $this->waitForElementPresent('_qf_Field_cancel-bottom'); + $this->waitForElementPresent('newCustomField'); //Is custom group created? $this->waitForText('crm-notification-container', $customGroupTitle); + $this->click('newCustomField'); + $this->waitForElementPresent('_qf_Field_cancel-bottom'); $gid = $this->urlArg('gid'); // create another custom field - Date @@ -182,10 +184,10 @@ class WebTest_Import_ContactCustomDataTest extends ImportCiviSeleniumTestCase { $this->click("is_searchable"); // clicking save - $this->click('_qf_Field_next-bottom'); + $this->click('_qf_Field_done-bottom'); $this->waitForElementPresent('newCustomField'); - $this->assertTrue($this->isTextPresent("Custom field '{$customField}' has been saved.")); + $this->waitForText('crm-notification-container', "Custom field '{$customField}' has been saved."); $customFieldId = explode('&id=', $this->getAttribute("xpath=//div[@id='field_page']//table/tbody//tr/td/span[text()='$customField']/../../td[8]/span/a@href")); $customFieldId = $customFieldId[1]; diff --git a/tests/phpunit/WebTest/Import/CustomDataTest.php b/tests/phpunit/WebTest/Import/CustomDataTest.php index 78282b0d99..2e5f2859df 100644 --- a/tests/phpunit/WebTest/Import/CustomDataTest.php +++ b/tests/phpunit/WebTest/Import/CustomDataTest.php @@ -173,10 +173,12 @@ class WebTest_Import_CustomDataTest extends ImportCiviSeleniumTestCase { $this->select("extends[0]", "value=Contact"); $this->click("//option[@value='Contact']"); $this->click('_qf_Group_next-bottom'); - $this->waitForElementPresent('_qf_Field_cancel-bottom'); + $this->waitForElementPresent('newCustomField'); //Is custom group created? $this->assertTrue($this->isTextPresent("Your custom field set '{$customGroupTitle}' has been added. You can add custom fields now.")); + $this->click('newCustomField'); + $this->waitForElementPresent('_qf_Field_cancel-bottom'); $url = explode('gid=', $this->getLocation()); $gid = $url[1]; @@ -207,11 +209,12 @@ class WebTest_Import_CustomDataTest extends ImportCiviSeleniumTestCase { $this->click("is_searchable"); // clicking save - $this->click('_qf_Field_next-bottom'); + $this->click('_qf_Field_done-bottom'); $this->waitForElementPresent('newCustomField'); - $this->assertTrue($this->isTextPresent("Custom field '{$dateFieldLabel}' has been saved.")); + $this->waitForText('crm-notification-container', "Custom field '{$dateFieldLabel}' has been saved."); + $this->waitForElementPresent("xpath=//div[@id='field_page']//table/tbody//tr/td/span[text()='$dateFieldLabel']"); $dateFieldId = explode('&id=', $this->getAttribute("xpath=//div[@id='field_page']//table/tbody//tr/td/span[text()='$dateFieldLabel']/../../td[8]/span/a@href")); $dateFieldId = $dateFieldId[1]; @@ -247,7 +250,7 @@ class WebTest_Import_CustomDataTest extends ImportCiviSeleniumTestCase { $this->click("is_searchable"); //clicking save - $this->click("_qf_Field_next"); + $this->click("_qf_Field_done"); $this->waitForElementPresent('newCustomField'); //Is custom field created @@ -288,7 +291,7 @@ class WebTest_Import_CustomDataTest extends ImportCiviSeleniumTestCase { $this->click("is_searchable"); // clicking save - $this->click('_qf_Field_next-bottom'); + $this->click('_qf_Field_done-bottom'); $this->waitForElementPresent('newCustomField'); $this->waitForText("crm-notification-container", "Custom field '{$multiSelectLabel}' has been saved."); $this->waitForElementPresent("xpath=//div[@id='field_page']//table/tbody//tr/td/span[text()='$multiSelectLabel']/parent::td/parent::tr/"); @@ -313,10 +316,11 @@ class WebTest_Import_CustomDataTest extends ImportCiviSeleniumTestCase { $this->click("is_searchable"); // clicking save - $this->click('_qf_Field_next-bottom'); + $this->click('_qf_Field_done-bottom'); $this->waitForElementPresent('newCustomField'); $this->waitForText("crm-notification-container", "Custom field '{$contactReferenceLabel}' has been saved."); + $this->waitForElementPresent("xpath=//div[@id='field_page']//table/tbody//tr/td/span[text()='$contactReferenceLabel']/parent::td/parent::tr/"); $contactReferenceFieldId = explode('&id=', $this->getAttribute("xpath=//div[@id='field_page']//table/tbody//tr/td/span[text()='$contactReferenceLabel']/parent::td/parent::tr/td[8]/span/a@href")); $contactReferenceFieldId = $contactReferenceFieldId[1]; -- 2.25.1