From: Coleman Watts Date: Thu, 25 Sep 2014 18:29:47 +0000 (-0400) Subject: clickPopupLink - add webtest method X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=a5d61f09a0c5c5bada02310982d6c40836760ec2;p=civicrm-core.git clickPopupLink - add webtest method --- diff --git a/tests/phpunit/CiviTest/CiviMailUtils.php b/tests/phpunit/CiviTest/CiviMailUtils.php index 0af4f729be..24c2fd7597 100644 --- a/tests/phpunit/CiviTest/CiviMailUtils.php +++ b/tests/phpunit/CiviTest/CiviMailUtils.php @@ -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 { diff --git a/tests/phpunit/CiviTest/CiviSeleniumTestCase.php b/tests/phpunit/CiviTest/CiviSeleniumTestCase.php index 8a616dc134..cf0a2ae1cb 100644 --- a/tests/phpunit/CiviTest/CiviSeleniumTestCase.php +++ b/tests/phpunit/CiviTest/CiviSeleniumTestCase.php @@ -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: diff --git a/tests/phpunit/WebTest/Case/AddCaseTest.php b/tests/phpunit/WebTest/Case/AddCaseTest.php index 6198e25f6f..d006267118 100644 --- a/tests/phpunit/WebTest/Case/AddCaseTest.php +++ b/tests/phpunit/WebTest/Case/AddCaseTest.php @@ -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"); diff --git a/tests/phpunit/WebTest/Case/AddCaseTypeTest.php b/tests/phpunit/WebTest/Case/AddCaseTypeTest.php index 51e01932cb..443eb7b839 100644 --- a/tests/phpunit/WebTest/Case/AddCaseTypeTest.php +++ b/tests/phpunit/WebTest/Case/AddCaseTypeTest.php @@ -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"); diff --git a/tests/phpunit/WebTest/Case/CaseCustomFieldsTest.php b/tests/phpunit/WebTest/Case/CaseCustomFieldsTest.php index e454dfa94e..55d88df4b0 100644 --- a/tests/phpunit/WebTest/Case/CaseCustomFieldsTest.php +++ b/tests/phpunit/WebTest/Case/CaseCustomFieldsTest.php @@ -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'], diff --git a/tests/phpunit/WebTest/Contact/AdvancedSearchTest.php b/tests/phpunit/WebTest/Contact/AdvancedSearchTest.php index eaa7ed4463..e559d044ae 100644 --- a/tests/phpunit/WebTest/Contact/AdvancedSearchTest.php +++ b/tests/phpunit/WebTest/Contact/AdvancedSearchTest.php @@ -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); diff --git a/tests/phpunit/WebTest/Event/AddParticipationTest.php b/tests/phpunit/WebTest/Event/AddParticipationTest.php index 017ae01758..836f203744 100644 --- a/tests/phpunit/WebTest/Event/AddParticipationTest.php +++ b/tests/phpunit/WebTest/Event/AddParticipationTest.php @@ -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('');