Webtests Fixes
authorWeb Access <rohan.katkar@webaccessglobal.com>
Fri, 22 Apr 2016 13:10:32 +0000 (18:40 +0530)
committerWeb Access <rohan.katkar@webaccessglobal.com>
Fri, 22 Apr 2016 13:10:32 +0000 (18:40 +0530)
tests/phpunit/WebTest/Admin/CustomAddTest.php
tests/phpunit/WebTest/Admin/Form/ScheduleReminderTest.php
tests/phpunit/WebTest/Case/AddCaseTest.php
tests/phpunit/WebTest/Contact/CustomDataAddTest.php
tests/phpunit/WebTest/Contact/InlineFieldsEditTest.php
tests/phpunit/WebTest/Contact/MergeContactsTest.php
tests/phpunit/WebTest/Contribute/AddBatchesTest.php
tests/phpunit/WebTest/Contribute/OfflineContributionTest.php
tests/phpunit/WebTest/Contribute/StandaloneAddTest.php
tests/phpunit/WebTest/Contribute/UpdateBatchPendingContributionTest.php

index d7623aafbb319b1110d2a99b16014776ce718976..d29664a60dd62fa3359c75f717f285aecf6d3025 100644 (file)
@@ -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");
index 7c74b7df51ed7a6cd58a08c9dbede5d2478551a4..6038829e42590c5d5460077ce825f59573f6c3fc 100644 (file)
@@ -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');
index 14f07e487e79988be426f017c5b6109311400c6e..379664e09f8625c12665a4e090684cfdf038c4ef 100644 (file)
@@ -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);
   }
 
   /**
index 00c86ad42d8a21e958f9836eefe5e26cc21f7c9d..1c3d2b1dccfab9606dd653a4bbbab969df2efcad 100644 (file)
@@ -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");
index 6e49c36540b0df9b4196daecd8763cd2d1bf2870..70796b4d101df8248a09962038c458810defe965 100644 (file)
@@ -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',
     ));
 
index 2ef2cc8b0e6838a0238887214260769530594e36..d86f7b72418e0c1906b5ff45d71b3d35f91b2fd2 100644 (file)
@@ -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
index 1c03d940ec58df1323fe19d8220c2bee8ecf9b2e..8a471ecbd4c53ee4d71f3aa7e6d5b0f32020a386 100644 (file)
@@ -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);
       }
     }
   }
index fb79858daa9ea047b9646c0f10d6eb58d21d18e4..6e2d73ae14298cbfde3bf9e44576dd78a540a5db 100644 (file)
@@ -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);
     }
   }
 
index c7834913eebaa36b748f66321ccb7161e530f278..5b67c6c1c0590e82a016df582a93a34fac6be136 100644 (file)
@@ -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(
index c3a677bd34a143c74ab345d14f45f6ae2737f759..953b2a2aa249d58b338e531b4d42b79aa3983709 100644 (file)
@@ -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);
     }
   }