Webtest fixes for profile/custom-field/price-set
authorColeman Watts <coleman@civicrm.org>
Tue, 16 Sep 2014 03:41:57 +0000 (23:41 -0400)
committerColeman Watts <coleman@civicrm.org>
Tue, 16 Sep 2014 03:41:57 +0000 (23:41 -0400)
12 files changed:
tests/phpunit/CiviTest/CiviSeleniumTestCase.php
tests/phpunit/WebTest/Admin/CustomAddTest.php
tests/phpunit/WebTest/Admin/CustomAddTestSameField.php
tests/phpunit/WebTest/Contact/MultipleContactSubTypes.php
tests/phpunit/WebTest/Contribute/AddPricesetTest.php
tests/phpunit/WebTest/Contribute/OnBehalfOfOrganization.php
tests/phpunit/WebTest/Member/BatchUpdateViaProfileTest.php
tests/phpunit/WebTest/Profile/BatchUpdateTest.php
tests/phpunit/WebTest/Profile/ProfileAddTest.php
tests/phpunit/WebTest/Profile/ProfileCountryState.php
tests/phpunit/WebTest/Profile/ProfileGroupSubscriptionTest.php
tests/phpunit/WebTest/Profile/SearchTest.php

index 4955b22775af3d5e71e6b98020128968f712126c..e99f4630e234d0c7cb7baa9c915f18c0045f31a1 100644 (file)
@@ -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');
index fb0c220989f9594d72866fdf0ed77d5d5baed267..476135b015cd633852299ee5ceda7f5600980804 100644 (file)
@@ -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");
index c46713cbc73312867f60c68b1a4e72a114c76acc..ff7b420877bef26cd96761f21775c86b2a2b148c 100644 (file)
@@ -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.");
 
   }
 }
index 5c64443727be6355b5fe72c257a1245faf843b84..5fc82930e0c405a881cada7524e1bec731b38a20 100644 (file)
@@ -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);
index c579e79b0b878eb4d8f1c4147921829335323bc5..f8fd446d0a6245b01f7d7b5371077c9182ab29fe 100644 (file)
@@ -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;
 
index 70ae4d40d3cb61eb51f0a5b82de1991224b89aa6..5f6cb83f77ea42d32eab65f22e620bef1fc925b0 100644 (file)
@@ -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
index 3bf68a6fec742e206f396d447b1d86a1542819a2..c92b57d6d0f6d17c6b3a0b4f5d2d5827ac6d12df 100644 (file)
@@ -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]}");
index c9a82d62d717f64cbf13f6b77a4dbb9ab7884177..08bc6182f70f5afbf204b32d943094121e094f5f 100644 (file)
@@ -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);
index 917f25a543f66bfcb4916a2eb9b1a0396eae48cb..3e72157b3aed270a9972a2abd3860af0029fefb2 100644 (file)
@@ -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]");
index cd2fbf5bc7f8fa98cf7738c3a9762ad4db99effb..9d90225a67d0c4a9cf76226da293f7f806443260 100644 (file)
@@ -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");
index 0c771d4a203dbbd6b292ee736231fffc88708d8a..04870f671ec7f315c19de3e9d4ab060ed7f5bb27 100644 (file)
@@ -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');
index 5fd60341b0cc4e9573bb345eb8236740bdacb0b0..d674e965a8614d12fe14a4493be7a7cda7004587 100644 (file)
@@ -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');