From 39a2888d8ecd2b5c016c6f46148b53cbc8071c70 Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Mon, 15 Sep 2014 23:41:57 -0400 Subject: [PATCH] Webtest fixes for profile/custom-field/price-set --- .../phpunit/CiviTest/CiviSeleniumTestCase.php | 14 ++---- tests/phpunit/WebTest/Admin/CustomAddTest.php | 1 - .../WebTest/Admin/CustomAddTestSameField.php | 24 ++++----- .../Contact/MultipleContactSubTypes.php | 4 +- .../WebTest/Contribute/AddPricesetTest.php | 4 +- .../Contribute/OnBehalfOfOrganization.php | 14 +++--- .../Member/BatchUpdateViaProfileTest.php | 6 ++- .../WebTest/Profile/BatchUpdateTest.php | 49 ++++++------------- .../WebTest/Profile/ProfileAddTest.php | 14 ++---- .../WebTest/Profile/ProfileCountryState.php | 17 ++++--- .../Profile/ProfileGroupSubscriptionTest.php | 1 - tests/phpunit/WebTest/Profile/SearchTest.php | 45 +++++++---------- 12 files changed, 80 insertions(+), 113 deletions(-) diff --git a/tests/phpunit/CiviTest/CiviSeleniumTestCase.php b/tests/phpunit/CiviTest/CiviSeleniumTestCase.php index 4955b22775..e99f4630e2 100644 --- a/tests/phpunit/CiviTest/CiviSeleniumTestCase.php +++ b/tests/phpunit/CiviTest/CiviSeleniumTestCase.php @@ -1900,22 +1900,14 @@ class CiviSeleniumTestCase extends PHPUnit_Extensions_SeleniumTestCase { function addProfile($profileTitle, $profileFields) { $this->openCiviPage('admin/uf/group', "reset=1"); - $this->click('link=Add Profile'); - - // Add membership custom data field to profile - $this->waitForElementPresent('_qf_Group_cancel-bottom'); + $this->clickLink('link=Add Profile', '_qf_Group_cancel-bottom'); $this->type('title', $profileTitle); - $this->click('_qf_Group_next-bottom'); - $this->waitForPageToLoad($this->getTimeoutMsec()); + $this->clickLink('_qf_Group_next-bottom', "xpath=//a/span[text()='Add Field']"); - $this->waitForElementPresent("xpath=//a/span[text()='Add Field']"); - $this->click("xpath=//a/span[text()='Add Field']"); - $this->waitForElementPresent("field_name[0]"); - //$this->assertTrue($this->isTextPresent("Your CiviCRM Profile '{$profileTitle}' has been added. You can add fields to this profile now.")); + $this->waitForText('crm-notification-container', "Your CiviCRM Profile '{$profileTitle}' has been added. You can add fields to this profile now."); foreach ($profileFields as $field) { $this->waitForElementPresent('field_name_0'); - // $this->waitForPageToLoad($this->getTimeoutMsec()); $this->click("id=field_name_0"); $this->select("id=field_name_0", "label=" . $field['type']); $this->waitForElementPresent('field_name_1'); diff --git a/tests/phpunit/WebTest/Admin/CustomAddTest.php b/tests/phpunit/WebTest/Admin/CustomAddTest.php index fb0c220989..476135b015 100644 --- a/tests/phpunit/WebTest/Admin/CustomAddTest.php +++ b/tests/phpunit/WebTest/Admin/CustomAddTest.php @@ -57,7 +57,6 @@ class WebTest_Admin_CustomAddTest extends CiviSeleniumTestCase { $this->waitForText('crm-notification-container', "Your custom field set '$customGroupTitle' has been added. You can add custom fields now."); //add custom field - alphanumeric text - $this->click('newCustomField'); $this->waitForElementPresent('_qf_Field_cancel-bottom'); $textFieldLabel = 'test_text_field' . substr(sha1(rand()), 0, 3); $this->click("header"); diff --git a/tests/phpunit/WebTest/Admin/CustomAddTestSameField.php b/tests/phpunit/WebTest/Admin/CustomAddTestSameField.php index c46713cbc7..ff7b420877 100644 --- a/tests/phpunit/WebTest/Admin/CustomAddTestSameField.php +++ b/tests/phpunit/WebTest/Admin/CustomAddTestSameField.php @@ -58,12 +58,15 @@ class WebTest_Admin_CustomAddTestSameField extends CiviSeleniumTestCase { $this->click("extends[0]"); $this->select("extends[0]", "label=Contacts"); $this->click("//option[@value='Contact']"); - $this->click("//form[@id='Group']/div[2]/div[3]/span[1]/input"); - $this->waitForPageToLoad($this->getTimeoutMsec()); + $this->clickLink("//form[@id='Group']/div[2]/div[3]/span[1]/input"); //Is custom group created? - $this->assertTrue($this->isTextPresent("Your custom field set '$customGroupTitle' has been added. You can add custom fields now.")); + $this->waitForText('crm-notification-container', "Your custom field set '$customGroupTitle' has been added. You can add custom fields now."); + + $gid = $this->urlArg('gid'); + //add custom field - alphanumeric text + $this->openCiviPage('admin/custom/group/field/add', "reset=1&action=add&gid=$gid"); $textFieldLabel = 'test_text_field'; $this->click("header"); $this->type("label", $textFieldLabel); @@ -106,20 +109,18 @@ class WebTest_Admin_CustomAddTestSameField extends CiviSeleniumTestCase { $this->click("is_searchable"); //clicking save - $this->click("_qf_Field_next_new-bottom"); - $this->waitForPageToLoad($this->getTimeoutMsec()); + $this->clickLink("_qf_Field_next_new-bottom"); //Is custom field created? - $this->assertTrue($this->isTextPresent("Your custom field '$checkboxFieldLabel' has been saved.")); + $this->waitForText('crm-notification-container', "Custom field '$checkboxFieldLabel' has been saved."); //add custom field - alphanumeric text $textFieldLabel = 'test_text_field'; $this->click("header"); $this->type("label", $textFieldLabel); - $this->click("_qf_Field_next_new-bottom"); + $this->clickLink("_qf_Field_next_new-bottom"); // Same group will not contain same custome fields so will show error for this field : - $this->waitForPageToLoad($this->getTimeoutMsec()); $this->click("data_type[0]"); $this->select("data_type[0]", "value=0"); $this->click("//option[@value='0']"); @@ -127,7 +128,7 @@ class WebTest_Admin_CustomAddTestSameField extends CiviSeleniumTestCase { $this->select("data_type[1]", "label=CheckBox"); $this->click("//option[@value='CheckBox']"); //Is custom field created - $this->assertTrue($this->isTextPresent("Custom field '$textFieldLabel' already exists in Database.")); + $this->waitForText('crm-notification-container', "Custom field '$textFieldLabel' already exists in Database."); //create another custom field - Number Radio $this->click("data_type[0]"); @@ -159,11 +160,10 @@ class WebTest_Admin_CustomAddTestSameField extends CiviSeleniumTestCase { $this->click("is_searchable"); //clicking save - $this->click("_qf_Field_next-bottom"); - $this->waitForPageToLoad($this->getTimeoutMsec()); + $this->clickLink("_qf_Field_done-bottom"); //Is custom field created - $this->assertTrue($this->isTextPresent("Your custom field '$radioFieldLabel' has been saved.")); + $this->waitForText('crm-notification-container', "Custom field '$radioFieldLabel' has been saved."); } } diff --git a/tests/phpunit/WebTest/Contact/MultipleContactSubTypes.php b/tests/phpunit/WebTest/Contact/MultipleContactSubTypes.php index 5c64443727..5fc82930e0 100644 --- a/tests/phpunit/WebTest/Contact/MultipleContactSubTypes.php +++ b/tests/phpunit/WebTest/Contact/MultipleContactSubTypes.php @@ -240,9 +240,11 @@ class WebTest_Contact_MultipleContactSubTypes extends CiviSeleniumTestCase { $this->waitForText('crm-notification-container', "Your custom field set '{$customGroupTitle}' has been added."); $gid = $this->urlArg('gid'); + // Add field + $this->openCiviPage('admin/custom/group/field/add', "reset=1&action=add&gid=$gid"); $fieldLabel = "custom_field_for_{$contactSubType}" . substr(sha1(rand()), 0, 4); $this->type('label', $fieldLabel); - $this->click('_qf_Field_next-bottom'); + $this->click('_qf_Field_done-bottom'); $this->waitForPageToLoad($this->getTimeoutMsec()); $customGroupTitle = preg_replace('/\s/', '_', trim($customGroupTitle)); return array($customGroupTitle, $gid); diff --git a/tests/phpunit/WebTest/Contribute/AddPricesetTest.php b/tests/phpunit/WebTest/Contribute/AddPricesetTest.php index c579e79b0b..f8fd446d0a 100644 --- a/tests/phpunit/WebTest/Contribute/AddPricesetTest.php +++ b/tests/phpunit/WebTest/Contribute/AddPricesetTest.php @@ -103,8 +103,8 @@ class WebTest_Contribute_AddPricesetTest extends CiviSeleniumTestCase { */ function _testAddPriceFields(&$fields, &$validateString, $financialType, $dateSpecificFields = FALSE) { $validateStrings[] = $financialType; - $this->click('newPriceField'); - $this->waitForElementPresent('label'); + $sid = $this->urlArg('sid'); + $this->openCiviPage('admin/price/field', "reset=1&action=add&sid=$sid", 'label'); foreach ($fields as $label => $type) { $validateStrings[] = $label; diff --git a/tests/phpunit/WebTest/Contribute/OnBehalfOfOrganization.php b/tests/phpunit/WebTest/Contribute/OnBehalfOfOrganization.php index 70ae4d40d3..5f6cb83f77 100644 --- a/tests/phpunit/WebTest/Contribute/OnBehalfOfOrganization.php +++ b/tests/phpunit/WebTest/Contribute/OnBehalfOfOrganization.php @@ -182,7 +182,7 @@ class WebTest_Contribute_OnBehalfOfOrganization extends CiviSeleniumTestCase { $this->waitForPageToLoad($this->getTimeoutMsec()); //Is custom field created? - $this->assertTrue($this->isTextPresent("Your custom field '$checkboxFieldLabel' has been saved.")); + $this->assertTrue($this->isTextPresent("Custom field '$checkboxFieldLabel' has been saved.")); //create another custom field - Integer Radio $this->click("//a[@id='newCustomField']/span"); @@ -224,7 +224,7 @@ class WebTest_Contribute_OnBehalfOfOrganization extends CiviSeleniumTestCase { $this->waitForPageToLoad($this->getTimeoutMsec()); //Is custom field created - $this->assertTrue($this->isTextPresent("Your custom field '$radioFieldLabel' has been saved.")); + $this->assertTrue($this->isTextPresent("Custom field '$radioFieldLabel' has been saved.")); //add the above custom data to the On Behalf of Profile $this->openCiviPage("admin/uf/group", "reset=1"); @@ -374,11 +374,13 @@ class WebTest_Contribute_OnBehalfOfOrganization extends CiviSeleniumTestCase { // Add membership custom data field to profile $this->waitForElementPresent('_qf_Group_cancel-bottom'); $this->type('title', $profileTitle); - $this->click('_qf_Group_next-bottom'); + $this->clickLink('_qf_Group_next-bottom'); - $this->waitForElementPresent('_qf_Field_cancel-bottom'); $this->assertTrue($this->isTextPresent("Your CiviCRM Profile '{$profileTitle}' has been added. You can add fields to this profile now.")); + $gid = $this->urlArg('gid'); + + $this->openCiviPage('admin/uf/group/field/add', array('action' => 'add', 'reset' => 1, 'gid' => $gid), 'field_name[0]'); $this->select('field_name[0]', "value=Membership"); $this->select('field_name[1]', "label={$checkboxFieldLabel} :: {$customGroupTitle}"); $this->click('field_name[1]'); @@ -813,7 +815,7 @@ class WebTest_Contribute_OnBehalfOfOrganization extends CiviSeleniumTestCase { $this->click('_qf_Field_next-bottom'); $this->waitForPageToLoad($this->getTimeoutMsec()); - $this->assertTrue($this->isTextPresent("Your custom field '$fieldTitle' has been saved.")); + $this->assertTrue($this->isTextPresent("Custom field '$fieldTitle' has been saved.")); $fieldId = $this->urlArg('id', $this->getAttribute("xpath=//div[@id='field_page']/div[2]/table/tbody//tr/td[1][text()='$fieldTitle']/../td[8]/span/a@href")); // Enable CiviCampaign module if necessary @@ -1063,7 +1065,7 @@ class WebTest_Contribute_OnBehalfOfOrganization extends CiviSeleniumTestCase { $this->click('_qf_Field_next-bottom'); $this->waitForPageToLoad($this->getTimeoutMsec()); - $this->assertTrue($this->isTextPresent("Your custom field '$fieldTitle' has been saved.")); + $this->assertTrue($this->isTextPresent("Custom field '$fieldTitle' has been saved.")); $fieldId = $this->urlArg('id', $this->getAttribute("xpath=//div[@id='field_page']/div[2]/table/tbody//tr/td[1]/span[text()='$fieldTitle']/../td[8]/span/a@href")); // Enable CiviCampaign module if necessary diff --git a/tests/phpunit/WebTest/Member/BatchUpdateViaProfileTest.php b/tests/phpunit/WebTest/Member/BatchUpdateViaProfileTest.php index 3bf68a6fec..c92b57d6d0 100644 --- a/tests/phpunit/WebTest/Member/BatchUpdateViaProfileTest.php +++ b/tests/phpunit/WebTest/Member/BatchUpdateViaProfileTest.php @@ -203,10 +203,12 @@ class WebTest_Member_BatchUpdateViaProfileTest extends CiviSeleniumTestCase { $this->waitForElementPresent('_qf_Group_cancel-bottom'); $this->type('title', $profileTitle); $this->click('uf_group_type_Profile'); - $this->click('_qf_Group_next-bottom'); + $this->clickLink('_qf_Group_next-bottom'); - $this->waitForElementPresent('_qf_Field_cancel-bottom'); $this->waitForText('crm-notification-container', "Your CiviCRM Profile '{$profileTitle}' has been added. You can add fields to this profile now."); + $gid = $this->urlArg('gid'); + + $this->openCiviPage('admin/uf/group/field/add', array('action' => 'add', 'reset' => 1, 'gid' => $gid), 'field_name[0]'); $this->select('field_name[0]', "value=Membership"); $this->select('field_name[1]', "label={$customDataParams[0]} :: {$customDataParams[1]}"); diff --git a/tests/phpunit/WebTest/Profile/BatchUpdateTest.php b/tests/phpunit/WebTest/Profile/BatchUpdateTest.php index c9a82d62d7..08bc6182f7 100644 --- a/tests/phpunit/WebTest/Profile/BatchUpdateTest.php +++ b/tests/phpunit/WebTest/Profile/BatchUpdateTest.php @@ -579,19 +579,20 @@ class WebTest_Profile_BatchUpdateTest extends CiviSeleniumTestCase { $this->openCiviPage('admin/uf/group', 'reset=1'); - $this->click('link=Add Profile'); + $this->clickLink('link=Add Profile', '_qf_Group_cancel-bottom'); // Add membership custom data field to profile - $this->waitForElementPresent('_qf_Group_cancel-bottom'); $this->type('title', $profileTitle); - $this->click('_qf_Group_next-bottom'); - $this->waitForElementPresent("xpath=//a/span[text()='Add Field']"); + // Standalone form or directory + $this->click('uf_group_type_Profile'); + + $this->clickLink('_qf_Group_next-bottom'); + $this->waitForText('crm-notification-container', "Your CiviCRM Profile '{$profileTitle}' has been added. You can add fields to this profile now."); - $this->click("xpath=//a/span[text()='Add Field']"); $this->waitForElementPresent("field_name[0]"); - foreach ($customDataArr as $key => $customDataParams) { + foreach ($customDataArr as $customDataParams) { $this->select('field_name[0]', "label={$profileFor}"); $this->select('field_name[1]', "label={$customDataParams[1]} :: {$customDataParams[0]}"); $this->click('field_name[1]'); @@ -600,6 +601,7 @@ class WebTest_Profile_BatchUpdateTest extends CiviSeleniumTestCase { // Clicking save and new $this->click('_qf_Field_next_new-bottom'); $this->waitForText('crm-notification-container', "Your CiviCRM Profile Field '{$customDataParams[1]}' has been saved to '{$profileTitle}'."); + $this->waitForElementPresent("xpath=//select[@id='field_name_1'][@style='display: none;']"); } } @@ -615,8 +617,7 @@ class WebTest_Profile_BatchUpdateTest extends CiviSeleniumTestCase { $this->openCiviPage('admin/custom/group', 'reset=1'); //add new custom data - $this->click("//a[@id='newCustomDataGroup']/span"); - $this->waitForPageToLoad($this->getTimeoutMsec()); + $this->clickLink("//a[@id='newCustomDataGroup']/span"); //fill custom group title $this->click("title"); @@ -629,14 +630,12 @@ class WebTest_Profile_BatchUpdateTest extends CiviSeleniumTestCase { $this->click("//option[@value='']"); } - $this->click('_qf_Group_next-bottom'); - $this->waitForElementPresent("newCustomField"); + $this->clickLink('_qf_Group_next-bottom'); //Is custom group created? $this->waitForText('crm-notification-container', "Your custom field set '{$customGroupTitle}' has been added. You can add custom fields now."); //for checkbox 1 - $this->click("newCustomField"); $this->waitForElementPresent("label"); $checkLabel1 = 'Custom Check One Text_' . substr(sha1(rand()), 0, 4); $this->type('label', $checkLabel1); @@ -660,17 +659,13 @@ class WebTest_Profile_BatchUpdateTest extends CiviSeleniumTestCase { $this->type("options_per_line", 2); //clicking save - $this->click('_qf_Field_done'); - $this->waitForElementPresent("newCustomField"); + $this->click('_qf_Field_next_new-top'); //Is custom field created $this->waitForText('crm-notification-container', "Custom field '$checkLabel1' has been saved."); $returnArray[1] = array($customGroupTitle, $checkLabel1); - $this->waitForElementPresent('newCustomField'); // create another custom field - Integer Radio - $this->clickLink('newCustomField', "_qf_Field_cancel-bottom", FALSE); - //for checkbox 2 $checkLabel2 = 'Custom Check Two Text_' . substr(sha1(rand()), 0, 4); $this->type('label', $checkLabel2); @@ -691,15 +686,12 @@ class WebTest_Profile_BatchUpdateTest extends CiviSeleniumTestCase { $this->type('option_value_3', 3); //clicking save - $this->clickLink('_qf_Field_done', 'newCustomField', FALSE); + $this->click('_qf_Field_next_new-top'); //Is custom field created $this->waitForText('crm-notification-container', "Custom field '$checkLabel2' has been saved."); $returnArray[2] = array($customGroupTitle, $checkLabel2); - // create another custom field - Integer Radio - $this->clickLink('newCustomField', "_qf_Field_cancel-bottom", FALSE); - // create another custom field - Date $dateFieldLabel = 'Custom Date Field' . substr(sha1(rand()), 0, 4); $this->type('label', $dateFieldLabel); @@ -718,15 +710,11 @@ class WebTest_Profile_BatchUpdateTest extends CiviSeleniumTestCase { $this->select('time_format', "value=2"); //clicking save - $this->clickLink('_qf_Field_done', 'newCustomField', FALSE); - + $this->click('_qf_Field_next_new-top'); //Is custom field created $this->waitForText('crm-notification-container', "Custom field '$dateFieldLabel' has been saved."); $returnArray[3] = array($customGroupTitle, $dateFieldLabel); - // create another custom field - Integer Radio - $this->clickLink('newCustomField', "_qf_Field_cancel-bottom", FALSE); - //create rich text editor field $richTextField = 'Custom Rich TextField_' . substr(sha1(rand()), 0, 4); $this->type('label', $richTextField); @@ -735,15 +723,12 @@ class WebTest_Profile_BatchUpdateTest extends CiviSeleniumTestCase { $this->select('data_type[1]', "label=RichTextEditor"); //clicking save - $this->clickLink('_qf_Field_done', 'newCustomField', FALSE); + $this->click('_qf_Field_next_new-top'); //Is custom field created $this->waitForText('crm-notification-container', "Custom field '$richTextField' has been saved."); $returnArray[4] = array($customGroupTitle, $richTextField); - // create another custom field - Integer Radio - $this->clickLink('newCustomField', "_qf_Field_cancel-bottom", FALSE); - //create radio button field //for radio 1 $radioLabel1 = 'Custom Radio One Text_' . substr(sha1(rand()), 0, 4); @@ -765,15 +750,13 @@ class WebTest_Profile_BatchUpdateTest extends CiviSeleniumTestCase { $this->type('option_value_3', 3); //clicking save - $this->clickLink('_qf_Field_done', 'newCustomField', FALSE); + $this->click('_qf_Field_next_new-top'); //Is custom field created $this->waitForText('crm-notification-container', "Custom field '$radioLabel1' has been saved."); $returnArray[5] = array($customGroupTitle, $radioLabel1); - // create another custom field - Integer Radio - $this->clickLink('newCustomField', "_qf_Field_cancel-bottom", FALSE); - + // create another custom field - Alpha Radio //for radio 2 $radioLabel2 = 'Custom Radio Two Text_' . substr(sha1(rand()), 0, 4); $this->type('label', $radioLabel2); diff --git a/tests/phpunit/WebTest/Profile/ProfileAddTest.php b/tests/phpunit/WebTest/Profile/ProfileAddTest.php index 917f25a543..3e72157b3a 100644 --- a/tests/phpunit/WebTest/Profile/ProfileAddTest.php +++ b/tests/phpunit/WebTest/Profile/ProfileAddTest.php @@ -99,14 +99,12 @@ class WebTest_Profile_ProfileAddTest extends CiviSeleniumTestCase { $this->click('is_uf_link'); //click on save - $this->click('_qf_Group_next'); - $this->waitForPageToLoad($this->getTimeoutMsec()); + $this->clickLink('_qf_Group_next'); + + $gid = $this->urlArg('gid'); - //check for profile create - $this->waitForText('crm-notification-container', "Your CiviCRM Profile '{$profileTitle}' has been added. You can add fields to this profile now."); //Add field to profile - $this->waitForElementPresent("xpath=//a/span[text()='Add Field']"); $this->click("xpath=//a/span[text()='Add Field']"); $this->waitForElementPresent("field_name[0]"); $this->click('field_name[0]'); @@ -117,7 +115,7 @@ class WebTest_Profile_ProfileAddTest extends CiviSeleniumTestCase { //click on save $this->click('_qf_Field_next'); - $this->waitForElementPresent("xpath=//a/span[text()='Add Field']"); + sleep(1); // delete the profile $this->openCiviPage('admin/uf/group', 'reset=1'); @@ -163,8 +161,6 @@ class WebTest_Profile_ProfileAddTest extends CiviSeleniumTestCase { 'last_name' => 'Individual', 'email' => 'Contact' ); - $this->waitForElementPresent("xpath=//a/span[text()='Add Field']"); - $this->click("xpath=//a/span[text()='Add Field']"); $this->waitForElementPresent("field_name_0"); foreach ($fields as $field => $type) { $this->click('field_name_0'); @@ -316,7 +312,7 @@ class WebTest_Profile_ProfileAddTest extends CiviSeleniumTestCase { // Wait for "saved" status msg $this->waitForText('crm-notification-container', 'Profile Saved'); - $this->clickLink("xpath=//div[@id='breadcrumb']/div//a[text()='Profiles']"); + $this->openCiviPage("admin/uf/group", "reset=1"); $this->waitForElementPresent("xpath=//div[@class='crm-submit-buttons']/a[@id='newCiviCRMProfile-bottom']"); $this->waitForElementPresent("xpath=//div[@id='user-profiles']/div/div/table/tbody/tr[@id='UFGroup-$id']/td[2]/a"); $this->waitForElementPresent("xpath=//div[@id='user-profiles']/div/div/table/tbody/tr[@id='UFGroup-$id']/td[3]"); diff --git a/tests/phpunit/WebTest/Profile/ProfileCountryState.php b/tests/phpunit/WebTest/Profile/ProfileCountryState.php index cd2fbf5bc7..9d90225a67 100644 --- a/tests/phpunit/WebTest/Profile/ProfileCountryState.php +++ b/tests/phpunit/WebTest/Profile/ProfileCountryState.php @@ -47,6 +47,9 @@ class WebTest_Profile_ProfileCountryState extends CiviSeleniumTestCase { $profileTitle = 'Country state province web test temp'; $this->type('title', $profileTitle); + // Standalone form or directory + $this->click('uf_group_type_Profile'); + //click on save $this->click('_qf_Group_next'); $this->waitForPageToLoad($this->getTimeoutMsec()); @@ -55,7 +58,9 @@ class WebTest_Profile_ProfileCountryState extends CiviSeleniumTestCase { //check for profile create $this->waitForText('crm-notification-container', "Profile '{$profileTitle}' has been added. You can add fields to this profile now."); $gid = $this->urlArg('gid'); + //Add Country field to profile + $this->openCiviPage('admin/uf/group/field/add', array('action' => 'add', 'reset' => 1, 'gid' => $gid), 'field_name[0]'); $this->click('field_name[0]'); $this->select('field_name[0]', 'value=Contact'); $this->click("//option[@value='Contact']"); @@ -112,18 +117,14 @@ class WebTest_Profile_ProfileCountryState extends CiviSeleniumTestCase { $states = CRM_Core_PseudoConstant::stateProvinceForCountry($countryID, 'id'); $stateID = array_rand($states); $this->select("xpath=//form[@id='Edit']/div[2]/div/div/div[2]/select", "value=$countryID"); - sleep(2); - $this->waitForElementPresent("xpath=//form[@id='Edit']/div[2]/div/div[2]/div[2]/select"); + $this->waitForElementPresent("xpath=//form[@id='Edit']/div[2]/div/div[2]/div[2]/select/option[@value=$stateID]"); $this->click("xpath=//form[@id='Edit']/div[2]/div/div[2]/div[2]/select"); $this->select("xpath=//form[@id='Edit']/div[2]/div/div[2]/div[2]/select", "value=$stateID"); $this->clickLink('_qf_Edit_next', NULL); - $this->openCiviPage('admin/uf/group', 'reset=1'); - $this->waitForElementPresent("xpath=//div[@id='user-profiles']/div/div/table/tbody//tr/td/span[text() = '$profileTitle']/../../td[7]/span[2][text()='more']/ul/li[4]/a[text()='Delete']"); - $this->click("xpath=//div[@id='user-profiles']/div/div/table/tbody//tr/td/span[text() = '$profileTitle']/../../td[7]/span[2][text()='more']/ul/li[4]/a[text()='Delete']"); - $this->waitForElementPresent('_qf_Group_next-bottom'); - $this->click('_qf_Group_next-bottom'); - $this->waitForElementPresent('newCiviCRMProfile-bottom'); + // Delete profile + $this->openCiviPage('admin/uf/group', 'action=delete&id=' . $gid, '_qf_Group_next-bottom'); + $this->clickLink('_qf_Group_next-bottom', 'newCiviCRMProfile-bottom'); $this->waitForText('crm-notification-container', "Profile '{$profileTitle}' has been deleted."); $this->openCiviPage("admin/setting/localization", "reset=1", "_qf_Localization_next-bottom"); diff --git a/tests/phpunit/WebTest/Profile/ProfileGroupSubscriptionTest.php b/tests/phpunit/WebTest/Profile/ProfileGroupSubscriptionTest.php index 0c771d4a20..04870f671e 100644 --- a/tests/phpunit/WebTest/Profile/ProfileGroupSubscriptionTest.php +++ b/tests/phpunit/WebTest/Profile/ProfileGroupSubscriptionTest.php @@ -76,7 +76,6 @@ class WebTest_Profile_ProfileGroupSubscriptionTest extends CiviSeleniumTestCase $this->waitForText('crm-notification-container', "Your CiviCRM Profile '{$profileTitle}' has been added. You can add fields to this profile now."); //Add email field to profile - $this->click("xpath=//a/span[text()='Add Field']"); $this->waitForElementPresent("field_name[0]"); $this->click('field_name[0]'); $this->select('field_name[0]', 'value=Contact'); diff --git a/tests/phpunit/WebTest/Profile/SearchTest.php b/tests/phpunit/WebTest/Profile/SearchTest.php index 5fd60341b0..d674e965a8 100644 --- a/tests/phpunit/WebTest/Profile/SearchTest.php +++ b/tests/phpunit/WebTest/Profile/SearchTest.php @@ -67,7 +67,6 @@ class WebTest_Profile_SearchTest extends CiviSeleniumTestCase { $profileId = $this->urlArg('gid'); // Add Last Name field. - $this->click("xpath=//a/span[text()='Add Field']"); $this->waitForElementPresent("field_name[0]"); $this->click('field_name[0]'); $this->select('field_name[0]', 'value=Individual'); @@ -154,8 +153,7 @@ class WebTest_Profile_SearchTest extends CiviSeleniumTestCase { $this->clickLink('_qf_Field_next-bottom', "xpath=//div[@id='field_page']/div[1]/a[4]/span[text()='Use (create mode)']", FALSE); $uselink = explode('?', $this->getAttribute("xpath=//*[@id='field_page']/div[1]/a[4]@href")); - $this->openCiviPage('profile/create', "$uselink[1]", '_qf_Edit_cancel'); - $this->waitForElementPresent('_qf_Edit_next'); + $this->openCiviPage('profile/create', "$uselink[1]", '_qf_Edit_next'); $lastName = substr(sha1(rand()), 0, 7); // Fill Last Name @@ -167,16 +165,16 @@ class WebTest_Profile_SearchTest extends CiviSeleniumTestCase { // fill country, state, county $this->select('country-Primary', "United States"); - // adding sleep gives time for state data - // to get populated in state combo box - sleep(1); + + // wait for state data to be populated + $this->waitForElementPresent("xpath=//select[@id='state_province-Primary']/option[text()='California']"); $this->select('state_province-Primary', "California"); - // adding sleep gives time for county data - // to get populated in county combo box - sleep(1); + + // wait for county data to be populated + $this->waitForElementPresent("xpath=//select[@id='county-Primary']/option[text()='Alameda']"); $this->select('county-Primary', "Alameda"); - $this->click('_qf_Edit_next'); - $this->waitForPageToLoad($this->getTimeoutMsec()); + + $this->clickLink('_qf_Edit_next', NULL); $this->assertElementContainsText("css=span.msg-text", 'Your information has been saved.'); @@ -192,19 +190,18 @@ class WebTest_Profile_SearchTest extends CiviSeleniumTestCase { // Fill state, county, country $this->select('country-Primary', "United States"); - // adding sleep gives time for state data - // to get populated in state combo box - sleep(1); + + // wait for state data to be populated + $this->waitForElementPresent("xpath=//select[@id='state_province-Primary']/option[text()='California']"); $this->select('state_province-Primary', "California"); - // adding sleep gives time for county data - // to get populated in county combo box - sleep(1); + + // wait for county data to be populated + $this->waitForElementPresent("xpath=//select[@id='county-Primary']/option[text()='Alameda']"); $this->select('county-Primary', "Alameda"); // Select Custom option $this->select('custom_1', 'Education'); - $this->click('_qf_Search_refresh'); - $this->waitForPageToLoad($this->getTimeoutMsec()); + $this->clickLink('_qf_Search_refresh', NULL); // Verify Data. $this->assertTrue($this->isElementPresent("xpath=//table/tbody/tr[2]/td[2][text()='$lastName']")); @@ -216,18 +213,12 @@ class WebTest_Profile_SearchTest extends CiviSeleniumTestCase { $this->assertTrue($this->isElementPresent("xpath=//table/tbody/tr[2]/td[8][text()='Alameda']")); // Go back to Profile fields admin - $this->openCiviPage('admin/uf/group/field', "reset=1&action=browse&gid=$profileId"); + $this->openCiviPage('admin/uf/group/field', "reset=1&action=browse&gid=$profileId", "xpath=//table/tbody/tr[1]/td[9]"); // Edit first profile field - $this->waitForElementPresent("xpath=//table/tbody/tr[1]/td[9]"); $this->clickLink("xpath=//table/tbody/tr[1]/td[9]/span[1]/a[1]", '_qf_Field_next-bottom', FALSE); - // sleep 5 to make sure jQuery is not hiding field after page load - // 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 - sleep(5); - $this->assertTrue($this->isElementPresent("visibility"), 'Visibility field not present when editing existing profile field.'); + $this->waitForElementPresent("visibility"); $this->click("xpath=//tr[@id='profile_visibility']/td[1]/a"); $this->waitForElementPresent("xpath=//div[@id='crm-notification-container']/div/div[2]/p[2]"); $this->waitForText('crm-notification-container', 'Is this field hidden from other users'); -- 2.25.1