From 8a65f8da962713f69b7ee7b1586081a45231d68e Mon Sep 17 00:00:00 2001 From: jitendrapurohit Date: Fri, 22 Apr 2016 18:38:31 +0530 Subject: [PATCH] CRM-18454: webtest fixes --- .../phpunit/CiviTest/CiviSeleniumTestCase.php | 16 +++++------ .../phpunit/WebTest/Case/AddCaseTypeTest.php | 4 +-- .../Contact/PrivacyOptionSearchTest.php | 28 ++++++------------- .../Contribute/ContactContextAddTest.php | 6 ++-- 4 files changed, 20 insertions(+), 34 deletions(-) diff --git a/tests/phpunit/CiviTest/CiviSeleniumTestCase.php b/tests/phpunit/CiviTest/CiviSeleniumTestCase.php index 8be6a5382c..4fb2fda525 100644 --- a/tests/phpunit/CiviTest/CiviSeleniumTestCase.php +++ b/tests/phpunit/CiviTest/CiviSeleniumTestCase.php @@ -2328,23 +2328,23 @@ class CiviSeleniumTestCase extends PHPUnit_Extensions_SeleniumTestCase { /** * Select multiple options. - * @param $fieldid - * @param $params + * @param $fieldId + * @param $options * @param $isDate if multiple date is to be selected from datepicker */ - public function multiselect2($fieldid, $params, $isDate = FALSE) { + public function multiselect2($fieldId, $options, $isDate = FALSE) { // In the case of chainSelect, wait for options to load $this->waitForElementNotPresent('css=select.loading'); - foreach ($params as $value) { + foreach ($options as $value) { if ($isDate) { - $this->clickAt("xpath=//*[@id='$fieldid']/../div/ul//li/input"); - $this->webtestFillDate($fieldid, $value, TRUE); + $this->clickAt("xpath=//*[@id='$fieldId']/../div/ul//li/input"); + $this->webtestFillDate($fieldId, $value, TRUE); } else { - $this->clickAt("xpath=//*[@id='$fieldid']/../div/ul//li/input"); + $this->clickAt("xpath=//*[@id='$fieldId']/../div/ul//li/input"); $this->waitForElementPresent("xpath=//ul[@class='select2-results']"); $this->clickAt("xpath=//ul[@class='select2-results']//li/div[text()='$value']"); - $this->assertElementContainsText("xpath=//*[@id='$fieldid']/preceding-sibling::div[1]/", $value); + $this->assertElementContainsText("xpath=//*[@id='$fieldId']/preceding-sibling::div[1]/", $value); } } // Wait a sec for select2 to update the original element diff --git a/tests/phpunit/WebTest/Case/AddCaseTypeTest.php b/tests/phpunit/WebTest/Case/AddCaseTypeTest.php index 6f6961f9ed..8be86fbefe 100644 --- a/tests/phpunit/WebTest/Case/AddCaseTypeTest.php +++ b/tests/phpunit/WebTest/Case/AddCaseTypeTest.php @@ -113,13 +113,13 @@ class WebTest_Case_AddCaseTypeTest extends CiviSeleniumTestCase { // check that expected roles are listed in the Case Roles pane foreach ($caseRoles as $key => $role) { - $this->assertText("css=div.crm-case-roles-block", $role); + $this->assertElementContainsText("css=div.crm-case-roles-block", $role); } $id = $this->urlArg('id'); // check that expected activities are listed in the Case Activities table foreach ($timelineActivityTypes as $tActivityType) { - $this->assertText("case_id_$id", $tActivityType); + $this->assertElementContainsText("case_id_$id", $tActivityType); } // for edit case type diff --git a/tests/phpunit/WebTest/Contact/PrivacyOptionSearchTest.php b/tests/phpunit/WebTest/Contact/PrivacyOptionSearchTest.php index 6c77e883c5..428307734a 100644 --- a/tests/phpunit/WebTest/Contact/PrivacyOptionSearchTest.php +++ b/tests/phpunit/WebTest/Contact/PrivacyOptionSearchTest.php @@ -109,14 +109,10 @@ class WebTest_Contact_PrivacyOptionSearchTest extends CiviSeleniumTestCase { // Go to advance search, check for 'Exclude' option. $this->openCiviPage("contact/search/advanced", "reset=1"); - $this->select("xpath=//form[@id='Advanced']//table[1]/tbody/tr[2]/td[2]//select[1]", "label={$groupName}"); + $this->select("group", "label={$groupName}"); $this->waitForTextPresent($groupName); - $this->select("xpath=//form[@id='Advanced']//table[1]/tbody/tr[5]/td[1]/table[1]/tbody/tr[2]/td[1]//select[1]", 'value=do_not_phone'); - $this->waitForTextPresent('Do not phone'); - - $this->select("xpath=//form[@id='Advanced']//table[1]/tbody/tr[5]/td[1]/table[1]/tbody/tr[2]/td[1]//select[1]", 'value=do_not_email'); - $this->waitForTextPresent('Do not email'); + $this->multiselect2('privacy_options', array('Do not phone', 'Do not email')); $this->click("_qf_Advanced_refresh"); $this->waitForPageToLoad(2 * $this->getTimeoutMsec()); @@ -126,16 +122,12 @@ class WebTest_Contact_PrivacyOptionSearchTest extends CiviSeleniumTestCase { // Go to advance search, check for 'Include' + 'OR' options. $this->openCiviPage("contact/search/advanced", "reset=1"); - $this->select("xpath=//form[@id='Advanced']//table[1]/tbody/tr[2]/td[2]//select[1]", "label={$groupName}"); + $this->select("group", "label={$groupName}"); $this->waitForTextPresent($groupName); - $this->click("xpath=//form[@id='Advanced']//table[1]/tbody/tr[5]/td[1]/table[1]/tbody/tr[1]/td[1]//input[2]"); - - $this->select("xpath=//form[@id='Advanced']//table[1]/tbody/tr[5]/td[1]/table[1]/tbody/tr[2]/td[1]//select[1]", 'value=do_not_phone'); - $this->waitForTextPresent('Do not phone'); + $this->click("CIVICRM_QFID_2_privacy_toggle"); - $this->select("xpath=//form[@id='Advanced']//table[1]/tbody/tr[5]/td[1]/table[1]/tbody/tr[2]/td[1]//select[1]", 'value=do_not_email'); - $this->waitForTextPresent('Do not email'); + $this->multiselect2('privacy_options', array('Do not phone', 'Do not email')); $this->click("_qf_Advanced_refresh"); $this->waitForPageToLoad(2 * $this->getTimeoutMsec()); @@ -146,16 +138,12 @@ class WebTest_Contact_PrivacyOptionSearchTest extends CiviSeleniumTestCase { // Go to advance search, check for 'Include' + 'AND' options. $this->openCiviPage("contact/search/advanced", "reset=1"); - $this->select("xpath=//form[@id='Advanced']//table[1]/tbody/tr[2]/td[2]//select[1]", "label={$groupName}"); + $this->select("group", "label={$groupName}"); $this->waitForTextPresent($groupName); - $this->click("xpath=//form[@id='Advanced']//table[1]/tbody/tr[5]/td[1]/table[1]/tbody/tr[1]/td[1]//input[2]"); - - $this->select("xpath=//form[@id='Advanced']//table[1]/tbody/tr[5]/td[1]/table[1]/tbody/tr[2]/td[1]//select[1]", 'value=do_not_phone'); - $this->waitForTextPresent('Do not phone'); + $this->click("CIVICRM_QFID_2_privacy_toggle"); - $this->select("xpath=//form[@id='Advanced']//table[1]/tbody/tr[5]/td[1]/table[1]/tbody/tr[2]/td[1]//select[1]", 'value=do_not_trade'); - $this->waitForTextPresent('Do not trade'); + $this->multiselect2('privacy_options', array('Do not phone', 'Do not trade')); $this->select('privacy_operator', 'value=AND'); diff --git a/tests/phpunit/WebTest/Contribute/ContactContextAddTest.php b/tests/phpunit/WebTest/Contribute/ContactContextAddTest.php index 6a935a96ea..d69c188c2e 100644 --- a/tests/phpunit/WebTest/Contribute/ContactContextAddTest.php +++ b/tests/phpunit/WebTest/Contribute/ContactContextAddTest.php @@ -159,9 +159,7 @@ class WebTest_Contribute_ContactContextAddTest extends CiviSeleniumTestCase { 'Check Number' => 'check #1041', ); foreach ($verifyData as $label => $value) { - $this->verifyText("xpath=//form[@id='ContributionView']//table/tbody/tr/td[text()='{$label}']/following-sibling::td", - preg_quote($value) - ); + $this->assertElementContainsText("xpath=//form[@id='ContributionView']//table/tbody/tr/td[text()='{$label}']/following-sibling::td", $value); } // check values of contribution record in the DB @@ -189,7 +187,7 @@ class WebTest_Contribute_ContactContextAddTest extends CiviSeleniumTestCase { 1 => "{$firstName} Anderson", ); foreach ($expected as $value => $label) { - $this->verifyText("xpath=id('Search')/div[2]/table[2]/tbody//tr/td[$value]", preg_quote($label)); + $this->assertElementContainsText("xpath=id('Search')/div[2]/table[2]/tbody//tr/td[$value]", $label); } } -- 2.25.1