From cebea087d183633a5529101c4182f1b34a0efae9 Mon Sep 17 00:00:00 2001 From: jitendrapurohit Date: Mon, 22 Sep 2014 18:46:56 +0530 Subject: [PATCH] Webtest Fixes --- .../WebTest/Import/ContactCustomDataTest.php | 3 +- .../Member/InheritedMembershipTest.php | 111 ++++++++---------- .../WebTest/Profile/BatchUpdateTest.php | 5 - 3 files changed, 48 insertions(+), 71 deletions(-) diff --git a/tests/phpunit/WebTest/Import/ContactCustomDataTest.php b/tests/phpunit/WebTest/Import/ContactCustomDataTest.php index ec4ccdc2e4..7f9c2e7e0d 100644 --- a/tests/phpunit/WebTest/Import/ContactCustomDataTest.php +++ b/tests/phpunit/WebTest/Import/ContactCustomDataTest.php @@ -63,7 +63,6 @@ class WebTest_Import_ContactCustomDataTest extends ImportCiviSeleniumTestCase { // Add Contact $firstName2 = 'An_' . substr(sha1(rand()), 0, 7); $this->webtestAddContact($firstName2, "Summerson"); - $this->waitForPageToLoad($this->getTimeoutMsec()); // Edit and expand all tabs $this->click('link=Edit'); @@ -183,7 +182,7 @@ class WebTest_Import_ContactCustomDataTest extends ImportCiviSeleniumTestCase { // clicking save $this->click('_qf_Field_done-bottom'); - $this->waitForElementPresent('newCustomField'); + $this->waitForElementPresent("xpath=//div[@id='field_page']//table/tbody//tr/td"); $this->waitForText('crm-notification-container', "Custom field '{$customField}' has been saved."); $customFieldId = explode('&id=', $this->getAttribute("xpath=//div[@id='field_page']//table/tbody//tr/td/span[text()='$customField']/../../td[8]/span/a@href")); diff --git a/tests/phpunit/WebTest/Member/InheritedMembershipTest.php b/tests/phpunit/WebTest/Member/InheritedMembershipTest.php index 7f615c29c1..537e7ed64a 100644 --- a/tests/phpunit/WebTest/Member/InheritedMembershipTest.php +++ b/tests/phpunit/WebTest/Member/InheritedMembershipTest.php @@ -153,11 +153,11 @@ class WebTest_Member_InheritedMembershipTest extends CiviSeleniumTestCase { //save the relationship $this->click('_qf_Relationship_upload-bottom'); - $this->waitForElementPresent('crm-contact-relationship-selector-current_wrapper'); + $this->waitForElementPresent("xpath=//div[@class='crm-contact-relationship-current']"); //check the status message $this->waitForText('crm-notification-container', 'Relationship created.'); - $this->waitForElementPresent("xpath=//div[@id='crm-contact-relationship-selector-current_wrapper']//table/tbody//tr/td[9]/span/a[text()='View']"); + $this->waitForElementPresent("xpath=//div[@class='crm-contact-relationship-current']/div/table/tbody//tr/td[9]/span/a[text()='View']"); // click through to the membership view screen $this->click('css=li#tab_member a'); @@ -185,12 +185,12 @@ class WebTest_Member_InheritedMembershipTest extends CiviSeleniumTestCase { $this->waitForElementPresent('css=div.action-link'); $this->click("//li[@id='tab_rel']/a"); - $this->waitForElementPresent("xpath=//div[@id='crm-contact-relationship-selector-current_wrapper']//table/tbody//tr/td[9]/span/a[text()='Edit']"); - $id = explode('&id=', $this->getAttribute("xpath=//div[@id='crm-contact-relationship-selector-current_wrapper']//table/tbody//tr/td[9]/span/a@href")); + $this->waitForElementPresent("xpath=//div[@class='crm-contact-relationship-current']/div/table/tbody//tr/td[9]/span/a[text()='Edit']"); + $id = explode('&id=', $this->getAttribute("xpath=//div[@class='crm-contact-relationship-current']/div/table/tbody//tr/td[9]/span/a@href")); $id = explode('&', $id[0]); $id = explode('=', $id[2]); $id = $id[1]; - $this->click("xpath=//div[@id='crm-contact-relationship-selector-current_wrapper']//table/tbody//tr/td[9]/span/a[text()='Edit']"); + $this->click("xpath=//div[@class='crm-contact-relationship-current']/div/table/tbody//tr/td[9]/span/a[text()='Edit']"); $this->waitForElementPresent('is_active'); //disable relationship @@ -198,7 +198,7 @@ class WebTest_Member_InheritedMembershipTest extends CiviSeleniumTestCase { $this->click('is_active'); } $this->click('_qf_Relationship_upload'); - $this->waitForElementPresent('crm-contact-relationship-selector-past_wrapper'); + $this->waitForElementPresent("xpath=//div[@class='crm-contact-relationship-current']"); //check the status message $this->waitForText('crm-notification-container', 'Relationship record has been updated'); @@ -214,14 +214,14 @@ class WebTest_Member_InheritedMembershipTest extends CiviSeleniumTestCase { $this->waitForElementPresent('css=div.action-link'); $this->click("//li[@id='tab_rel']/a"); - $this->waitForElementPresent("xpath=//div[@id='crm-contact-relationship-selector-past_wrapper']//table/tbody//tr/td[9]/span/a[text()='Edit']"); - $this->click("xpath=//div[@id='crm-contact-relationship-selector-past_wrapper']//table/tbody//tr/td[9]/span/a[text()='Edit']"); + $this->waitForElementPresent("xpath=//div[@class='crm-contact-relationship-past']/div/table/tbody//tr/td[9]/span/a[text()='Edit']"); + $this->click("xpath=//div[@class='crm-contact-relationship-past']/div/table/tbody//tr/td[9]/span/a[text()='Edit']"); $this->waitForElementPresent('is_active'); if (!$this->isChecked('is_active')) { $this->click('is_active'); } $this->click('_qf_Relationship_upload'); - $this->waitForElementPresent('crm-contact-relationship-selector-current_wrapper'); + $this->waitForElementPresent("xpath=//div[@class='crm-contact-relationship-current']"); //check the status message $this->waitForText('crm-notification-container', 'Relationship record has been updated.'); @@ -233,10 +233,10 @@ class WebTest_Member_InheritedMembershipTest extends CiviSeleniumTestCase { //disable relationship $this->click('css=li#tab_rel a'); $this->waitForElementPresent('css=div.action-link'); - $this->waitForElementPresent("xpath=//div[@id='crm-contact-relationship-selector-current_wrapper']//table/tbody//tr/td[9]/span[2][text()='more']/ul/li[1]/a[text()='Disable']"); - $this->click("xpath=//div[@id='crm-contact-relationship-selector-current_wrapper']//table/tbody//tr/td[9]/span[2][text()='more']/ul/li[1]/a[text()='Disable']"); - $this->waitForText("xpath=//div[@class='crm-confirm-dialog ui-dialog-content ui-widget-content modal-dialog']", 'Are you sure you want to disable this record?'); - $this->click("xpath=//div[@class='ui-dialog-buttonset']//button//span[text()='Disable']"); + $this->waitForElementPresent("xpath=//div[@class='crm-contact-relationship-current']/div/table/tbody//tr/td[9]/span[2][text()='more']/ul/li[1]/a[text()='Disable']"); + $this->click("xpath=//div[@class='crm-contact-relationship-current']/div/table/tbody//tr/td[9]/span[2][text()='more']/ul/li[1]/a[text()='Disable']"); + $this->waitForText("xpath=//div[@class='crm-confirm-dialog ui-dialog-content ui-widget-content modal-dialog']", 'Are you sure you want to disable this relationship?'); + $this->click("xpath=//div[@class='ui-dialog-buttonset']//button//span[text()='Yes']"); // 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 @@ -250,8 +250,8 @@ class WebTest_Member_InheritedMembershipTest extends CiviSeleniumTestCase { $this->click('css=li#tab_rel a'); $this->waitForElementPresent('css=div.action-link'); - $this->waitForElementPresent("xpath=//div[@id='crm-contact-relationship-selector-past_wrapper']//table/tbody//tr/td[9]/span[2][text()='more']/ul/li[1]/a[text()='Enable']"); - $this->click("xpath=//div[@id='crm-contact-relationship-selector-past_wrapper']//table/tbody//tr/td[9]/span[2][text()='more']/ul/li[1]/a[text()='Enable']"); + $this->waitForElementPresent("xpath=//div[@class='crm-contact-relationship-current']/div/table/tbody//tr/td[9]/span[2][text()='more']/ul/li[1]/a[text()='Enable']"); + $this->click("xpath=//div[@class='crm-contact-relationship-current']/div/table/tbody//tr/td[9]/span[2][text()='more']/ul/li[1]/a[text()='Enable']"); //verify membership $this->click('css=li#tab_member a'); @@ -354,28 +354,26 @@ class WebTest_Member_InheritedMembershipTest extends CiviSeleniumTestCase { // check number of membership for contact $this->assertEquals(1, $this->getText("xpath=//li[@id='tab_member']/a/em")); - $this->clickLink("xpath=//div[@id='memberships']//table//tbody/tr[1]/td[9]/span/a[text()='View']"); - $expectedMembershipId = $this->urlArg('id'); - $this->clickLink("_qf_MembershipView_cancel-bottom"); + $url = $this->parseURL($this->getAttribute("xpath=//div[@id='memberships']//table//tbody/tr[1]/td[9]/span/a[text()='View']@href")); + $expectedMembershipId = $url['queryString']['id']; // click through to the activity view screen $this->click('css=li#tab_activity a'); - $this->waitForElementPresent("xpath=//table[@id='contact-activity-selector-activity']/tbody//tr/td[8]/span/a[text()='View']"); + $this->waitForElementPresent("xpath=//table[@class='contact-activity-selector-activity dataTable no-footer']/tbody//tr/td[8]/span/a[text()='View']"); // check number of activity for contact $this->assertEquals(1, $this->getText("xpath=//li[@id='tab_activity']/a/em")); - $this->clickLink("xpath=//table[@id='contact-activity-selector-activity']/tbody//tr/td[8]/span/a[text()='View']"); - $expectedMembershipActivityId = $this->urlArg('id'); - $this->clickLink("_qf_MembershipView_cancel-bottom"); + $url = $this->parseURL($this->getAttribute("xpath=//table[@class='contact-activity-selector-activity dataTable no-footer']/tbody//tr/td[8]/span/a[text()='View']@href")); + $expectedMembershipActivityId = $url['queryString']['id']; // verify membership id with membership activity id $this->assertEquals($expectedMembershipId, $expectedMembershipActivityId); // click through to the relationship view screen $this->click('css=li#tab_rel a'); - $this->waitForElementPresent("xpath=//div[@id='option11_wrapper']/table/tbody/tr/td[2]/a"); - $this->assertTrue($this->isElementPresent("xpath=//div[@id='option11_wrapper']/table/tbody/tr/td[2]/a[text()='Organization $org1']")); + $this->waitForElementPresent("xpath=//div[@class='crm-contact-relationship-current']/div/table/tbody/tr/td[2]/a"); + $this->assertTrue($this->isElementPresent("xpath=//div[@class='crm-contact-relationship-current']/div/table/tbody/tr/td[2]/a[text()='Organization $org1']")); $this->assertEquals(1, $this->getText("xpath=//li[@id='tab_rel']/a/em")); // Edit Contact but do not change any field @@ -388,17 +386,16 @@ class WebTest_Member_InheritedMembershipTest extends CiviSeleniumTestCase { $this->click('css=li#tab_member a'); $this->waitForElementPresent("xpath=//div[@id='memberships']//table//tbody/tr[1]/td[9]/span/a[text()='View']"); $this->assertEquals(1, $this->getText("xpath=//li[@id='tab_member']/a/em")); - $this->clickLink("xpath=//div[@id='memberships']//table//tbody/tr[1]/td[9]/span/a[text()='View']"); - $actualMembershipId1 = $this->urlArg('id'); - $this->clickLink("_qf_MembershipView_cancel-bottom"); + + $url = $this->parseURL($this->getAttribute("xpath=//div[@id='memberships']//table//tbody/tr[1]/td[9]/span/a[text()='View']@href")); + $actualMembershipId1 = $url['queryString']['id']; // click through to the activity view screen after edit $this->click('css=li#tab_activity a'); - $this->waitForElementPresent("xpath=//table[@id='contact-activity-selector-activity']/tbody//tr/td[8]/span/a[text()='View']"); + $this->waitForElementPresent("xpath=//table[@class='contact-activity-selector-activity dataTable no-footer']/tbody//tr/td[8]/span/a[text()='View']"); $this->assertEquals(1, $this->getText("xpath=//li[@id='tab_activity']/a/em")); - $this->clickLink("xpath=//table[@id='contact-activity-selector-activity']/tbody//tr/td[8]/span/a[text()='View']"); - $actualMembershipActivityId1 = $this->urlArg('id'); - $this->clickLink("_qf_MembershipView_cancel-bottom"); + $url = $this->parseURL($this->getAttribute("xpath=//table[@class='contact-activity-selector-activity dataTable no-footer']/tbody//tr/td[8]/span/a[text()='View']@href")); + $actualMembershipActivityId1 = $url['queryString']['id']; // verify membership id and membership activity id with previous one $this->assertEquals($expectedMembershipId, $actualMembershipId1); @@ -406,8 +403,8 @@ class WebTest_Member_InheritedMembershipTest extends CiviSeleniumTestCase { // click through to the relationship view screen after edit $this->click('css=li#tab_rel a'); - $this->waitForElementPresent("xpath=//div[@id='option11_wrapper']/table/tbody/tr/td[2]/a"); - $this->assertTrue($this->isElementPresent("xpath=//div[@id='option11_wrapper']/table/tbody/tr/td[2]/a[text()='Organization $org1']")); + $this->waitForElementPresent("xpath=//div[@class='crm-contact-relationship-current']/div/table/tbody/tr/td[2]/a"); + $this->assertTrue($this->isElementPresent("xpath=//div[@class='crm-contact-relationship-current']/div/table/tbody/tr/td[2]/a[text()='Organization $org1']")); $this->assertEquals(1, $this->getText("xpath=//li[@id='tab_rel']/a/em")); // change the current employer of the contact @@ -419,17 +416,14 @@ class WebTest_Member_InheritedMembershipTest extends CiviSeleniumTestCase { $this->type('name', "Membership Type Another $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', 'label=Member Dues'); $this->type('duration_interval', 1); $this->select('duration_unit', 'label=year'); - $this->select('period_type', 'label=rolling'); + $this->select('period_type', 'value=rolling'); $this->removeSelection('relationship_type_id', 'label=- select -'); $this->addSelection('relationship_type_id', 'label=Employer of'); @@ -459,7 +453,7 @@ class WebTest_Member_InheritedMembershipTest extends CiviSeleniumTestCase { $sourceText = 'Membership ContactAddTest with Rolling Membership Type'; $this->type('source', $sourceText); - $this->clickLink('_qf_Membership_upload'); + $this->clickLink('_qf_Membership_upload', 'link=Add Membership', FALSE); $this->waitForTextPresent($sourceText); // Is status message correct? @@ -469,29 +463,22 @@ class WebTest_Member_InheritedMembershipTest extends CiviSeleniumTestCase { $this->openCiviPage("contact/add", "reset=1&action=update&cid=$cid", "_qf_Contact_cancel-bottom"); // change Current Employer - $this->type('current_employer', ''); - $this->click('current_employer'); - $this->type('current_employer', $org2); - $this->click('current_employer'); - $this->waitForElementPresent("css=div.ac_results-inner li"); - $this->click("css=div.ac_results-inner li"); + $this->select2('employer_id', $org2); $this->clickLink("_qf_Contact_upload_view-bottom"); // click through to the membership view screen $this->click('css=li#tab_member a'); $this->waitForElementPresent("xpath=//div[@id='memberships']//table//tbody/tr[1]/td[9]/span/a[text()='View']"); $this->assertEquals(1, $this->getText("xpath=//li[@id='tab_member']/a/em")); - $this->clickLink("xpath=//div[@id='memberships']//table//tbody/tr[1]/td[9]/span/a[text()='View']"); - $actualMembershipId2 = $this->urlArg('id'); - $this->clickLink("_qf_MembershipView_cancel-bottom"); + $url = $this->parseURL($this->getAttribute("xpath=//div[@id='memberships']//table//tbody/tr[1]/td[9]/span/a[text()='View']@href")); + $actualMembershipId2 = $url['queryString']['id']; // click through to the activity view screen $this->click('css=li#tab_activity a'); - $this->waitForElementPresent("xpath=//table[@id='contact-activity-selector-activity']/tbody//tr/td[8]/span/a[text()='View']"); + $this->waitForElementPresent("xpath=//table[@class='contact-activity-selector-activity dataTable no-footer']/tbody//tr/td[8]/span/a[text()='View']"); $this->assertEquals(1, $this->getText("xpath=//li[@id='tab_activity']/a/em")); - $this->clickLink("xpath=//table[@id='contact-activity-selector-activity']/tbody//tr/td[8]/span/a[text()='View']"); - $actualMembershipActivityId2 = $this->urlArg('id'); - $this->clickLink("_qf_MembershipView_cancel-bottom"); + $url = $this->parseURL($this->getAttribute("xpath=//table[@class='contact-activity-selector-activity dataTable no-footer']/tbody//tr/td[8]/span/a[text()='View']@href")); + $actualMembershipActivityId2 = $url['queryString']['id']; // verify membership id and membership activity id with previous one $this->assertNotEquals($expectedMembershipId, $actualMembershipId2); @@ -499,8 +486,8 @@ class WebTest_Member_InheritedMembershipTest extends CiviSeleniumTestCase { // click through to the relationship view screen $this->click('css=li#tab_rel a'); - $this->waitForElementPresent("xpath=//div[@id='option11_wrapper']/table/tbody/tr/td[2]/a"); - $this->assertTrue($this->isElementPresent("xpath=//div[@id='option11_wrapper']/table/tbody/tr/td[2]/a[text()='Organization $org2']")); + $this->waitForElementPresent("xpath=//div[@class='crm-contact-relationship-current']/div/table/tbody/tr/td[2]/a"); + $this->assertTrue($this->isElementPresent("xpath=//div[@class='crm-contact-relationship-current']/div/table/tbody/tr/td[2]/a[text()='Organization $org2']")); $this->assertEquals(1, $this->getText("xpath=//li[@id='tab_rel']/a/em")); // creating another Orgnization with no membership @@ -514,28 +501,24 @@ class WebTest_Member_InheritedMembershipTest extends CiviSeleniumTestCase { $this->openCiviPage("contact/add", "reset=1&action=update&cid=$cid", "_qf_Contact_cancel-bottom"); // change Current Employer - $this->type('current_employer', ''); - $this->click('current_employer'); - $this->type('current_employer', $org3); - $this->click('current_employer'); - $this->waitForElementPresent("css=div.ac_results-inner li"); - $this->click("css=div.ac_results-inner li"); + $this->select2('employer_id', $org3); $this->clickLink("_qf_Contact_upload_view-bottom"); // click through to the membership view screen $this->click('css=li#tab_member a'); - $this->waitForText("xpath=//div[@id='Memberships']/div/div/div[3]", "No memberships have been recorded for this contact."); + + $this->waitForText("xpath=//div[@class='messages status no-popup']", "No memberships have been recorded for this contact."); $this->assertEquals(0, $this->getText("xpath=//li[@id='tab_member']/a/em")); // click through to the activity view screen $this->click('css=li#tab_activity a'); - $this->waitForText("xpath=//table[@id='contact-activity-selector-activity']/tbody/tr/td", "No matches found."); + $this->waitForText("xpath=//table[@class='contact-activity-selector-activity dataTable no-footer']/tbody/tr/td", "No matches found."); $this->assertEquals(0, $this->getText("xpath=//li[@id='tab_activity']/a/em")); // click through to the relationship view screen $this->click('css=li#tab_rel a'); - $this->waitForElementPresent("xpath=//div[@id='option11_wrapper']/table/tbody/tr/td[2]/a"); - $this->assertTrue($this->isElementPresent("xpath=//div[@id='option11_wrapper']/table/tbody/tr/td[2]/a[text()='Organization $org3']")); + $this->waitForElementPresent("xpath=//div[@class='crm-contact-relationship-current']/div/table/tbody/tr/td[2]/a"); + $this->assertTrue($this->isElementPresent("xpath=//div[@class='crm-contact-relationship-current']/div/table/tbody/tr/td[2]/a[text()='Organization $org3']")); $this->assertEquals(1, $this->getText("xpath=//li[@id='tab_rel']/a/em")); } } diff --git a/tests/phpunit/WebTest/Profile/BatchUpdateTest.php b/tests/phpunit/WebTest/Profile/BatchUpdateTest.php index b85998cc00..d26423efdc 100644 --- a/tests/phpunit/WebTest/Profile/BatchUpdateTest.php +++ b/tests/phpunit/WebTest/Profile/BatchUpdateTest.php @@ -44,7 +44,6 @@ class WebTest_Profile_BatchUpdateTest extends CiviSeleniumTestCase { $lastName1 = "Smiths_x" . substr(sha1(rand()), 0, 7); $Name1 = $lastName1 . ', ' . $firstName1; $this->webtestAddContact($firstName1, $lastName1, "$firstName1.$lastName1@example.com"); - $this->waitForPageToLoad($this->getTimeoutMsec()); // Add new individual using Quick Add block on the main page $firstName2 = "James_" . substr(sha1(rand()), 0, 7); @@ -56,9 +55,7 @@ class WebTest_Profile_BatchUpdateTest extends CiviSeleniumTestCase { $Name3 = $lastName3 . ', ' . $firstName3; $this->webtestAddContact($firstName2, $lastName2, "$firstName2.$lastName2@example.com", "Student"); - $this->waitForPageToLoad($this->getTimeoutMsec()); $this->webtestAddContact($firstName3, $lastName3, "$firstName3.$lastName3@example.com", "Staff"); - $this->waitForPageToLoad($this->getTimeoutMsec()); $profileTitle = 'Batch Profile test_' . substr(sha1(rand()), 0, 7); $profileFields = array( @@ -134,13 +131,11 @@ class WebTest_Profile_BatchUpdateTest extends CiviSeleniumTestCase { $lastName = "Smith_" . substr(sha1(rand()), 0, 7); $Name1 = $lastName . ', ' . $firstName1; $this->webtestAddContact($firstName1, $lastName, "$firstName1.$lastName@example.com"); - $this->waitForPageToLoad($this->getTimeoutMsec()); // Add new individual using Quick Add block on the main page $firstName1 = "James_" . substr(sha1(rand()), 0, 7); $Name2 = $lastName . ', ' . $firstName1; $this->webtestAddContact($firstName1, $lastName, "$firstName1.$lastName@example.com"); - $this->waitForPageToLoad($this->getTimeoutMsec()); $profileTitle = 'Batch Profile test for contacts ' . substr(sha1(rand()), 0, 7); $profileFor = 'Contacts'; $customDataArr = $this->_addCustomData($profileFor); -- 2.25.1