From e684c1ae215abcde2cd7fbb61a8edd70b9996bd5 Mon Sep 17 00:00:00 2001 From: Web Access Date: Fri, 22 Apr 2016 18:40:32 +0530 Subject: [PATCH] Webtests Fixes --- tests/phpunit/WebTest/Admin/CustomAddTest.php | 4 ++-- .../phpunit/WebTest/Admin/Form/ScheduleReminderTest.php | 3 +++ tests/phpunit/WebTest/Case/AddCaseTest.php | 4 ++-- tests/phpunit/WebTest/Contact/CustomDataAddTest.php | 4 ++-- tests/phpunit/WebTest/Contact/InlineFieldsEditTest.php | 9 +++------ tests/phpunit/WebTest/Contact/MergeContactsTest.php | 3 +++ tests/phpunit/WebTest/Contribute/AddBatchesTest.php | 6 +++--- .../WebTest/Contribute/OfflineContributionTest.php | 6 +++--- tests/phpunit/WebTest/Contribute/StandaloneAddTest.php | 4 ++-- .../Contribute/UpdateBatchPendingContributionTest.php | 2 +- 10 files changed, 24 insertions(+), 21 deletions(-) diff --git a/tests/phpunit/WebTest/Admin/CustomAddTest.php b/tests/phpunit/WebTest/Admin/CustomAddTest.php index d7623aafbb..d29664a60d 100644 --- a/tests/phpunit/WebTest/Admin/CustomAddTest.php +++ b/tests/phpunit/WebTest/Admin/CustomAddTest.php @@ -78,11 +78,11 @@ class WebTest_Admin_CustomAddTest extends CiviSeleniumTestCase { $checkboxOptionLabel2 = 'check2' . substr(sha1(rand()), 0, 3); $this->type("option_label_2", $checkboxOptionLabel2); $this->type("option_value_2", "2"); - $this->click("link=another choice"); + $this->click("link=add another choice"); $checkboxOptionLabel3 = 'check3' . substr(sha1(rand()), 0, 3); $this->type("option_label_3", $checkboxOptionLabel3); $this->type("option_value_3", "3"); - $this->click("link=another choice"); + $this->click("link=add another choice"); $checkboxOptionLabel4 = 'check4' . substr(sha1(rand()), 0, 3); $this->type("option_label_4", $checkboxOptionLabel4); $this->type("option_value_4", "4"); diff --git a/tests/phpunit/WebTest/Admin/Form/ScheduleReminderTest.php b/tests/phpunit/WebTest/Admin/Form/ScheduleReminderTest.php index 7c74b7df51..6038829e42 100644 --- a/tests/phpunit/WebTest/Admin/Form/ScheduleReminderTest.php +++ b/tests/phpunit/WebTest/Admin/Form/ScheduleReminderTest.php @@ -43,6 +43,7 @@ class WebTest_Admin_Form_ScheduleReminderTest extends CiviSeleniumTestCase { // Fill Title $title = 'Title' . substr(sha1(rand()), 0, 4); + $htmlMessage = "Schedule Reminder Test"; $this->type('title', $title); // Fill Entity Details @@ -60,6 +61,8 @@ class WebTest_Admin_Form_ScheduleReminderTest extends CiviSeleniumTestCase { // Fill Subject $subject = 'subject' . substr(sha1(rand()), 0, 4); $this->type('subject', $subject); + $this->waitForElementPresent("html_message"); + $this->fillRichTextField("html_message", $htmlMessage); //click on save $this->click('_qf_ScheduleReminders_next-bottom'); diff --git a/tests/phpunit/WebTest/Case/AddCaseTest.php b/tests/phpunit/WebTest/Case/AddCaseTest.php index 14f07e487e..379664e09f 100644 --- a/tests/phpunit/WebTest/Case/AddCaseTest.php +++ b/tests/phpunit/WebTest/Case/AddCaseTest.php @@ -195,10 +195,10 @@ class WebTest_Case_AddCaseTest extends CiviSeleniumTestCase { $this->waitForElementPresent("xpath=//table[@id='caseRoles-selector-$id']/tbody/tr[4]/td[2]/a"); // check that expected roles are listed in the Case Roles pane foreach ($caseRoles as $role) { - $this->assertText("css=div.crm-case-roles-block", $role); + $this->assertElementContainsText("xpath=//table[@id='caseRoles-selector-$id']/tbody/tr[4]/td[1]", $role); } // check that case creator role has been assigned to logged in user - $this->verifyText("xpath=//table[@id='caseRoles-selector-$id']/tbody/tr[4]/td[2]", $creatorName); + $this->assertElementContainsText("xpath=//table[@id='caseRoles-selector-$id']/tbody/tr[4]/td[2]", $creatorName); } /** diff --git a/tests/phpunit/WebTest/Contact/CustomDataAddTest.php b/tests/phpunit/WebTest/Contact/CustomDataAddTest.php index 00c86ad42d..1c3d2b1dcc 100644 --- a/tests/phpunit/WebTest/Contact/CustomDataAddTest.php +++ b/tests/phpunit/WebTest/Contact/CustomDataAddTest.php @@ -68,7 +68,7 @@ class WebTest_Contact_CustomDataAddTest extends CiviSeleniumTestCase { $checkboxOptionLabel2 = 'optionLabel_' . substr(sha1(rand()), 0, 5); $this->type("option_label_2", $checkboxOptionLabel2); $this->type("option_value_2", "2"); - $this->click("link=another choice"); + $this->click("link=add another choice"); $checkboxOptionLabel3 = 'optionLabel_' . substr(sha1(rand()), 0, 5); $this->type("option_label_3", $checkboxOptionLabel3); $this->type("option_value_3", "3"); @@ -109,7 +109,7 @@ class WebTest_Contact_CustomDataAddTest extends CiviSeleniumTestCase { $radioOptionLabel2 = 'optionLabel_' . substr(sha1(rand()), 0, 5); $this->type("option_label_2", $radioOptionLabel2); $this->type("option_value_2", "2"); - $this->click("link=another choice"); + $this->click("link=add another choice"); $radioOptionLabel3 = 'optionLabel_' . substr(sha1(rand()), 0, 5); $this->type("option_label_3", $radioOptionLabel3); $this->type("option_value_3", "3"); diff --git a/tests/phpunit/WebTest/Contact/InlineFieldsEditTest.php b/tests/phpunit/WebTest/Contact/InlineFieldsEditTest.php index 6e49c36540..70796b4d10 100644 --- a/tests/phpunit/WebTest/Contact/InlineFieldsEditTest.php +++ b/tests/phpunit/WebTest/Contact/InlineFieldsEditTest.php @@ -67,15 +67,12 @@ class WebTest_Contact_InlineFieldsEditTest extends CiviSeleniumTestCase { // Custom data $this->click('css=div.crm-custom-set-block-1 .collapsible-title'); - // Because it tends to cause problems, all uses of sleep() must be justified in comments - // NOTE: Sleep should never be used for wait for anything to load from the server - // Justification for this instance: opening an accordion is predictable - sleep(1); + $this->waitForAjaxContent(); $this->openInlineForm('custom-set-content-1'); - $dateFieldId = $this->getAttribute("xpath=//div[@class='crm-accordion-body']/table/tbody/tr[3]/td[@class='html-adjust']/input@id"); + $dateFieldId = $this->getAttribute("xpath=//table[@class='form-layout-compressed']/tbody/tr[3]/td[@class='html-adjust']/span/input@id"); $this->inlineEdit('custom-set-content-1', array( 'CIVICRM_QFID_Edu_2' => 1, - "//div[@class='crm-accordion-body']/table/tbody/tr[2]/td[@class='html-adjust']/select" => array('Single'), + "//table[@class='form-layout-compressed']/tbody/tr[2]/td[@class='html-adjust']/select" => array('Single'), $dateFieldId => 'date: now - 10 years', )); diff --git a/tests/phpunit/WebTest/Contact/MergeContactsTest.php b/tests/phpunit/WebTest/Contact/MergeContactsTest.php index 2ef2cc8b0e..d86f7b7241 100644 --- a/tests/phpunit/WebTest/Contact/MergeContactsTest.php +++ b/tests/phpunit/WebTest/Contact/MergeContactsTest.php @@ -827,6 +827,7 @@ class WebTest_Contact_MergeContactsTest extends CiviSeleniumTestCase { // add relationship "Employer of" // click through to the relationship view screen + $this->waitForAjaxContent(); $this->click("css=li#tab_rel a"); // wait for add Relationship link @@ -875,6 +876,7 @@ class WebTest_Contact_MergeContactsTest extends CiviSeleniumTestCase { // add relationship "Employer of" // click through to the relationship view screen + $this->waitForAjaxContent(); $this->click("css=li#tab_rel a"); // wait for add Relationship link @@ -916,6 +918,7 @@ class WebTest_Contact_MergeContactsTest extends CiviSeleniumTestCase { $this->waitForPageToLoad($this->getTimeoutMsec()); // click through to the relationship view screen + $this->waitForAjaxContent(); $this->click("css=li#tab_rel a"); // wait for add Relationship link diff --git a/tests/phpunit/WebTest/Contribute/AddBatchesTest.php b/tests/phpunit/WebTest/Contribute/AddBatchesTest.php index 1c03d940ec..8a471ecbd4 100644 --- a/tests/phpunit/WebTest/Contribute/AddBatchesTest.php +++ b/tests/phpunit/WebTest/Contribute/AddBatchesTest.php @@ -284,7 +284,7 @@ class WebTest_Contribute_AddBatchesTest extends CiviSeleniumTestCase { 'Soft Credit Type' => $data['soft_credit_type'], ); foreach ($expectedSoft as $value) { - $this->verifyText("css=table.crm-soft-credit-listing", preg_quote($value)); + $this->assertElementContainsText("css=table.crm-soft-credit-listing", $value); } } elseif ($type == "Membership") { @@ -300,7 +300,7 @@ class WebTest_Contribute_AddBatchesTest extends CiviSeleniumTestCase { 4 => 'New', ); foreach ($expected as $label => $value) { - $this->verifyText("xpath=id('MembershipView')/div[2]/div/table[1]/tbody/tr[$label]/td[2]", preg_quote($value)); + $this->assertElementContainsText("xpath=id('MembershipView')/div[2]/div/table[1]/tbody/tr[$label]/td[2]", $value); } //View Contribution $this->waitForElementPresent("xpath=//form[@id='MembershipView']/div[2]/div/div[2]/div[2]/table/tbody/tr[1]/td[8]/span/a[1][text()='View']"); @@ -320,7 +320,7 @@ class WebTest_Contribute_AddBatchesTest extends CiviSeleniumTestCase { 'Soft Credit Type' => $data['soft_credit_type'], ); foreach ($expectedSoft as $value) { - $this->verifyText("css=table.crm-soft-credit-listing", preg_quote($value)); + $this->assertElementContainsText("css=table.crm-soft-credit-listing", $value); } } } diff --git a/tests/phpunit/WebTest/Contribute/OfflineContributionTest.php b/tests/phpunit/WebTest/Contribute/OfflineContributionTest.php index fb79858daa..6e2d73ae14 100644 --- a/tests/phpunit/WebTest/Contribute/OfflineContributionTest.php +++ b/tests/phpunit/WebTest/Contribute/OfflineContributionTest.php @@ -168,7 +168,7 @@ class WebTest_Contribute_OfflineContributionTest extends CiviSeleniumTestCase { $this->waitForElementPresent("xpath=//*[@id='ContributionView']/div[2]"); foreach ($expected as $value) { - $this->verifyText("xpath=//*[@id='ContributionView']/div[2]", preg_quote($value)); + $this->assertElementContainsText("xpath=//*[@id='ContributionView']/div[2]", $value); } // verify if soft credit was created successfully @@ -179,7 +179,7 @@ class WebTest_Contribute_OfflineContributionTest extends CiviSeleniumTestCase { ); foreach ($expected as $value) { - $this->verifyText("css=table.crm-soft-credit-listing", preg_quote($value)); + $this->assertElementContainsText("css=table.crm-soft-credit-listing", $value); } // go to first soft creditor contact view page @@ -198,7 +198,7 @@ class WebTest_Contribute_OfflineContributionTest extends CiviSeleniumTestCase { 1 => "{$firstName} {$lastName}", ); foreach ($expected as $value => $label) { - $this->verifyText("xpath=//div[@class='view-content']//table[@class='selector row-highlight']//tbody/tr[2]/td[$value]", preg_quote($label)); + $this->assertElementContainsText("xpath=//div[@class='view-content']//table[@class='selector row-highlight']//tbody/tr[2]/td[$value]", $label); } } diff --git a/tests/phpunit/WebTest/Contribute/StandaloneAddTest.php b/tests/phpunit/WebTest/Contribute/StandaloneAddTest.php index c7834913ee..5b67c6c1c0 100644 --- a/tests/phpunit/WebTest/Contribute/StandaloneAddTest.php +++ b/tests/phpunit/WebTest/Contribute/StandaloneAddTest.php @@ -142,13 +142,13 @@ class WebTest_Contribute_StandaloneAddTest extends CiviSeleniumTestCase { $this->waitForText("crm-notification-container", "The contribution record has been saved."); // verify if Membership is created - $this->waitForElementPresent("xpath=//form[@class='CRM_Contribute_Form_Search crm-search-form']//div[2]table[@class='selector row-highlight']//tbody/tr[1]/td[8]/span//a[text()='View']"); + $this->waitForElementPresent("xpath=//form[@class='CRM_Contribute_Form_Search crm-search-form']//div[2]/table[@class='selector row-highlight']//tbody/tr[1]/td[8]/span//a[text()='View']"); $contriID = $this->urlArg('id', $this->getAttribute("xpath=//table[@class='selector row-highlight']//tbody/tr[1]/td[8]/span//a[text()='Edit']@href")); $contactID = $this->urlArg('cid', $this->getAttribute("xpath=//table[@class='selector row-highlight']//tbody/tr[1]/td[8]/span//a[text()='Edit']@href")); //click through to the Membership view screen - $this->click("xpath=//form[@class='CRM_Contribute_Form_Search crm-search-form']//div[2]table[@class='selector row-highlight']//tbody/tr[1]/td[8]/span//a[text()='View']"); + $this->click("xpath=//form[@class='CRM_Contribute_Form_Search crm-search-form']//div[2]/table[@class='selector row-highlight']//tbody/tr[1]/td[8]/span//a[text()='View']"); $this->waitForElementPresent("_qf_ContributionView_cancel-bottom"); $expected = array( diff --git a/tests/phpunit/WebTest/Contribute/UpdateBatchPendingContributionTest.php b/tests/phpunit/WebTest/Contribute/UpdateBatchPendingContributionTest.php index c3a677bd34..953b2a2aa2 100644 --- a/tests/phpunit/WebTest/Contribute/UpdateBatchPendingContributionTest.php +++ b/tests/phpunit/WebTest/Contribute/UpdateBatchPendingContributionTest.php @@ -225,7 +225,7 @@ class WebTest_Contribute_UpdateBatchPendingContributionTest extends CiviSelenium 'Contribution Status' => 'Pending', ); foreach ($expected as $label => $value) { - $this->verifyText("xpath=id('ContributionView')/div[2]/table[1]/tbody//tr/td[1][text()='$label']/../td[2]", preg_quote($value)); + $this->assertElementContainsText("xpath=id('ContributionView')/div[2]/table[1]/tbody//tr/td[1][text()='$label']/../td[2]", $value); } } -- 2.25.1