From b5e4fcd98e55c002e7c33422c417fa574eafd3fa Mon Sep 17 00:00:00 2001 From: jitendrapurohit Date: Fri, 18 Apr 2014 17:51:20 +0530 Subject: [PATCH] Web Test Fix --- .../AddContactsToEventAdvancedSearchTest.php | 2 +- .../WebTest/Contact/AdvanceSearchPaneTest.php | 2 +- .../Contact/AdvanceSearchPrivacyOptionsTest.php | 10 +++++----- .../Contact/ContactReferenceFieldTest.php | 17 ++++++++--------- .../DeceasedContactsAdvancedSearchTest.php | 7 +++---- .../WebTest/Contact/InlineFieldsEditTest.php | 4 ++-- tests/phpunit/WebTest/Contact/PrevNextTest.php | 3 --- .../WebTest/Contact/PrivacyOptionSearchTest.php | 2 -- .../WebTest/Contact/ProfileChecksumTest.php | 3 ++- .../WebTest/Contact/SearchBuilderTest.php | 8 ++++---- .../WebTest/Contact/SearchbyDateFilterTest.php | 2 +- .../Contact/TaskActionAddToGroupTest.php | 6 +++--- 12 files changed, 30 insertions(+), 36 deletions(-) diff --git a/tests/phpunit/WebTest/Contact/AddContactsToEventAdvancedSearchTest.php b/tests/phpunit/WebTest/Contact/AddContactsToEventAdvancedSearchTest.php index e2e26f4dab..0018a3be73 100644 --- a/tests/phpunit/WebTest/Contact/AddContactsToEventAdvancedSearchTest.php +++ b/tests/phpunit/WebTest/Contact/AddContactsToEventAdvancedSearchTest.php @@ -47,7 +47,7 @@ class WebTest_Contact_AddContactsToEventAdvancedSearchTest extends CiviSeleniumT // Select event. Based on label for now. $this->waitForElementPresent('event_id'); - $this->select('event_id', "label=regexp:Rain-forest Cup Youth Soccer Tournament."); + $this->select2('event_id', "Rain-forest Cup Youth Soccer Tournament"); // Select role $this->click('role_id[2]'); diff --git a/tests/phpunit/WebTest/Contact/AdvanceSearchPaneTest.php b/tests/phpunit/WebTest/Contact/AdvanceSearchPaneTest.php index a03072fc4e..6faa45d567 100644 --- a/tests/phpunit/WebTest/Contact/AdvanceSearchPaneTest.php +++ b/tests/phpunit/WebTest/Contact/AdvanceSearchPaneTest.php @@ -351,7 +351,7 @@ class WebTest_Contact_AdvanceSearchPaneTest extends CiviSeleniumTestCase { 'event' => array( 'headerLocator' => 'div#CiviEvent', - 'bodyLocator' => 'input#event_name', + 'bodyLocator' => 'input#event_id', 'title' => 'Events', 'fields' => array( diff --git a/tests/phpunit/WebTest/Contact/AdvanceSearchPrivacyOptionsTest.php b/tests/phpunit/WebTest/Contact/AdvanceSearchPrivacyOptionsTest.php index 51d465bf93..f237ba5de7 100644 --- a/tests/phpunit/WebTest/Contact/AdvanceSearchPrivacyOptionsTest.php +++ b/tests/phpunit/WebTest/Contact/AdvanceSearchPrivacyOptionsTest.php @@ -128,17 +128,17 @@ class WebTest_Contact_AdvanceSearchPrivacyOptionsTest extends CiviSeleniumTestCa foreach ($privacyOptions as $privacyOption) { $privacyOptionVal = $this->getOptionVal($privacyOption); - if (!$this->isElementPresent("xpath=//ul[@id='crmasmList4']//li//span[text()='{$privacyOptionVal}']")) { - $this->select('crmasmSelect4', "value={$privacyOption}"); - $this->waitForElementPresent("xpath=//ul[@id='crmasmList4']//li//span[text()='{$privacyOptionVal}']"); + if (!$this->isElementPresent("xpath=//div[@id='s2id_privacy_options']//ul//li//div[text()='{$privacyOptionVal}']")) { + $this->select('privacy_options', "value={$privacyOption}"); + $this->waitForElementPresent("xpath=//div[@id='s2id_privacy_options']//ul//li//div[text()='{$privacyOptionVal}']"); } } foreach ($allPrivacyOptions as $allPrivacyOption) { if (!in_array($allPrivacyOption, $privacyOptions)) { $privacyOptionVal = $this->getOptionVal($allPrivacyOption); - if ($this->isElementPresent("xpath=//ul[@id='crmasmList4']//li//span[text()='{$privacyOptionVal}']")) { - $this->click("xpath=//ul[@id='crmasmList4']//li//span[text()='{$privacyOptionVal}']/../a[@class='crmasmListItemRemove']"); + if ($this->isElementPresent("xpath=//div[@id='s2id_privacy_options']//ul//li//div[text()='{$privacyOptionVal}']")) { + $this->click("xpath=//div[@id='s2id_privacy_options']//ul//li//div[text()='{$privacyOptionVal}']/../a[@class='select2-search-choice-close']"); } } } diff --git a/tests/phpunit/WebTest/Contact/ContactReferenceFieldTest.php b/tests/phpunit/WebTest/Contact/ContactReferenceFieldTest.php index 85fc925589..f0b795f26c 100644 --- a/tests/phpunit/WebTest/Contact/ContactReferenceFieldTest.php +++ b/tests/phpunit/WebTest/Contact/ContactReferenceFieldTest.php @@ -62,7 +62,6 @@ class WebTest_Contact_ContactReferenceFieldTest extends CiviSeleniumTestCase { $this->waitForElementPresent('_qf_GroupContact_next'); $this->select('group_id', "label={$groupName}"); $this->click('_qf_GroupContact_next'); - $this->waitForPageToLoad($this->getTimeoutMsec()); $this->waitForText('crm-notification-container', "Added to Group"); // Individual 1 @@ -110,7 +109,7 @@ class WebTest_Contact_ContactReferenceFieldTest extends CiviSeleniumTestCase { $this->waitForPageToLoad($this->getTimeoutMsec()); //Is custom field created? - $this->waitForText('crm-notification-container', "Your custom field '$contactRefFieldLabel1' has been saved."); + $this->waitForText('crm-notification-container', "Custom field '$contactRefFieldLabel1' has been saved."); //add custom field - alphanumeric checkbox $contactRefFieldLabel2 = 'contact_ref_' . substr(sha1(rand()), 0, 4); @@ -129,21 +128,21 @@ class WebTest_Contact_ContactReferenceFieldTest extends CiviSeleniumTestCase { $this->waitForPageToLoad($this->getTimeoutMsec()); //Is custom field created? - $this->waitForText('crm-notification-container', "Your custom field '$contactRefFieldLabel2' has been saved."); + $this->waitForText('crm-notification-container', "Custom field '$contactRefFieldLabel2' has been saved."); $this->openCiviPage('admin/custom/group/field', "reset=1&action=browse&gid={$customGroupId}"); - $this->click("xpath=//div[@id='field_page']//table/tbody/tr[1]/td[8]/span[1]/a[text()='Edit Field']"); - $this->waitForPageToLoad($this->getTimeoutMsec()); + $fieldid1 = explode("&id=", $this->getAttribute("xpath=//div[@id='field_page']//table/tbody/tr[1]/td[8]/span[1]/a[text()='Edit Field']@href")); + $fieldid1 = $fieldid1[1]; - $contactRefFieldID1 = $this->urlArg('id'); + $contactRefFieldID1 = $fieldid1; $this->openCiviPage('admin/custom/group/field', "reset=1&action=browse&gid={$customGroupId}"); - $this->click("xpath=//div[@id='field_page']//table/tbody/tr[2]/td[8]/span[1]/a[text()='Edit Field']"); - $this->waitForPageToLoad($this->getTimeoutMsec()); + $fieldid2 = explode("&id=", $this->getAttribute("xpath=//div[@id='field_page']//table/tbody/tr[2]/td[8]/span[1]/a[text()='Edit Field']@href")); + $fieldid2 = $fieldid2[1]; - $contactRefFieldID2 = $this->urlArg('id'); + $contactRefFieldID2 = $fieldid2; // Visit custom group preview page $this->openCiviPage('admin/custom/group', "action=preview&reset=1&id={$customGroupId}"); diff --git a/tests/phpunit/WebTest/Contact/DeceasedContactsAdvancedSearchTest.php b/tests/phpunit/WebTest/Contact/DeceasedContactsAdvancedSearchTest.php index d079e6c24f..7165398b15 100644 --- a/tests/phpunit/WebTest/Contact/DeceasedContactsAdvancedSearchTest.php +++ b/tests/phpunit/WebTest/Contact/DeceasedContactsAdvancedSearchTest.php @@ -57,7 +57,7 @@ class WebTest_Contact_DeceasedContactsAdvancedSearchTest extends CiviSeleniumTes $this->openCiviPage('contact/search/advanced', 'reset=1', '_qf_Advanced_refresh'); // Select the group and check deceased contacts - $this->select('crmasmSelect1', "label={$groupName}"); + $this->select('group', "label={$groupName}"); $this->click('demographics'); $this->waitForElementPresent('CIVICRM_QFID_1_is_deceased'); $this->click('CIVICRM_QFID_1_is_deceased'); @@ -67,7 +67,7 @@ class WebTest_Contact_DeceasedContactsAdvancedSearchTest extends CiviSeleniumTes $this->waitForTextPresent('2 Selected records only'); $this->select('task', 'label=Remove Contacts from Group'); - $this->click("xpath=//div[@id='search-status']/table/tbody/tr[3]/td/ul/input[2]"); + $this->click("Go"); $this->waitForElementPresent('_qf_RemoveFromGroup_back-bottom'); $this->assertElementContainsText('crm-container', 'Number of selected contacts: 2'); $this->select('group_id', "label={$groupName}"); @@ -77,7 +77,7 @@ class WebTest_Contact_DeceasedContactsAdvancedSearchTest extends CiviSeleniumTes // Search for the contacts who are not deceased $this->openCiviPage('contact/search/advanced', 'reset=1', '_qf_Advanced_refresh'); - $this->select('crmasmSelect1', "label={$groupName}"); + $this->select('group', "label={$groupName}"); $this->click('_qf_Advanced_refresh'); // Check if non-deceased contacts are still present @@ -106,7 +106,6 @@ class WebTest_Contact_DeceasedContactsAdvancedSearchTest extends CiviSeleniumTes $this->waitForElementPresent('_qf_GroupContact_next'); $this->select('group_id', "{$groupName}"); $this->click('_qf_GroupContact_next'); - $this->waitForPageToLoad($this->getTimeoutMsec()); } } diff --git a/tests/phpunit/WebTest/Contact/InlineFieldsEditTest.php b/tests/phpunit/WebTest/Contact/InlineFieldsEditTest.php index 3bc4051437..63565660a1 100644 --- a/tests/phpunit/WebTest/Contact/InlineFieldsEditTest.php +++ b/tests/phpunit/WebTest/Contact/InlineFieldsEditTest.php @@ -67,10 +67,10 @@ class WebTest_Contact_InlineFieldsEditTest extends CiviSeleniumTestCase { // Justification for this instance: opening an accordion is predictable sleep(1); $this->openInlineForm('custom-set-content-1'); - $dateFieldId = $this->getAttribute("xpath=//div[@id='constituent_information']/table/tbody/tr[3]/td[@class='html-adjust']/input@id"); + $dateFieldId = $this->getAttribute("xpath=//div[@class='crm-accordion-body']/table/tbody/tr[3]/td[@class='html-adjust']/input@id"); $this->inlineEdit('custom-set-content-1', array( 'CIVICRM_QFID_Edu_2' => 1, - "//div[@id='constituent_information']/table/tbody/tr[2]/td[@class='html-adjust']/select" => array('Single'), + "//div[@class='crm-accordion-body']/table/tbody/tr[2]/td[@class='html-adjust']/select" => array('Single'), $dateFieldId => 'date: now - 10 years', )); diff --git a/tests/phpunit/WebTest/Contact/PrevNextTest.php b/tests/phpunit/WebTest/Contact/PrevNextTest.php index acd44d8c5f..35206890f6 100644 --- a/tests/phpunit/WebTest/Contact/PrevNextTest.php +++ b/tests/phpunit/WebTest/Contact/PrevNextTest.php @@ -62,7 +62,6 @@ class WebTest_Contact_PrevNextTest extends CiviSeleniumTestCase { $this->waitForElementPresent('_qf_GroupContact_next'); $this->select('group_id', "label={$groupName}"); $this->click('_qf_GroupContact_next'); - $this->waitForPageToLoad($this->getTimeoutMsec()); $this->waitForText('crm-notification-container', "Added to Group"); // Individual 2 @@ -74,7 +73,6 @@ class WebTest_Contact_PrevNextTest extends CiviSeleniumTestCase { $this->waitForElementPresent('_qf_GroupContact_next'); $this->select('group_id', "label={$groupName}"); $this->click('_qf_GroupContact_next'); - $this->waitForPageToLoad($this->getTimeoutMsec()); $this->waitForText('crm-notification-container', "Added to Group"); // Individual 3 @@ -86,7 +84,6 @@ class WebTest_Contact_PrevNextTest extends CiviSeleniumTestCase { $this->waitForElementPresent('_qf_GroupContact_next'); $this->select('group_id', "label={$groupName}"); $this->click('_qf_GroupContact_next'); - $this->waitForPageToLoad($this->getTimeoutMsec()); $this->waitForText('crm-notification-container', "Added to Group"); // Search contacts diff --git a/tests/phpunit/WebTest/Contact/PrivacyOptionSearchTest.php b/tests/phpunit/WebTest/Contact/PrivacyOptionSearchTest.php index 5546fa8f4e..d03ffd9ca1 100644 --- a/tests/phpunit/WebTest/Contact/PrivacyOptionSearchTest.php +++ b/tests/phpunit/WebTest/Contact/PrivacyOptionSearchTest.php @@ -76,7 +76,6 @@ class WebTest_Contact_PrivacyOptionSearchTest extends CiviSeleniumTestCase { $this->waitForElementPresent("group_id"); $this->select("group_id", "label=$groupName"); $this->click("_qf_GroupContact_next"); - $this->waitForPageToLoad($this->getTimeoutMsec()); // Add Contact2. $fname2 = substr(sha1(rand()), 0, 7); @@ -102,7 +101,6 @@ class WebTest_Contact_PrivacyOptionSearchTest extends CiviSeleniumTestCase { $this->waitForElementPresent("group_id"); $this->select("group_id", "label=$groupName"); $this->click("_qf_GroupContact_next"); - $this->waitForPageToLoad($this->getTimeoutMsec()); // Go to advance search, check for 'Exclude' option. $this->openCiviPage("contact/search/advanced", "reset=1"); diff --git a/tests/phpunit/WebTest/Contact/ProfileChecksumTest.php b/tests/phpunit/WebTest/Contact/ProfileChecksumTest.php index 423d675bff..f726500be5 100644 --- a/tests/phpunit/WebTest/Contact/ProfileChecksumTest.php +++ b/tests/phpunit/WebTest/Contact/ProfileChecksumTest.php @@ -99,7 +99,7 @@ class WebTest_Contact_ProfileChecksumTest extends CiviSeleniumTestCase { $profileId = $this->_testCreateContactProfile($fields, $profileName); // Check for profile create/edit permissions. - $permission = array('edit-1-profile-edit', 'edit-1-profile-create', 'edit-1-access-all-custom-data'); + $permission = array('edit-1-profile-edit', 'edit-1-profile-create', 'edit-1-access-all-custom-data', 'edit-1-edit-all-contacts'); $this->changePermissions($permission); // Get checksum of the newly created contact. @@ -145,6 +145,7 @@ class WebTest_Contact_ProfileChecksumTest extends CiviSeleniumTestCase { // Name of the profile. $this->type('title', $profileName); + $this->click('uf_group_type_Profile'); $this->click('_qf_Group_next-top'); $this->waitForPageToLoad($this->getTimeoutMsec()); $profileId = $this->urlArg('gid'); diff --git a/tests/phpunit/WebTest/Contact/SearchBuilderTest.php b/tests/phpunit/WebTest/Contact/SearchBuilderTest.php index 11378a94d6..60c82a1684 100644 --- a/tests/phpunit/WebTest/Contact/SearchBuilderTest.php +++ b/tests/phpunit/WebTest/Contact/SearchBuilderTest.php @@ -159,8 +159,8 @@ class WebTest_Contact_SearchBuilderTest extends CiviSeleniumTestCase { $this->click("_qf_Contact_upload_view"); $this->waitForPageToLoad($this->getTimeoutMsec()); $this->_searchBuilder('Email', NULL, NULL, 'IS NULL'); - $this->click("xpath=//div[@class='crm-search-results']/div[4]/a[2]"); - $this->waitForPageToLoad($this->getTimeoutMsec()); + $this->type("xpath=//*[@id='Builder-rows-per-page-select']", '100'); + $this->waitForElementPresent("xpath=//*[@id='Builder-rows-per-page-select']"); $names = array( 1 => $firstName1, 2 => $firstName2, @@ -176,8 +176,8 @@ class WebTest_Contact_SearchBuilderTest extends CiviSeleniumTestCase { } //searching contacts whose phone field is not empty $this->_searchBuilder('Phone', NULL, $firstName, 'IS NOT EMPTY'); - $this->click("xpath=//div[@class='crm-search-results']/div[4]/a[2]"); - $this->waitForPageToLoad($this->getTimeoutMsec()); + $this->type("xpath=//*[@id='Builder-rows-per-page-select']", '100'); + $this->waitForElementPresent("xpath=//*[@id='Builder-rows-per-page-select']"); $this->assertTrue($this->isTextPresent($firstName)); $firstName4 = "AB" . substr(sha1(rand()), 0, 7); diff --git a/tests/phpunit/WebTest/Contact/SearchbyDateFilterTest.php b/tests/phpunit/WebTest/Contact/SearchbyDateFilterTest.php index 65c1d3d807..54530b9eaa 100644 --- a/tests/phpunit/WebTest/Contact/SearchbyDateFilterTest.php +++ b/tests/phpunit/WebTest/Contact/SearchbyDateFilterTest.php @@ -329,7 +329,7 @@ class WebTest_Contact_SearchbyDateFilterTest extends CiviSeleniumTestCase { 'event' => array( 'headerLocator' => 'div#CiviEvent', - 'bodyLocator' => 'input#event_name', + 'bodyLocator' => 'input#event_id', 'title' => 'Events', 'fields' => array( diff --git a/tests/phpunit/WebTest/Contact/TaskActionAddToGroupTest.php b/tests/phpunit/WebTest/Contact/TaskActionAddToGroupTest.php index d9d28b9b61..ab9a07ca1e 100644 --- a/tests/phpunit/WebTest/Contact/TaskActionAddToGroupTest.php +++ b/tests/phpunit/WebTest/Contact/TaskActionAddToGroupTest.php @@ -113,11 +113,11 @@ class WebTest_Contact_TaskActionAddToGroupTest extends CiviSeleniumTestCase { $this->click("_qf_Basic_refresh"); $this->waitForPageToLoad($this->getTimeoutMsec()); - $this->click("xpath=//div[@class='form-item float-right']/a[text()='25']"); - $this->waitForPageToLoad($this->getTimeoutMsec()); + $this->type("xpath=//*[@id='Basic-rows-per-page-select']", '25'); + $this->waitForElementPresent("xpath=//*[@id='Basic-rows-per-page-select']"); $this->click("toggleSelect"); $this->click("xpath=//div[@class='crm-content-block']/div/div[2]/div/span[2]/a"); - $this->waitForPageToLoad($this->getTimeoutMsec()); + $this->waitForElementPresent("Go"); $this->click("toggleSelect"); $this->select("task", "label=Add Contacts to Group"); $this->click("Go"); -- 2.25.1