From 0e32ba2d15077447bd37cfc5fccf7d6792f53cab Mon Sep 17 00:00:00 2001 From: jitendrapurohit Date: Thu, 17 Apr 2014 19:42:08 +0530 Subject: [PATCH] Web Test Fix --- .../phpunit/CiviTest/CiviSeleniumTestCase.php | 2 +- tests/phpunit/WebTest/Contact/AddTest.php | 2 +- .../WebTest/Contact/RelationshipAddTest.php | 97 +++++++++++-------- .../WebTest/Contact/TagSetSearchTest.php | 6 +- 4 files changed, 62 insertions(+), 45 deletions(-) diff --git a/tests/phpunit/CiviTest/CiviSeleniumTestCase.php b/tests/phpunit/CiviTest/CiviSeleniumTestCase.php index f0528d8682..b46703a5d9 100644 --- a/tests/phpunit/CiviTest/CiviSeleniumTestCase.php +++ b/tests/phpunit/CiviTest/CiviSeleniumTestCase.php @@ -506,7 +506,7 @@ class CiviSeleniumTestCase extends PHPUnit_Extensions_SeleniumTestCase { // 4 - Individual profile // 5 - Organization profile // 6 - Household profile - $profile = array('4' => 'New Individual', '5' => 'New Organisation', '6' => 'New Household'); + $profile = array('4' => 'New Individual', '5' => 'New Organization', '6' => 'New Household'); $this->clickAt("xpath=//div[@id='$selectId']/a"); $this->click("xpath=//li[@class='select2-no-results']//a[contains(text(),' $profile[$type]')]"); diff --git a/tests/phpunit/WebTest/Contact/AddTest.php b/tests/phpunit/WebTest/Contact/AddTest.php index 39349eb8f1..58ac49475c 100644 --- a/tests/phpunit/WebTest/Contact/AddTest.php +++ b/tests/phpunit/WebTest/Contact/AddTest.php @@ -157,7 +157,7 @@ class WebTest_Contact_AddTest extends CiviSeleniumTestCase { $this->click("tagGroup"); // select group - $this->select("crmasmSelect0", "label=$groupName"); + $this->select("group", "label=$groupName"); $this->click("tag[{$this->webtestGetValidEntityID('Tag')}]"); // Clicking save. diff --git a/tests/phpunit/WebTest/Contact/RelationshipAddTest.php b/tests/phpunit/WebTest/Contact/RelationshipAddTest.php index 492c9a87dd..910d9ce814 100644 --- a/tests/phpunit/WebTest/Contact/RelationshipAddTest.php +++ b/tests/phpunit/WebTest/Contact/RelationshipAddTest.php @@ -73,9 +73,13 @@ class WebTest_Contact_RelationshipAddTest extends CiviSeleniumTestCase { $this->select('relationship_type_id', "label={$params['label_b_a']}"); //fill in the individual - $this->webtestFillAutocomplete($sortName); + $this->click("//*[@id='related_contact_id']/../div/ul/li/input"); + $this->keyDown("//*[@id='related_contact_id']/../div/ul/li/input", " "); + $this->type("//*[@id='related_contact_id']/../div/ul/li/input", $sortName); + $this->typeKeys("//*[@id='related_contact_id']/../div/ul/li/input", $sortName); + $this->waitForElementPresent("//*[@class='select2-result-label']"); + $this->clickAt("//*[@class='select2-results']/li[1]"); - $this->waitForElementPresent("quick-save"); //fill in the relationship start date $this->webtestFillDate('start_date', '-2 year'); @@ -86,16 +90,15 @@ class WebTest_Contact_RelationshipAddTest extends CiviSeleniumTestCase { //save the relationship //$this->click("_qf_Relationship_upload"); - $this->click("quick-save"); - $this->waitForElementPresent("current-relationships"); + $this->click('_qf_Relationship_upload-bottom'); + $this->waitForElementPresent("crm-contact-relationship-selector-current_wrapper"); //check the status message - $this->assertTrue($this->isTextPresent("New relationship created.")); + $this->waitForText('crm-notification-container', 'Relationship created.'); - $this->waitForElementPresent("xpath=//div[@id='current-relationships']//div//table/tbody//tr/td[9]/span/a[text()='View']"); - $this->click("xpath=//div[@id='current-relationships']//div//table/tbody//tr/td[9]/span/a[text()='View']"); + $this->waitForElementPresent("xpath=//div[@id='crm-contact-relationship-selector-current_wrapper']//table/tbody//tr/td[9]/span/a[text()='View']"); + $this->click("xpath=//div[@id='crm-contact-relationship-selector-current_wrapper']//table/tbody//tr/td[9]/span/a[text()='View']"); - $this->waitForPageToLoad($this->getTimeoutMsec()); $this->webtestVerifyTabularData( array( 'Description' => $description, @@ -161,9 +164,13 @@ class WebTest_Contact_RelationshipAddTest extends CiviSeleniumTestCase { $this->select('relationship_type_id', "label={$params['label_b_a']}"); //fill in the individual - $this->webtestFillAutocomplete($sortName); + $this->click("//*[@id='related_contact_id']/../div/ul/li/input"); + $this->keyDown("//*[@id='related_contact_id']/../div/ul/li/input", " "); + $this->type("//*[@id='related_contact_id']/../div/ul/li/input", $sortName); + $this->typeKeys("//*[@id='related_contact_id']/../div/ul/li/input", $sortName); + $this->waitForElementPresent("//*[@class='select2-result-label']"); + $this->clickAt("//*[@class='select2-results']/li[1]"); - $this->waitForElementPresent("quick-save"); //fill in the relationship start date $this->webtestFillDate('start_date', '-2 year'); @@ -173,13 +180,12 @@ class WebTest_Contact_RelationshipAddTest extends CiviSeleniumTestCase { $this->type("description", $description); //save the relationship - $this->click("quick-save"); - $this->waitForElementPresent("current-relationships"); + $this->click('_qf_Relationship_upload-bottom'); + $this->waitForElementPresent("crm-contact-relationship-selector-current_wrapper"); - $this->waitForElementPresent("xpath=//div[@id='current-relationships']//div//table/tbody//tr/td[9]/span/a[text()='View']"); - $this->click("xpath=//div[@id='current-relationships']//div//table/tbody//tr/td[9]/span/a[text()='View']"); + $this->waitForElementPresent("xpath=//div[@id='crm-contact-relationship-selector-current_wrapper']//table/tbody//tr/td[9]/span/a[text()='View']"); + $this->click("xpath=//div[@id='crm-contact-relationship-selector-current_wrapper']//table/tbody//tr/td[9]/span/a[text()='View']"); - $this->waitForPageToLoad($this->getTimeoutMsec()); $this->webtestVerifyTabularData( array( 'Description' => $description, @@ -257,9 +263,13 @@ class WebTest_Contact_RelationshipAddTest extends CiviSeleniumTestCase { $this->select('relationship_type_id', "label={$params['label_b_a']}"); //fill in the individual - $this->webtestFillAutocomplete($sortName); - $this->waitForElementPresent("quick-save"); + $this->click("//*[@id='related_contact_id']/../div/ul/li/input"); + $this->keyDown("//*[@id='related_contact_id']/../div/ul/li/input", " "); + $this->type("//*[@id='related_contact_id']/../div/ul/li/input", $sortName); + $this->typeKeys("//*[@id='related_contact_id']/../div/ul/li/input", $sortName); + $this->waitForElementPresent("//*[@class='select2-result-label']"); + $this->clickAt("//*[@class='select2-results']/li[1]"); //fill in the relationship start date $this->webtestFillDate('start_date', '-2 year'); @@ -268,13 +278,12 @@ class WebTest_Contact_RelationshipAddTest extends CiviSeleniumTestCase { $this->type("description", $description); //save the relationship - $this->click("quick-save"); - $this->waitForElementPresent("current-relationships"); + $this->click('_qf_Relationship_upload-bottom'); + $this->waitForElementPresent("crm-contact-relationship-selector-current_wrapper"); - $this->waitForElementPresent("xpath=//div[@id='current-relationships']//div//table/tbody//tr/td[9]/span/a[text()='View']"); - $this->click("xpath=//div[@id='current-relationships']//div//table/tbody//tr/td[9]/span/a[text()='View']"); + $this->waitForElementPresent("xpath=//div[@id='crm-contact-relationship-selector-current_wrapper']//table/tbody//tr/td[9]/span/a[text()='View']"); + $this->click("xpath=//div[@id='crm-contact-relationship-selector-current_wrapper']//table/tbody//tr/td[9]/span/a[text()='View']"); - $this->waitForPageToLoad($this->getTimeoutMsec()); $this->webtestVerifyTabularData( array( 'Description' => $description, @@ -321,9 +330,14 @@ class WebTest_Contact_RelationshipAddTest extends CiviSeleniumTestCase { // create a new organization $orgName = 'WestsideCoop' . substr(sha1(rand()), 0, 7); - $this->webtestNewDialogContact($orgName, "", "info@" . $orgName . ".com", 5); - $this->waitForElementPresent("quick-save"); + $this->click("//*[@id='related_contact_id']/../div/ul/li/input"); + $this->click("xpath=//li[@class='select2-no-results']//a[contains(text(),' New Organization')]"); + $this->waitForElementPresent('_qf_Edit_next'); + $this->type('organization_name', $orgName); + $this->type('email-Primary', "info@" . $orgName . ".com"); + $this->click('_qf_Edit_next'); + $this->waitForText("xpath=//div[@id='s2id_related_contact_id']","$orgName"); //fill in the relationship start date $this->webtestFillDate('start_date', '-2 year'); @@ -334,16 +348,15 @@ class WebTest_Contact_RelationshipAddTest extends CiviSeleniumTestCase { //save the relationship //$this->click("_qf_Relationship_upload"); - $this->click("quick-save"); - $this->waitForElementPresent("current-relationships"); + $this->click("_qf_Relationship_upload-bottom"); + $this->waitForElementPresent("crm-contact-relationship-selector-current_wrapper"); //check the status message - $this->assertTrue($this->isTextPresent("New relationship created.")); + $this->waitForText('crm-notification-container', 'Relationship created.'); - $this->waitForElementPresent("xpath=//div[@id='current-relationships']//div//table/tbody//tr/td[9]/span/a[text()='View']"); - $this->click("xpath=//div[@id='current-relationships']//div//table/tbody//tr/td[9]/span/a[text()='View']"); + $this->waitForElementPresent("xpath=//div[@id='crm-contact-relationship-selector-current_wrapper']//table/tbody//tr/td[9]/span/a[text()='View']"); + $this->click("xpath=//div[@id='crm-contact-relationship-selector-current_wrapper']//table/tbody//tr/td[9]/span/a[text()='View']"); - $this->waitForPageToLoad($this->getTimeoutMsec()); $this->webtestVerifyTabularData( array( 'Description' => $description, @@ -395,10 +408,15 @@ class WebTest_Contact_RelationshipAddTest extends CiviSeleniumTestCase { sleep(2); // create a new organization - $orgName = 'WestsideCoop' . substr(sha1(rand()), 0, 7); - $this->webtestNewDialogContact($orgName, "", "info@" . $orgName . ".com", 5); - $this->waitForElementPresent("quick-save"); + $orgName = 'WestsideCoop' . substr(sha1(rand()), 0, 7); + $this->click("//*[@id='related_contact_id']/../div/ul/li/input"); + $this->click("xpath=//li[@class='select2-no-results']//a[contains(text(),' New Organization')]"); + $this->waitForElementPresent('_qf_Edit_next'); + $this->type('organization_name', $orgName); + $this->type('email-Primary', "info@" . $orgName . ".com"); + $this->click('_qf_Edit_next'); + $this->waitForText("xpath=//div[@id='s2id_related_contact_id']","$orgName"); //fill in the relationship start date $this->webtestFillDate('start_date', '-2 year'); @@ -407,21 +425,18 @@ class WebTest_Contact_RelationshipAddTest extends CiviSeleniumTestCase { $description = "Current employee test."; $this->type("description", $description); - $this->waitForElementPresent("add_current_employee"); - $this->click("add_current_employee"); //save the relationship //$this->click("_qf_Relationship_upload"); - $this->click("quick-save"); - $this->waitForElementPresent("current-relationships"); + $this->click('_qf_Relationship_upload-bottom'); + $this->waitForElementPresent("crm-contact-relationship-selector-current_wrapper"); //check the status message - $this->assertTrue($this->isTextPresent("New relationship created.")); + $this->waitForText('crm-notification-container', 'Relationship created.'); - $this->waitForElementPresent("xpath=//div[@id='current-relationships']//div//table/tbody//tr/td[9]/span/a[text()='View']"); - $this->click("xpath=//div[@id='current-relationships']//div//table/tbody//tr/td[9]/span/a[text()='View']"); + $this->waitForElementPresent("xpath=//div[@id='crm-contact-relationship-selector-current_wrapper']//table/tbody//tr/td[9]/span/a[text()='View']"); + $this->click("xpath=//div[@id='crm-contact-relationship-selector-current_wrapper']//table/tbody//tr/td[9]/span/a[text()='View']"); - $this->waitForPageToLoad($this->getTimeoutMsec()); $this->webtestVerifyTabularData( array( 'Description' => $description, diff --git a/tests/phpunit/WebTest/Contact/TagSetSearchTest.php b/tests/phpunit/WebTest/Contact/TagSetSearchTest.php index 0a1c72dbc8..b57b71ac27 100644 --- a/tests/phpunit/WebTest/Contact/TagSetSearchTest.php +++ b/tests/phpunit/WebTest/Contact/TagSetSearchTest.php @@ -163,9 +163,11 @@ class WebTest_Contact_TagSetSearchTest extends CiviSeleniumTestCase { // verify text $this->waitForElementPresent("xpath=//table//tbody/tr/td[1][text()= '$tagSetName']"); - $this->clickLink("xpath=//table//tbody/tr/td[1][text()= '$tagSetName']/following-sibling::td[7]/span/a[text()= 'Edit']"); + $tagid = explode('&id=', $this->getAttribute("xpath=//table//tbody/tr/td[1][text()= '$tagSetName']/following-sibling::td[7]/span/a[text()= 'Edit']@href")); + $tagid = explode('&', $tagid[1]); + $tagid = $tagid[0]; - return $this->urlArg('id'); + return $tagid; } } -- 2.25.1