From b3d402872d211e5e2d8254009150c6262c00dfc5 Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Sun, 21 Sep 2014 21:53:20 -0400 Subject: [PATCH] Webtest fixes --- tests/phpunit/CiviTest/CiviMailUtils.php | 11 +++-------- tests/phpunit/CiviTest/CiviSeleniumTestCase.php | 9 +++------ .../Member/OfflineAutoRenewMembershipTest.php | 15 ++------------- 3 files changed, 8 insertions(+), 27 deletions(-) diff --git a/tests/phpunit/CiviTest/CiviMailUtils.php b/tests/phpunit/CiviTest/CiviMailUtils.php index 1c098de5a0..bd9a5e0584 100644 --- a/tests/phpunit/CiviTest/CiviMailUtils.php +++ b/tests/phpunit/CiviTest/CiviMailUtils.php @@ -164,15 +164,12 @@ class CiviMailUtils extends PHPUnit_Framework_TestCase { $this->_ut->waitForElementPresent('css=td.crm-mailing-name'); // This should select the first "Report" link in the table, which is sorted by Completion Date descending, so in theory is the most recent email. Not sure of a more robust way at the moment. - $this->_ut->click('xpath=//tr[contains(@id, "crm-mailing_")]//a[text()="Report"]'); + $this->_ut->clickLink('xpath=//tr[contains(@id, "crm-mailing_")]//a[text()="Report"]'); // 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->click('xpath=//a[contains(text(), "View complete message")]'); - - $this->_ut->waitForPopUp(NULL, 30000); - $this->_ut->selectPopUp(NULL); + $this->_ut->clickLinkSuppressPopup('xpath=//a[contains(text(), "View complete message")]', NULL); /* * FIXME: * @@ -184,8 +181,6 @@ class CiviMailUtils extends PHPUnit_Framework_TestCase { */ //$msg = $this->_ut->getHtmlSource(); $msg = $this->_ut->getBodyText(); - $this->_ut->close(); - $this->_ut->selectWindow(NULL); } else { @@ -328,7 +323,7 @@ class CiviMailUtils extends PHPUnit_Framework_TestCase { * @return ezcMail */ private function convertToEzc($msg) { - $set = new ezcMailVariableSet($msg); + $set = new ezcMailVariableSet($msg);print_r($msg); $parser = new ezcMailParser(); $mail = $parser->parseMail($set); $this->_ut->assertNotEmpty($mail, 'Cannot parse mail'); diff --git a/tests/phpunit/CiviTest/CiviSeleniumTestCase.php b/tests/phpunit/CiviTest/CiviSeleniumTestCase.php index f6a105f3b4..967dd3d3a9 100644 --- a/tests/phpunit/CiviTest/CiviSeleniumTestCase.php +++ b/tests/phpunit/CiviTest/CiviSeleniumTestCase.php @@ -862,10 +862,8 @@ class CiviSeleniumTestCase extends PHPUnit_Extensions_SeleniumTestCase { $this->type('billing_street_address-5', '234 Lincoln Ave'); $this->type('billing_city-5', 'San Bernadino'); - $this->select('billing_country_id-5', 'value=1228'); - $this->click('billing_state_province_id-5'); - $this->waitForVisible('billing_state_province_id-5'); - $this->select('billing_state_province_id-5', 'label=California'); + $this->select2('billing_country_id-5', 'United States'); + $this->select2('billing_state_province_id-5', 'California'); $this->type('billing_postal_code-5', '93245'); return array($firstName, $middleName, $lastName); @@ -1558,8 +1556,7 @@ class CiviSeleniumTestCase extends PHPUnit_Extensions_SeleniumTestCase { $this->waitForElementPresent("xpath=//div[@class='dataTables_wrapper no-footer']//table/tbody/tr[2]/td[8]/span/a[text()='View']"); // click through to the Activity view screen - $this->click("xpath=//div[@class='dataTables_wrapper no-footer']//table/tbody/tr[2]/td[8]/span/a[text()='View']"); - $this->waitForElementPresent('_qf_Activity_cancel-bottom'); + $this->clickLinkSuppressPopup("xpath=//div[@class='dataTables_wrapper no-footer']//table/tbody/tr[2]/td[8]/span/a[text()='View']", '_qf_Activity_cancel-bottom'); // parse URL to grab the activity id // pass id back to any other tests that call this class diff --git a/tests/phpunit/WebTest/Member/OfflineAutoRenewMembershipTest.php b/tests/phpunit/WebTest/Member/OfflineAutoRenewMembershipTest.php index 4233c31d9e..981455b1aa 100644 --- a/tests/phpunit/WebTest/Member/OfflineAutoRenewMembershipTest.php +++ b/tests/phpunit/WebTest/Member/OfflineAutoRenewMembershipTest.php @@ -84,18 +84,9 @@ class WebTest_Member_OfflineAutoRenewMembershipTest extends CiviSeleniumTestCase $this->webtestAddCreditCardDetails(); - // since country is not pre-selected for offline mode - $this->select("billing_country_id-5", "label=United States"); - //wait for states to populate the select box - // Because it tends to cause problems, all uses of sleep() must be justified in comments - // Sleep should never be used for wait for anything to load from the server - // Justification for this instance: FIXME - sleep(2); - $this->click('billing_state_province_id-5'); $this->webtestAddBillingDetails($firstName, NULL, $lastName); - $this->click("_qf_Membership_upload-bottom"); - $this->waitForPageToLoad($this->getTimeoutMsec()); + $this->clickLink("_qf_Membership_upload-bottom"); // Use Find Members to make sure membership exists $this->openCiviPage("member/search", "reset=1", "member_end_date_high"); @@ -103,8 +94,7 @@ class WebTest_Member_OfflineAutoRenewMembershipTest extends CiviSeleniumTestCase $this->type("sort_name", "$firstName $lastName"); $this->click("member_test"); $this->clickLink("_qf_Search_refresh", "xpath=//div[@id='memberSearch']/table/tbody/tr[1]/td[11]/span/a[text()='View']"); - $this->click("xpath=//div[@id='memberSearch']/table/tbody/tr[1]/td[11]/span/a[text()='View']"); - $this->waitForElementPresent("_qf_MembershipView_cancel-bottom"); + $this->clickAjaxLink("xpath=//div[@id='memberSearch']/table/tbody/tr[1]/td[11]/span/a[text()='View']", "_qf_MembershipView_cancel-bottom"); // View Membership Record $verifyData = array( @@ -119,7 +109,6 @@ class WebTest_Member_OfflineAutoRenewMembershipTest extends CiviSeleniumTestCase preg_quote($value) ); } - $this->waitForElementPresent("_qf_MembershipView_cancel-bottom"); } } -- 2.25.1