CRM-18454: webtest fixes
authorjitendrapurohit <jitendra.purohit@webaccessglobal.com>
Fri, 22 Apr 2016 13:08:31 +0000 (18:38 +0530)
committerjitendrapurohit <jitendra.purohit@webaccessglobal.com>
Fri, 22 Apr 2016 13:08:31 +0000 (18:38 +0530)
tests/phpunit/CiviTest/CiviSeleniumTestCase.php
tests/phpunit/WebTest/Case/AddCaseTypeTest.php
tests/phpunit/WebTest/Contact/PrivacyOptionSearchTest.php
tests/phpunit/WebTest/Contribute/ContactContextAddTest.php

index 8be6a5382cf633d7cb0323dae05b5b126277466d..4fb2fda525742f8a1352775ea372cc83c511d211 100644 (file)
@@ -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
index 6f6961f9edaa617cb1b0ab12931e4a15858a088f..8be86fbefebc95a9959c1f0a7297a2f208496a42 100644 (file)
@@ -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
index 6c77e883c571adf41e5730c5d9c3355ae9101c84..428307734aa35f40dfe6b37980536e845347bbb5 100644 (file)
@@ -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');
 
index 6a935a96ea4f622944a4812a3ca7e4068f77fe87..d69c188c2e9b9f922e882839f86e70203b97a618 100644 (file)
@@ -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);
     }
   }