From 77a2a633c5b1693ccc2535777304f0eb82f2a505 Mon Sep 17 00:00:00 2001 From: jitendrapurohit Date: Fri, 4 Apr 2014 17:50:28 +0530 Subject: [PATCH] Web Tests Fix --- .../phpunit/CiviTest/CiviSeleniumTestCase.php | 3 +- .../WebTest/Contribute/AddPricesetTest.php | 47 ++++++++++--------- .../OnlineAutoRenewMembershipGCTest.php | 6 +-- .../Member/OnlineAutoRenewMembershipTest.php | 18 +++---- 4 files changed, 33 insertions(+), 41 deletions(-) diff --git a/tests/phpunit/CiviTest/CiviSeleniumTestCase.php b/tests/phpunit/CiviTest/CiviSeleniumTestCase.php index 927b557d32..c4be6ed3ba 100644 --- a/tests/phpunit/CiviTest/CiviSeleniumTestCase.php +++ b/tests/phpunit/CiviTest/CiviSeleniumTestCase.php @@ -1672,14 +1672,13 @@ class CiviSeleniumTestCase extends PHPUnit_Extensions_SeleniumTestCase { } $this->click('_qf_FinancialType_next'); - $this->waitForPageToLoad($this->getTimeoutMsec()); if ($option == 'new') { $text = "Your Financial '{$financialType['name']}' Type has been created, along with a corresponding income account '{$financialType['name']}'. That income account, along with standard financial accounts 'Accounts Receivable', 'Banking Fees' and 'Premiums' have been linked to the financial type. You may edit or replace those relationships here."; } else { $text = "The financial type '{$financialType['name']}' has been saved."; } - $this->assertTrue($this->isTextPresent($text), 'Missing text: ' . $text); + $this->waitForText('crm-notification-container', $text); } /** diff --git a/tests/phpunit/WebTest/Contribute/AddPricesetTest.php b/tests/phpunit/WebTest/Contribute/AddPricesetTest.php index f80e836a86..55000e2308 100644 --- a/tests/phpunit/WebTest/Contribute/AddPricesetTest.php +++ b/tests/phpunit/WebTest/Contribute/AddPricesetTest.php @@ -230,9 +230,9 @@ class WebTest_Contribute_AddPricesetTest extends CiviSeleniumTestCase { // select price set items $this->select('price_set_id', "label=$setTitle"); - $this->type("xpath=//input[@class='form-text four required']", "1"); - $this->click("xpath=//input[@class='form-radio']"); - $this->click("xpath=//input[@class='form-checkbox']"); + $this->type("xpath=//input[@class='four crm-form-text required']", "1"); + $this->click("xpath=//input[@class='crm-form-radio']"); + $this->click("xpath=//input[@class='crm-form-checkbox']"); // select payment instrument type = Check and enter chk number $this->select('payment_instrument_id', 'value=4'); $this->waitForElementPresent('check_number'); @@ -258,10 +258,10 @@ class WebTest_Contribute_AddPricesetTest extends CiviSeleniumTestCase { // Is status message correct? $this->assertTrue($this->isTextPresent('The contribution record has been saved.'), "Status message didn't show up after saving!"); - $this->waitForElementPresent("xpath=//div[@id='Contributions']//table//tbody/tr[1]/td[8]/span/a[text()='View']"); + $this->waitForElementPresent("xpath=//div[@class='view-content']//table[@class='selector row-highlight']//tbody/tr[1]/td[8]/span/a[text()='View']"); //click through to the Membership view screen - $this->click("xpath=//div[@id='Contributions']//table/tbody/tr[1]/td[8]/span/a[text()='View']"); + $this->click("xpath=//div[@class='view-content']//table[@class='selector row-highlight']//tbody/tr[1]/td[8]/span/a[text()='View']"); $this->waitForElementPresent('_qf_ContributionView_cancel-bottom'); $expected = array( 2 => $financialType, @@ -355,9 +355,9 @@ class WebTest_Contribute_AddPricesetTest extends CiviSeleniumTestCase { $lastName = 'An' . substr(sha1(rand()), 0, 7); $this->waitForElementPresent('_qf_Main_upload-bottom'); $this->type('email-5', $firstName . '@example.com'); - $this->type("xpath=//input[@class='form-text four required']", "1"); - $this->click("xpath=//input[@class='form-radio']"); - $this->click("xpath=//input[@class='form-checkbox']"); + $this->type("xpath=//input[@class='four crm-form-text required']", "1"); + $this->click("xpath=//input[@class='crm-form-radio']"); + $this->click("xpath=//input[@class='crm-form-checkbox']"); $streetAddress = '100 Main Street'; $this->type('billing_street_address-5', $streetAddress); @@ -396,7 +396,7 @@ class WebTest_Contribute_AddPricesetTest extends CiviSeleniumTestCase { $this->type('sort_name', "$firstName $lastName"); $this->clickLink('_qf_Search_refresh', "xpath=//div[@id='contributionSearch']//table//tbody/tr[1]/td[11]/span/a[text()='View']"); - $this->clickLink("xpath=//div[@id='contributionSearch']//table//tbody/tr[1]/td[11]/span/a[text()='View']", "_qf_ContributionView_cancel-bottom"); + $this->clickLink("xpath=//div[@id='contributionSearch']//table//tbody/tr[1]/td[11]/span/a[text()='View']", "_qf_ContributionView_cancel-bottom", FALSE); // View Contribution Record and test for expected values $expected = array( @@ -474,8 +474,8 @@ class WebTest_Contribute_AddPricesetTest extends CiviSeleniumTestCase { $lastName = 'An' . substr(sha1(rand()), 0, 7); $this->waitForElementPresent('_qf_Main_upload-bottom'); $this->type('email-5', $firstName . '@example.com'); - $this->click("xpath=//input[@class='form-radio']"); - $this->click("xpath=//input[@class='form-checkbox']"); + $this->click("xpath=//input[@class='crm-form-radio']"); + $this->click("xpath=//input[@class='crm-form-checkbox']"); $streetAddress = '100 Main Street'; $this->type('billing_street_address-5', $streetAddress); @@ -511,8 +511,8 @@ class WebTest_Contribute_AddPricesetTest extends CiviSeleniumTestCase { $this->openCiviPage("contribute/search", "reset=1", 'contribution_date_low'); $this->type('sort_name', "$firstName $lastName"); - $this->clickLink('_qf_Search_refresh', "xpath=//div[@id='contributionSearch']//table//tbody/tr[1]/td[11]/span/a[text()='View']"); - $this->clickLink("xpath=//div[@id='contributionSearch']//table//tbody/tr[1]/td[11]/span/a[text()='View']", '_qf_ContributionView_cancel-bottom'); + $this->clickLink('_qf_Search_refresh', "xpath=//div[@id='contributionSearch']//table//tbody/tr[1]/td[11]/span/a[text()='View']", FALSE); + $this->clickLink("xpath=//div[@id='contributionSearch']//table//tbody/tr[1]/td[11]/span/a[text()='View']", '_qf_ContributionView_cancel-bottom', FALSE); // View Contribution Record and test for expected values $expected = array( @@ -576,9 +576,9 @@ class WebTest_Contribute_AddPricesetTest extends CiviSeleniumTestCase { // select price set items $this->select('price_set_id', "label=$setTitle"); - $this->type("xpath=//input[@class='form-text four required']", "1"); - $this->click("xpath=//input[@class='form-radio']"); - $this->click("xpath=//input[@class='form-checkbox']"); + $this->type("xpath=//input[@class='four crm-form-text required']", "2"); + $this->click("xpath=//input[@class='crm-form-radio']"); + $this->click("xpath=//input[@class='crm-form-checkbox']"); // select payment instrument type = Check and enter chk number $this->select('payment_instrument_id', 'value=4'); $this->waitForElementPresent('check_number'); @@ -586,8 +586,9 @@ class WebTest_Contribute_AddPricesetTest extends CiviSeleniumTestCase { $this->type('trxn_id', 'P20901X1' . rand(100, 10000)); - $this->webtestFillAutocomplete("{$lastNameSoft}, {$firstNameSoft}", 'soft_credit_contact_1'); + $this->webtestFillAutocomplete("{$lastNameSoft}, {$firstNameSoft}", 'soft_credit_contact_id_1'); + $this->type('soft_credit_amount_1', "1"); //Additional Detail section $this->click('AdditionalDetail'); $this->waitForElementPresent('thankyou_date'); @@ -597,11 +598,11 @@ class WebTest_Contribute_AddPricesetTest extends CiviSeleniumTestCase { $this->webtestFillDate('thankyou_date'); // Clicking save. - $this->clickLink('_qf_Contribution_upload', "xpath=//div[@id='Contributions']//table//tbody/tr[1]/td[8]/span/a[text()='View']"); + $this->clickLink('_qf_Contribution_upload', "xpath=//div[@class='view-content']//table[@class='selector row-highlight']//tbody/tr[1]/td[8]/span/a[text()='View']", FALSE); $this->assertTrue($this->isTextPresent('The contribution record has been saved.'), "Status message didn't show up after saving!"); //click through to the Contribution view screen - $this->click("xpath=//div[@id='Contributions']//table/tbody/tr[1]/td[8]/span/a[text()='View']"); + $this->click("xpath=//table[@class='selector row-highlight']/tbody/tr[1]/td[8]/span/a[text()='View']"); $this->waitForElementPresent('_qf_ContributionView_cancel-bottom'); // View Contribution Record and test for expected values @@ -642,17 +643,17 @@ class WebTest_Contribute_AddPricesetTest extends CiviSeleniumTestCase { $this->type("css=input#sort_name_navigation", "$lastNameSoft, $firstNameSoft"); $this->typeKeys("css=input#sort_name_navigation", "$lastNameSoft, $firstNameSoft"); // wait for result list - $this->waitForElementPresent("css=div.ac_results-inner li"); + $this->waitForElementPresent("css=ul.ui-autocomplete li"); // visit contact summary page - $this->click("css=div.ac_results-inner li"); + $this->click("css=ul.ui-autocomplete li"); $this->waitForPageToLoad($this->getTimeoutMsec()); $this->click('css=li#tab_contribute a'); $this->waitForElementPresent('link=Record Contribution (Check, Cash, EFT ...)'); - $id = explode('id=', $this->getAttribute("xpath=id('rowid')/td[7]/a[text()='View']@href")); + $id = explode('id=', $this->getAttribute("xpath=//table[@class='selector row-highlight']/tbody//tr[@id='rowid']/td[8]/a[text()='View']@href")); $id = substr($id[1], 0, strpos($id[1], '&')); - $this->click("xpath=id('rowid')/td[7]/a"); + $this->click("xpath=//table[@class='selector row-highlight']/tbody//tr[@id='rowid']/td[8]/a"); $this->waitForElementPresent('_qf_ContributionView_cancel-bottom'); $this->webtestVerifyTabularData($expected); diff --git a/tests/phpunit/WebTest/Member/OnlineAutoRenewMembershipGCTest.php b/tests/phpunit/WebTest/Member/OnlineAutoRenewMembershipGCTest.php index eece41a7e3..84ae09746c 100644 --- a/tests/phpunit/WebTest/Member/OnlineAutoRenewMembershipGCTest.php +++ b/tests/phpunit/WebTest/Member/OnlineAutoRenewMembershipGCTest.php @@ -115,8 +115,6 @@ class WebTest_Member_OnlineAutoRenewMembershipGCTest extends CiviSeleniumTestCas $this->type("duration_interval", "1"); $this->select("duration_unit", "label=year"); - //wait for the auto-complete member_of_contact to populate - $this->waitForValue('member_of_contact', '::'); $this->click("_qf_MembershipType_upload-bottom"); $this->waitForPageToLoad($this->getTimeoutMsec()); @@ -129,8 +127,6 @@ class WebTest_Member_OnlineAutoRenewMembershipGCTest extends CiviSeleniumTestCas $this->type("duration_interval", "1"); $this->select("duration_unit", "label=year"); - //wait for the auto-complete member_of_contact to populate - $this->waitForValue('member_of_contact', '::'); $this->click("_qf_MembershipType_upload-bottom"); $this->waitForPageToLoad($this->getTimeoutMsec()); @@ -174,7 +170,7 @@ class WebTest_Member_OnlineAutoRenewMembershipGCTest extends CiviSeleniumTestCas ); //make sure we do have required permissions. - $permissions = array("edit-1-make-online-contributions"); + $permissions = array("edit-1-make-online-contributions", "edit-1-profile-listings-and-forms"); $this->changePermissions($permissions); // now logout and do membership test that way diff --git a/tests/phpunit/WebTest/Member/OnlineAutoRenewMembershipTest.php b/tests/phpunit/WebTest/Member/OnlineAutoRenewMembershipTest.php index a2be786925..74fa8c37b2 100644 --- a/tests/phpunit/WebTest/Member/OnlineAutoRenewMembershipTest.php +++ b/tests/phpunit/WebTest/Member/OnlineAutoRenewMembershipTest.php @@ -51,13 +51,13 @@ class WebTest_Member_OnlineAutoRenewMembershipTest extends CiviSeleniumTestCase $this->clickLink("_qf_Main_upload-bottom", "_qf_Confirm_next-bottom"); $text = 'I want this membership to be renewed automatically every 1 year(s).'; - $this->assertElementContainsText('css=div.display-block', $text, 'Missing text: ' . $text); + $this->assertElementContainsText("xpath=//div[@class='crm-group amount_display-group']/div[2]", $text, 'Missing text: ' . $text); $this->click("_qf_Confirm_next-bottom"); $this->waitForPageToLoad($this->getTimeoutMsec()); $text = 'This membership will be renewed automatically every 1 year(s).'; - $this->assertElementContainsText('css=div.display-block', $text, 'Missing text: ' . $text); + $this->assertElementContainsText("xpath=//div[@class='crm-group amount_display-group']/div[2]", $text, 'Missing text: ' . $text); } function testOnlineAutoRenewMembershipAuthenticated() { @@ -84,13 +84,13 @@ class WebTest_Member_OnlineAutoRenewMembershipTest extends CiviSeleniumTestCase $this->waitForElementPresent("_qf_Confirm_next-bottom"); $text = 'I want this membership to be renewed automatically every 1 year(s).'; - $this->assertElementContainsText('css=div.display-block', $text, 'Missing text: ' . $text); + $this->assertElementContainsText("xpath=//div[@class='crm-group amount_display-group']/div[2]", $text, 'Missing text: ' . $text); $this->click("_qf_Confirm_next-bottom"); $this->waitForPageToLoad($this->getTimeoutMsec()); $text = 'This membership will be renewed automatically every 1 year(s).'; - $this->assertElementContainsText('css=div.display-block', $text, 'Missing text: ' . $text); + $this->assertElementContainsText("xpath=//div[@class='crm-group amount_display-group']/div[2]", $text, 'Missing text: ' . $text); } function testOnlinePendingAutoRenewMembershipAnonymous() { @@ -112,13 +112,13 @@ class WebTest_Member_OnlineAutoRenewMembershipTest extends CiviSeleniumTestCase $this->waitForElementPresent("_qf_Confirm_next-bottom"); $text = 'I want this membership to be renewed automatically every 1 year(s).'; - $this->assertElementContainsText('css=div.display-block', $text, 'Missing text: ' . $text); + $this->assertElementContainsText("xpath=//div[@class='crm-group amount_display-group']/div[2]", $text, 'Missing text: ' . $text); $this->click("_qf_Confirm_next-bottom"); $this->waitForPageToLoad($this->getTimeoutMsec()); $text = 'This membership will be renewed automatically every 1 year(s).'; - $this->assertElementContainsText('css=div.display-block', $text, 'Missing text: ' . $text); + $this->assertElementContainsText("xpath=//div[@class='crm-group amount_display-group']/div[2]", $text, 'Missing text: ' . $text); } function _configureMembershipPage() { @@ -141,8 +141,6 @@ class WebTest_Member_OnlineAutoRenewMembershipTest extends CiviSeleniumTestCase $this->type("duration_interval", "1"); $this->select("duration_unit", "label=year"); - // wait for the auto-complete member_of_contact to populate - $this->waitForValue('member_of_contact', '::'); $this->click("_qf_MembershipType_upload-bottom"); $this->waitForPageToLoad($this->getTimeoutMsec()); @@ -154,8 +152,6 @@ class WebTest_Member_OnlineAutoRenewMembershipTest extends CiviSeleniumTestCase $this->type("duration_interval", "1"); $this->select("duration_unit", "label=year"); - //wait for the auto-complete member_of_contact to populate - $this->waitForValue('member_of_contact', '::'); $this->click("_qf_MembershipType_upload-bottom"); $this->waitForPageToLoad($this->getTimeoutMsec()); @@ -199,7 +195,7 @@ class WebTest_Member_OnlineAutoRenewMembershipTest extends CiviSeleniumTestCase ); //make sure we do have required permissions. - $permissions = array("edit-1-make-online-contributions"); + $permissions = array("edit-1-make-online-contributions", "edit-1-profile-listings-and-forms"); $this->changePermissions($permissions); // now logout and do membership test that way -- 2.25.1