From 5ddf48856bf4ff610ca745004f22a0a49a5c6cc3 Mon Sep 17 00:00:00 2001 From: jitendrapurohit Date: Thu, 3 Apr 2014 20:32:08 +0530 Subject: [PATCH] Web Test Fix --- .../phpunit/CiviTest/CiviSeleniumTestCase.php | 11 ++++-- .../Member/FixedMembershipTypeTest.php | 36 +++++++------------ .../Member/OfflineMembershipRenewTest.php | 34 +++++++++--------- .../WebTest/Profile/ProfileAddTest.php | 7 ++-- 4 files changed, 41 insertions(+), 47 deletions(-) diff --git a/tests/phpunit/CiviTest/CiviSeleniumTestCase.php b/tests/phpunit/CiviTest/CiviSeleniumTestCase.php index 3520416eca..927b557d32 100644 --- a/tests/phpunit/CiviTest/CiviSeleniumTestCase.php +++ b/tests/phpunit/CiviTest/CiviSeleniumTestCase.php @@ -437,9 +437,11 @@ class CiviSeleniumTestCase extends PHPUnit_Extensions_SeleniumTestCase { } foreach ($expected as $label => $value) { if ($xpathPrefix) { + $this->waitForElementPresent("xpath=//table{$tableLocator}/tbody/tr/td{$xpathPrefix}[text()='{$label}']/../following-sibling::td"); $this->verifyText("xpath=//table{$tableLocator}/tbody/tr/td{$xpathPrefix}[text()='{$label}']/../following-sibling::td", preg_quote($value), 'In line ' . __LINE__); } else { + $this->waitForElementPresent("xpath=//table{$tableLocator}/tbody/tr/td[text()='{$label}']/following-sibling::td"); $this->verifyText("xpath=//table{$tableLocator}/tbody/tr/td[text()='{$label}']/following-sibling::td", preg_quote($value), 'In line ' . __LINE__); } } @@ -650,7 +652,7 @@ class CiviSeleniumTestCase extends PHPUnit_Extensions_SeleniumTestCase { // Is new processor created? $this->assertTrue($this->isTextPresent($processorName), 'Processor name not found in selector after adding payment processor (webTestAddPaymentProcessor).'); - $paymentProcessorId = explode('&id=', $this->getAttribute("xpath=//table[@class='selector']//tbody//tr/td[text()='{$processorName}']/../td[7]/span/a[1]@href")); + $paymentProcessorId = explode('&id=', $this->getAttribute("xpath=//table[@class='selector row-highlight']//tbody//tr/td[text()='{$processorName}']/../td[7]/span/a[1]@href")); $paymentProcessorId = explode('&', $paymentProcessorId[1]); return $paymentProcessorId[0]; } @@ -868,7 +870,10 @@ class CiviSeleniumTestCase extends PHPUnit_Extensions_SeleniumTestCase { $this->click('honor_block_is_active'); $this->type('honor_block_title', "Honoree Section Title $hash"); $this->type('honor_block_text', "Honoree Introductory Message $hash"); - $this->select('crmasmSelect0', "label=Household"); + $this->click("//*[@id='s2id_soft_credit_types']/ul"); + $this->waitForElementPresent("//*[@id='select2-drop']/ul"); + $this->waitForElementPresent("//*[@class='select2-result-label']"); + $this->clickAt("//*[@class='select2-results']/li[1]"); } // is confirm enabled? it starts out enabled, so uncheck it if false @@ -1210,7 +1215,7 @@ class CiviSeleniumTestCase extends PHPUnit_Extensions_SeleniumTestCase { $this->type('duration_interval', $duration_interval); $this->select('duration_unit', "label={$duration_unit}"); - $this->select('period_type', "label={$period_type}"); + $this->select('period_type', "value={$period_type}"); $this->click('_qf_MembershipType_upload-bottom'); $this->waitForElementPresent('link=Add Membership Type'); diff --git a/tests/phpunit/WebTest/Member/FixedMembershipTypeTest.php b/tests/phpunit/WebTest/Member/FixedMembershipTypeTest.php index 660de2047d..68e3e92a94 100644 --- a/tests/phpunit/WebTest/Member/FixedMembershipTypeTest.php +++ b/tests/phpunit/WebTest/Member/FixedMembershipTypeTest.php @@ -55,17 +55,14 @@ class WebTest_Member_FixedMembershipTypeTest extends CiviSeleniumTestCase { $this->waitForElementPresent('_qf_MembershipType_cancel-bottom'); $this->type('name', "Membership Type $title"); - $this->type('member_of_contact', $title); - $this->click('member_of_contact'); - $this->waitForElementPresent("css=div.ac_results-inner li"); - $this->click("css=div.ac_results-inner li"); + $this->select2('member_of_contact_id',$title); $this->type('minimum_fee', '100'); $this->select( 'financial_type_id', 'value=2' ); $this->type('duration_interval', 1); $this->select('duration_unit', "label=year"); - $this->select('period_type', "label=fixed"); + $this->select('period_type', "value=fixed"); $this->waitForElementPresent('fixed_period_rollover_day[d]'); // fixed period start set to April 1 @@ -77,7 +74,7 @@ class WebTest_Member_FixedMembershipTypeTest extends CiviSeleniumTestCase { $this->click('_qf_MembershipType_upload-bottom'); $this->waitForElementPresent('link=Add Membership Type'); - $this->assertTrue($this->isTextPresent("The membership type 'Membership Type $title' has been saved.")); + $this->waitForText('crm-notification-container',"The membership type 'Membership Type $title' has been saved."); $this->openCiviPage("contact/add", "reset=1&ct=Individual"); @@ -213,10 +210,7 @@ SELECT end_event_adjust_interval $this->waitForElementPresent('_qf_MembershipType_cancel-bottom'); $this->type('name', "Membership Type $title"); - $this->type('member_of_contact', $title); - $this->click('member_of_contact'); - $this->waitForElementPresent("css=div.ac_results-inner li"); - $this->click("css=div.ac_results-inner li"); + $this->select2('member_of_contact_id',$title); $this->type('minimum_fee', '100'); $this->select( 'financial_type_id', 'value=2' ); @@ -224,7 +218,7 @@ SELECT end_event_adjust_interval $this->type('duration_interval', 2); $this->select('duration_unit', "label=year"); - $this->select('period_type', "label=fixed"); + $this->select('period_type', "value=fixed"); $this->waitForElementPresent('fixed_period_rollover_day[d]'); $this->select('fixed_period_start_day[M]', 'value=9'); @@ -235,7 +229,7 @@ SELECT end_event_adjust_interval $this->click('_qf_MembershipType_upload-bottom'); $this->waitForElementPresent('link=Add Membership Type'); - $this->assertTrue($this->isTextPresent("The membership type 'Membership Type $title' has been saved.")); + $this->waitForText('crm-notification-container',"The membership type 'Membership Type $title' has been saved."); $this->openCiviPage("contact/add", "reset=1&ct=Individual"); @@ -373,17 +367,14 @@ SELECT end_event_adjust_interval $this->waitForElementPresent('_qf_MembershipType_cancel-bottom'); $this->type('name', "Membership Type $title"); - $this->type('member_of_contact', $title); - $this->click('member_of_contact'); - $this->waitForElementPresent("css=div.ac_results-inner li"); - $this->click("css=div.ac_results-inner li"); + $this->select2('member_of_contact_id',$title); $this->type('minimum_fee', '100'); $this->select( 'financial_type_id', 'value=2' ); $this->type('duration_interval', 1); $this->select('duration_unit', "label=year"); - $this->select('period_type', "label=fixed"); + $this->select('period_type', "value=fixed"); $this->waitForElementPresent('fixed_period_rollover_day[d]'); $this->select('fixed_period_rollover_day[M]', 'value=10'); @@ -393,8 +384,8 @@ SELECT end_event_adjust_interval $this->click('_qf_MembershipType_upload-bottom'); $this->waitForElementPresent('link=Add Membership Type'); - $this->assertTrue($this->isTextPresent("The membership type 'Membership Type $title' has been saved.")); + $this->waitForText('crm-notification-container',"The membership type 'Membership Type $title' has been saved."); $this->openCiviPage("contact/add", "reset=1&ct=Individual"); $firstName = "John_" . substr(sha1(rand()), 0, 7); @@ -525,17 +516,14 @@ SELECT end_event_adjust_interval $this->waitForElementPresent('_qf_MembershipType_cancel-bottom'); $this->type('name', "Membership Type $title"); - $this->type('member_of_contact', $title); - $this->click('member_of_contact'); - $this->waitForElementPresent("css=div.ac_results-inner li"); - $this->click("css=div.ac_results-inner li"); + $this->select2('member_of_contact_id',$title); $this->type('minimum_fee', '100'); $this->select( 'financial_type_id', 'value=2' ); $this->type('duration_interval', 1); $this->select('duration_unit', "label=year"); - $this->select('period_type', "label=fixed"); + $this->select('period_type', "value=fixed"); $this->waitForElementPresent('fixed_period_rollover_day[d]'); $this->select('fixed_period_start_day[M]', 'value=1'); @@ -546,7 +534,7 @@ SELECT end_event_adjust_interval $this->click('_qf_MembershipType_upload-bottom'); $this->waitForElementPresent('link=Add Membership Type'); - $this->assertTrue($this->isTextPresent("The membership type 'Membership Type $title' has been saved.")); + $this->waitForText('crm-notification-container',"The membership type 'Membership Type $title' has been saved."); $this->openCiviPage("contact/add", "reset=1&ct=Individual"); diff --git a/tests/phpunit/WebTest/Member/OfflineMembershipRenewTest.php b/tests/phpunit/WebTest/Member/OfflineMembershipRenewTest.php index bc0888d485..0129a83843 100644 --- a/tests/phpunit/WebTest/Member/OfflineMembershipRenewTest.php +++ b/tests/phpunit/WebTest/Member/OfflineMembershipRenewTest.php @@ -80,10 +80,10 @@ class WebTest_Member_OfflineMembershipRenewTest extends CiviSeleniumTestCase { // Is status message correct? $this->waitForText('crm-notification-container', "{$membershipTypes['membership_type']} membership for $firstName Memberson has been added."); - $this->waitForElementPresent("xpath=//div[@id='Memberships']//table/tbody/tr/td[9]/span[2][text()='more']/ul/li/a[text()='Renew']"); + $this->waitForElementPresent("xpath=//div[@id='memberships']//table/tbody/tr/td[9]/span[2][text()='more']/ul/li/a[text()='Renew']"); // click through to the Membership Renewal Link - $this->click("xpath=//div[@id='Memberships']//table/tbody/tr/td[9]/span[2][text()='more']/ul/li/a[text()='Renew']"); + $this->click("xpath=//div[@id='memberships']//table/tbody/tr/td[9]/span[2][text()='more']/ul/li/a[text()='Renew']"); $this->waitForElementPresent('_qf_MembershipRenewal_cancel-bottom'); @@ -95,10 +95,10 @@ class WebTest_Member_OfflineMembershipRenewTest extends CiviSeleniumTestCase { // page was loaded $this->waitForTextPresent($sourceText); - $this->waitForElementPresent("xpath=//div[@id='Memberships']//table/tbody/tr/td[9]/span/a[text()='View']"); + $this->waitForElementPresent("xpath=//div[@id='memberships']//table/tbody/tr/td[9]/span/a[text()='View']"); // click through to the membership view screen - $this->click("xpath=//div[@id='Memberships']//table/tbody/tr/td[9]/span/a[text()='View']"); + $this->click("xpath=//div[@id='memberships']//table/tbody/tr/td[9]/span/a[text()='View']"); $this->waitForElementPresent('_qf_MembershipView_cancel-bottom'); @@ -185,10 +185,10 @@ class WebTest_Member_OfflineMembershipRenewTest extends CiviSeleniumTestCase { // Is status message correct? $this->waitForText('crm-notification-container', "{$membershipTypes['membership_type']} membership for $firstName Memberson has been added."); - $this->waitForElementPresent("xpath=//div[@id='Memberships']//table/tbody/tr/td[9]/span[2][text()='more']/ul/li/a[text()='Renew']"); + $this->waitForElementPresent("xpath=//div[@id='memberships']//table/tbody/tr/td[9]/span[2][text()='more']/ul/li/a[text()='Renew']"); // click through to the Membership Renewal Link - $this->click("xpath=//div[@id='Memberships']//table/tbody/tr/td[9]/span[2][text()='more']/ul/li/a[text()='Renew']"); + $this->click("xpath=//div[@id='memberships']//table/tbody/tr/td[9]/span[2][text()='more']/ul/li/a[text()='Renew']"); $this->waitForElementPresent('_qf_MembershipRenewal_cancel-bottom'); @@ -200,10 +200,10 @@ class WebTest_Member_OfflineMembershipRenewTest extends CiviSeleniumTestCase { // page was loaded $this->waitForTextPresent($sourceText); - $this->waitForElementPresent("xpath=//div[@id='Memberships']//table/tbody/tr/td[9]/span/a[text()='View']"); + $this->waitForElementPresent("xpath=//div[@id='memberships']//table/tbody/tr/td[9]/span/a[text()='View']"); // click through to the membership view screen - $this->click("xpath=//div[@id='Memberships']//table/tbody/tr/td[9]/span/a[text()='View']"); + $this->click("xpath=//div[@id='memberships']//table/tbody/tr/td[9]/span/a[text()='View']"); $this->waitForElementPresent('_qf_MembershipView_cancel-bottom'); @@ -273,10 +273,10 @@ class WebTest_Member_OfflineMembershipRenewTest extends CiviSeleniumTestCase { // Is status message correct? $this->waitForText('crm-notification-container', "{$membershipTypes['membership_type']} membership for $firstName Memberson has been added."); - $this->waitForElementPresent("xpath=//div[@id='Memberships']//table/tbody/tr/td[7]/span[2][text()='more']/ul/li/a[text()='Renew']"); + $this->waitForElementPresent("xpath=//div[@id='inactive-memberships']//table/tbody/tr/td[7]/span[2][text()='more']/ul/li/a[text()='Renew']"); // click through to the Membership Renewal Link - $this->click("xpath=//div[@id='Memberships']//table/tbody/tr/td[7]/span[2][text()='more']/ul/li/a[text()='Renew']"); + $this->click("xpath=//div[@id='inactive-memberships']//table/tbody/tr/td[7]/span[2][text()='more']/ul/li/a[text()='Renew']"); $this->waitForElementPresent('_qf_MembershipRenewal_cancel-bottom'); @@ -295,15 +295,14 @@ class WebTest_Member_OfflineMembershipRenewTest extends CiviSeleniumTestCase { // save the renewed membership $this->click('_qf_MembershipRenewal_upload-bottom'); - $this->waitForPageToLoad($this->getTimeoutMsec()); // page was loaded $this->waitForTextPresent($sourceText); - $this->waitForElementPresent("xpath=//div[@id='Memberships']//div[@id='memberships']//table/tbody/tr/td[9]/span/a[text()='View']"); + $this->waitForElementPresent("xpath=//div[@id='memberships']//table/tbody/tr/td[9]/span/a[text()='View']"); // click through to the membership view screen - $this->click("xpath=//div[@id='Memberships']//div[@id='memberships']//table/tbody/tr/td[9]/span/a[text()='View']"); + $this->click("xpath=//div[@id='memberships']//table/tbody/tr/td[9]/span/a[text()='View']"); $this->waitForElementPresent('_qf_MembershipView_cancel-bottom'); @@ -384,10 +383,10 @@ class WebTest_Member_OfflineMembershipRenewTest extends CiviSeleniumTestCase { $this->waitForText('crm-notification-container', "{$membershipTypes['membership_type']} membership for $firstName Memberson has been added."); $this->waitForText('crm-notification-container', "A membership confirmation and receipt has been sent to {$firstName}@memberson.com."); - $this->waitForElementPresent("xpath=//div[@id='Memberships']//table/tbody/tr/td[9]/span[2][text()='more']/ul/li/a[text()='Renew']"); + $this->waitForElementPresent("xpath=//div[@id='memberships']//table/tbody/tr/td[9]/span[2][text()='more']/ul/li/a[text()='Renew']"); // click through to the Membership Renewal Link - $this->click("xpath=//div[@id='Memberships']//table/tbody/tr/td[9]/span[2][text()='more']/ul/li/a[text()='Renew']"); + $this->click("xpath=//div[@id='memberships']//table/tbody/tr/td[9]/span[2][text()='more']/ul/li/a[text()='Renew']"); $this->waitForElementPresent('_qf_MembershipRenewal_cancel-bottom'); // Record contribution and set number of terms to 2 @@ -414,15 +413,14 @@ class WebTest_Member_OfflineMembershipRenewTest extends CiviSeleniumTestCase { // save the renewed membership $this->click('_qf_MembershipRenewal_upload-bottom'); - $this->waitForPageToLoad($this->getTimeoutMsec()); // page was loaded $this->waitForTextPresent($sourceText); - $this->waitForElementPresent("xpath=//div[@id='Memberships']//table/tbody/tr/td[9]/span/a[text()='View']"); + $this->waitForElementPresent("xpath=//div[@id='memberships']//table/tbody/tr/td[9]/span/a[text()='View']"); // click through to the membership view screen - $this->click("xpath=//div[@id='Memberships']//table/tbody/tr/td[9]/span/a[text()='View']"); + $this->click("xpath=//div[@id='memberships']//table/tbody/tr/td[9]/span/a[text()='View']"); $this->waitForElementPresent('_qf_MembershipView_cancel-bottom'); diff --git a/tests/phpunit/WebTest/Profile/ProfileAddTest.php b/tests/phpunit/WebTest/Profile/ProfileAddTest.php index abc1bf1888..984a58ead1 100644 --- a/tests/phpunit/WebTest/Profile/ProfileAddTest.php +++ b/tests/phpunit/WebTest/Profile/ProfileAddTest.php @@ -120,6 +120,8 @@ class WebTest_Profile_ProfileAddTest extends CiviSeleniumTestCase { function testProfileAddContactstoGroup() { $this->webtestLogin(); + $permissions = array("edit-1-profile-listings-and-forms"); + $this->changePermissions($permissions); // take group name and create group $groupName = 'group_' . substr(sha1(rand()), 0, 7); $this->WebtestAddGroup($groupName); @@ -135,6 +137,7 @@ class WebTest_Profile_ProfileAddTest extends CiviSeleniumTestCase { $profileTitle = 'profile_' . substr(sha1(rand()), 0, 7); $this->type('title', $profileTitle); + $this->click('uf_group_type_Profile'); //Profile Advance Settings $this->click("//form[@id='Group']/div[2]/div[2]/div[1]"); @@ -188,8 +191,8 @@ class WebTest_Profile_ProfileAddTest extends CiviSeleniumTestCase { $this->type('title', $groupName); $this->click('_qf_Search_refresh'); $this->waitForVisible('crm-group-selector_processing'); - $this->waitForElementPresent("xpath=//table[@id='crm-group-selector']/tbody/tr/td[contains(text(), '$groupName')]/following-sibling::td[@class='crm-group-group_links']/span/a"); - $this->clickLink("xpath=//table[@id='crm-group-selector']/tbody/tr/td[1][text()= '$groupName']/following-sibling::td[@class='crm-group-group_links']/span/a"); + $this->waitForElementPresent("xpath=//table[@id='crm-group-selector']/tbody/tr/td[contains(., '$groupName')]/following-sibling::td[@class='crm-group-group_links']/span/a"); + $this->clickLink("xpath=//table[@id='crm-group-selector']/tbody/tr/td[1][contains(., '$groupName')]/following-sibling::td[@class='crm-group-group_links']/span/a"); $contactEmails = array( 1 => "$lastName1, $firstName1", 2 => "$lastName2, $firstName2" -- 2.25.1