clickPopupLink - add webtest method
authorColeman Watts <coleman@civicrm.org>
Thu, 25 Sep 2014 18:29:47 +0000 (14:29 -0400)
committerColeman Watts <coleman@civicrm.org>
Thu, 25 Sep 2014 18:29:47 +0000 (14:29 -0400)
tests/phpunit/CiviTest/CiviMailUtils.php
tests/phpunit/CiviTest/CiviSeleniumTestCase.php
tests/phpunit/WebTest/Case/AddCaseTest.php
tests/phpunit/WebTest/Case/AddCaseTypeTest.php
tests/phpunit/WebTest/Case/CaseCustomFieldsTest.php
tests/phpunit/WebTest/Contact/AdvancedSearchTest.php
tests/phpunit/WebTest/Event/AddParticipationTest.php

index 0af4f729be03b275fb1884a01ad07c831bf728de..24c2fd7597d5eaeee600f40c0ff9e767f2c246c5 100644 (file)
@@ -165,7 +165,7 @@ class CiviMailUtils extends PHPUnit_Framework_TestCase {
       // Also not sure how robust this is, but there isn't a good
       // identifier for this link either.
       $this->_ut->waitForElementPresent('xpath=//a[contains(text(), "View complete message")]');
-      $this->_ut->clickAjaxLink('xpath=//a[contains(text(), "View complete message")]', NULL);
+      $this->_ut->clickAjaxLink('xpath=//a[contains(text(), "View complete message")]');
       $msg = $this->_ut->getText('css=.ui-dialog-content.crm-ajax-container');
     }
     else {
index 8a616dc134f48974011c022f2850e8967bd1f25b..cf0a2ae1cbd50c95fb9147d1efd88a00fcf9c7ff 100644 (file)
@@ -237,11 +237,23 @@ class CiviSeleniumTestCase extends PHPUnit_Extensions_SeleniumTestCase {
   }
 
   /**
-   * Click a link or button and wait for the ajax content to load
+   * Click a link or button and wait for an ajax dialog to load
    * @param string $element
    * @param string $waitFor
    */
-  function clickAjaxLink($element, $waitFor = 'css=.ui-dialog') {
+  function clickPopupLink($element, $waitFor=NULL) {
+    $this->clickAjaxLink($element, 'css=.ui-dialog');
+    if ($waitFor) {
+      $this->waitForElementPresent($waitFor);
+    }
+  }
+
+  /**
+   * Click a link or button and wait for ajax content to load or refresh
+   * @param string $element
+   * @param string $waitFor
+   */
+  function clickAjaxLink($element, $waitFor=NULL) {
     $this->click($element);
     if ($waitFor) {
       $this->waitForElementPresent($waitFor);
@@ -664,9 +676,7 @@ class CiviSeleniumTestCase extends PHPUnit_Extensions_SeleniumTestCase {
     // 6 - Household profile
     $profile = array('4' => 'New Individual', '5' => 'New Organization', '6' => 'New Household');
     $this->clickAt("xpath=//div[@id='$selectId']/a");
-    $this->clickAjaxLink("xpath=//li[@class='select2-no-results']//a[contains(text(),' $profile[$type]')]");
-
-    $this->waitForElementPresent('_qf_Edit_next');
+    $this->clickPopupLink("xpath=//li[@class='select2-no-results']//a[contains(text(),' $profile[$type]')]", '_qf_Edit_next');
 
     switch ($type) {
       case 4:
index 6198e25f6f92d8332bf3f8ca76827c42266ce3fc..d0062671187aad1e05d06db7533f45395705d91e 100644 (file)
@@ -277,7 +277,7 @@ class WebTest_Case_AddCaseTest extends CiviSeleniumTestCase {
     $this->clickLink('_qf_Search_refresh-bottom');
     $this->waitForElementPresent("xpath=//table[@class='caseSelector']/tbody//tr/td[3]/a[text()='{$lastName}, {$firstName}']");
 
-    $this->clickAjaxLink("xpath=//table[@class='caseSelector']/tbody//tr/td[3]/a[text()='{$lastName}, {$firstName}']/../../td[11]/span[2]/ul/li/a[contains(text(),'Assign to Another Client')]");
+    $this->clickPopupLink("xpath=//table[@class='caseSelector']/tbody//tr/td[3]/a[text()='{$lastName}, {$firstName}']/../../td[11]/span[2]/ul/li/a[contains(text(),'Assign to Another Client')]");
     $client = $this->createDialogContact("reassign_contact_id");
     $this->clickLink('_qf_EditClient_done-bottom');
     $this->assertElementContainsText('page-title', "{$client['display_name']} - $caseTypeLabel");
index 51e01932cbfe41f86730d1f5efc4faf00ceac318..443eb7b839d0e7193f8087782a64a4b61b5fd7a8 100644 (file)
@@ -71,7 +71,7 @@ class WebTest_Case_AddCaseTypeTest extends CiviSeleniumTestCase {
       $this->select2("xpath=//tr[@class='addRow']/td[contains(text(),'Add activity:')]/span/div/a", $tActivityType, FALSE, TRUE);
     }
 
-    $this->clickAjaxLink("xpath=//div[@class='crm-submit-buttons']/span/input[@value='Save']", NULL);
+    $this->clickAjaxLink("xpath=//div[@class='crm-submit-buttons']/span/input[@value='Save']");
 
     $this->openCiviPage('case/add', 'reset=1&action=add&atype=13&context=standalone', '_qf_Case_upload-bottom');
     $client = $this->createDialogContact("client_id");
index e454dfa94e7eef78da9938031361ff8357cf0303..55d88df4b01c03fe1d0fe457ca22135187bf3756 100644 (file)
@@ -118,7 +118,7 @@ class WebTest_Case_CaseCustomFieldsTest extends CiviSeleniumTestCase {
     $this->checkCRMAlert("Case opened successfully.");
     $this->clickLink("_qf_CaseView_cancel-bottom");
     $this->openCiviPage('case', 'reset=1', "xpath=//table[@class='caseSelector']/tbody//tr/td[2]/a[text()='{$client['sort_name']}']/../../td[8]/a[text()='Open Case']");
-    $this->clickAjaxLink("xpath=//table[@class='caseSelector']/tbody//tr/td[2]/a[text()='{$client['sort_name']}']/../../td[8]/a[text()='Open Case']");
+    $this->clickPopupLink("xpath=//table[@class='caseSelector']/tbody//tr/td[2]/a[text()='{$client['sort_name']}']/../../td[8]/a[text()='Open Case']");
 
     $openCaseData = array(
       "Client" => $client['display_name'],
index eaa7ed4463c3a7c850345f49f313dce24bf2337f..e559d044ae84f3ca88a349bbb1a2db16e43405da 100644 (file)
@@ -58,7 +58,7 @@ class WebTest_Contact_AdvancedSearchTest extends CiviSeleniumTestCase {
     // go to group tab and add to new group
     $this->clickAjaxLink("css=li#tab_group a", "_qf_GroupContact_next");
     $this->select("group_id", "$groupName");
-    $this->clickAjaxLink("_qf_GroupContact_next", NULL);
+    $this->clickAjaxLink("_qf_GroupContact_next");
     $this->waitForText('crm-notification-container', "Contact has been added to '$groupName'");
 
     // go to tag tab and add to new tag
@@ -67,7 +67,7 @@ class WebTest_Contact_AdvancedSearchTest extends CiviSeleniumTestCase {
     $this->checkCRMStatus();
 
     // register for event ( auto add activity and contribution )
-    $this->clickAjaxLink("link=Register for Event");
+    $this->clickPopupLink("link=Register for Event");
     $this->waitForText('s2id_event_id', "- select event -");
     $this->select2("event_id", "Fall Fundraiser Dinner");
     $this->waitForElementPresent("receipt_text");
@@ -83,7 +83,7 @@ class WebTest_Contact_AdvancedSearchTest extends CiviSeleniumTestCase {
     $this->waitForText('crm-notification-container', "Event registration for $firstName adv$firstName has been added");
 
     // Add pledge
-    $this->clickAjaxLink("link=Add Pledge");
+    $this->clickPopupLink("link=Add Pledge");
     $this->waitForElementPresent("contribution_page_id");
     $this->type("amount", "200");
     $this->type("installments", "5");
@@ -93,7 +93,7 @@ class WebTest_Contact_AdvancedSearchTest extends CiviSeleniumTestCase {
     $this->waitForText('crm-notification-container', "Pledge has been recorded and the payment schedule has been created.");
 
     // Add membership
-    $this->clickAjaxLink("link=Add Membership", "_qf_Membership_cancel-bottom");
+    $this->clickPopupLink("link=Add Membership", "_qf_Membership_cancel-bottom");
     //let the organisation be default (Default Organization)
     $this->select("membership_type_id[0]", "value=1");
     $this->click("membership_type_id[1]");
@@ -103,7 +103,7 @@ class WebTest_Contact_AdvancedSearchTest extends CiviSeleniumTestCase {
     $this->waitForText('crm-notification-container', "Student membership for $firstName adv$firstName has been added");
 
     // Add relationship
-    $this->clickAjaxLink("link=Add Relationship", "_qf_Relationship_cancel");
+    $this->clickPopupLink("link=Add Relationship", "_qf_Relationship_cancel");
     $this->select2("relationship_type_id", "Employee of");
     $this->waitForElementPresent("xpath=//input[@id='related_contact_id'][@placeholder='- select organization -']");
     $this->select2("related_contact_id", "Default", TRUE);
index 017ae01758b5ab33da960deef8248c2ed89bc754..836f203744a4f8d7ae47a8887406d553e9a4c417 100644 (file)
@@ -193,7 +193,7 @@ class WebTest_Event_AddParticipationTest extends CiviSeleniumTestCase {
     $this->waitForAjaxContent();
 
     //create another custom field - Integer Radio
-    $this->clickAjaxLink('newCustomField', '_qf_Field_cancel');
+    $this->clickPopupLink('newCustomField', '_qf_Field_cancel');
     $this->click('data_type[0]');
     $this->select('data_type[0]', 'value=1');
     $this->click("//option[@value='1']");
@@ -227,7 +227,7 @@ class WebTest_Event_AddParticipationTest extends CiviSeleniumTestCase {
     $this->click('is_searchable');
 
     //clicking save
-    $this->clickAjaxLink('_qf_Field_done-bottom', NULL);
+    $this->clickAjaxLink('_qf_Field_done-bottom');
 
     // Visit home page for a sec to give caches time to be cleared
     $this->openCiviPage('');