-- improved webtests
authorRavish Nair <ravish@ravish.(none)>
Fri, 8 Mar 2013 14:12:59 +0000 (19:42 +0530)
committerRavish Nair <ravish@ravish.(none)>
Fri, 8 Mar 2013 14:12:59 +0000 (19:42 +0530)
tests/phpunit/WebTest/Contact/AddCmsUserTest.php
tests/phpunit/WebTest/Contact/AddContactsToEventAdvancedSearchTest.php
tests/phpunit/WebTest/Contact/AddTest.php
tests/phpunit/WebTest/Contact/AddViaProfileTest.php
tests/phpunit/WebTest/Contact/AdvancedSearchTest.php
tests/phpunit/WebTest/Contact/AdvancedSearchedRelatedContactTest.php
tests/phpunit/WebTest/Grant/ContactContextAddTest.php
tests/phpunit/WebTest/Grant/CustomFieldsetTest.php
tests/phpunit/WebTest/Grant/StandaloneAddTest.php

index ae3c11e972151427e90fb4e20082c4ba25374d65..4af9a2a71ba3732a1ef4ce4605a292935de8e8b5 100644 (file)
@@ -76,7 +76,7 @@ class WebTest_Contact_AddCmsUserTest extends CiviSeleniumTestCase {
     $this->waitForElementPresent("edit-submit");
 
     $this->click('edit-user-register-1');
-    $this->click('edit-user-email-verification');
+    $this->check('edit-user-email-verification');
     $this->click('edit-submit');
     $this->waitForPageToLoad($this->getTimeoutMsec());
     // logout
index 83a583b7f3b0de9945b9cd0cf142315a078e27fe..c564b0601c9d331aadf278054de2fc54d3900d84 100644 (file)
@@ -48,9 +48,7 @@ class WebTest_Contact_AddContactsToEventAdvancedSearchTest extends CiviSeleniumT
 
 
     // Advanced Search
-    $this->open($this->sboxPath . 'civicrm/contact/search/advanced?reset=1');
-
-    $this->waitForElementPresent('_qf_Advanced_refresh');
+    $this->openCiviPage('contact/search/advanced', 'reset=1', '_qf_Advanced_refresh');
     $this->click('_qf_Advanced_refresh');
 
     $this->waitForElementPresent('CIVICRM_QFID_ts_all_8');
@@ -72,7 +70,7 @@ class WebTest_Contact_AddContactsToEventAdvancedSearchTest extends CiviSeleniumT
     // Setting registration source
     $this->type('source', 'Event StandaloneAddTest Webtest');
 
-    $this->assertTrue($this->isTextPresent('Source for this registration (if applicable).'));
+    $this->assertElementContainsText('css=tr.crm-participant-form-block-source span.description', 'Source for this registration (if applicable).');
 
 
     // Clicking save.
index acb29300d369d01d6afb660be8e72da07af3437d..7828ecc157f05f6da5fdb7b2e83d7d98c4ba9da6 100644 (file)
@@ -102,7 +102,7 @@ class WebTest_Contact_AddTest extends CiviSeleniumTestCase {
     $this->click("address_1_country_id");
     $this->select("address_1_country_id", "value=" . $this->webtestGetValidCountryID());
 
-    if ($this->isTextPresent("Latitude")) {
+    if($this->assertElementContainsText('address_1', "Latitude")) {    
       $this->type("address_1_geo_code_1", "1234");
       $this->type("address_1_geo_code_2", "5678");
     }
@@ -117,7 +117,7 @@ class WebTest_Contact_AddTest extends CiviSeleniumTestCase {
     $this->click("address_2_country_id");
     $this->select("address_2_country_id", "value=" . $this->webtestGetValidCountryID());
 
-    if ($this->isTextPresent("Latitude")) {
+    if($this->assertElementContainsText('address_2', "Latitude")) {
       $this->type("address_2_geo_code_1", "1234");
       $this->type("address_2_geo_code_2", "5678");
     }
@@ -147,7 +147,7 @@ class WebTest_Contact_AddTest extends CiviSeleniumTestCase {
     $this->waitForElementPresent("subject");
     $this->type("subject", "test note");
     $this->type("note", "this is a test note contact webtest");
-    $this->assertTrue($this->isTextPresent("Subject\n Notes"));
+    $this->assertElementContainsText('notesBlock', "Subject\n Notes");
 
     //Demographics section
     $this->click("//div[@class='crm-accordion-header' and contains(.,'Demographics')]");
@@ -200,7 +200,7 @@ class WebTest_Contact_AddTest extends CiviSeleniumTestCase {
 
 
     //fill in IM
-    $this->assertTrue($this->isTextPresent("Yahoo MSN AIM GTalk Jabber Skype"));
+    $this->assertElementContainsText('im_1_provider_id', "Yahoo MSN AIM GTalk Jabber Skype");
     $this->type("im_1_name", "testSkype");
     $this->select("im_1_location_type_id", "value=3");
     $this->select("im_1_provider_id", "value=6");
@@ -232,7 +232,7 @@ class WebTest_Contact_AddTest extends CiviSeleniumTestCase {
     $this->click("address_1_country_id");
     $this->select("address_1_country_id", "value=" . $this->webtestGetValidCountryID());
 
-    if ($this->isTextPresent("Latitude")) {
+    if ($this->assertElementContainsText('address_1', "Latitude")) {
       $this->type("address_1_geo_code_1", "1234");
       $this->type("address_1_geo_code_2", "5678");
     }
@@ -284,7 +284,7 @@ class WebTest_Contact_AddTest extends CiviSeleniumTestCase {
     $this->click("_qf_Display_next-bottom");
     $this->waitForPageToLoad($this->getTimeoutMsec());
     // Go directly to the URL of the screen that you will be testing (New Organization).
-    $this->open($this->sboxPath . "civicrm/contact/add?reset=1&ct=Organization");
+    $this->openCiviPage('contact/add', 'reset=1&ct=Organization');
 
     //contact details section
     //fill in Organization name
@@ -337,7 +337,7 @@ class WebTest_Contact_AddTest extends CiviSeleniumTestCase {
     $this->click("address_1_country_id");
     $this->select("address_1_country_id", "value=" . $this->webtestGetValidCountryID());
 
-    if ($this->isTextPresent("Latitude")) {
+    if ($this->assertElementContainsText('address_1', "Latitude")) {
       $this->type("address_1_geo_code_1", "1234");
       $this->type("address_1_geo_code_2", "5678");
     }
@@ -433,8 +433,7 @@ class WebTest_Contact_AddTest extends CiviSeleniumTestCase {
     $this->click("_qf_Edit_next");
 
     // Is new contact created?
-    $this->assertTrue(
-      $this->isTextPresent("$currentEmployer has been created."),
+    $this->assertElementContainsText('crm-notification-container', "$currentEmployer has been created.",
       "Status message didn't show up after saving!"
     );
 
@@ -466,8 +465,7 @@ class WebTest_Contact_AddTest extends CiviSeleniumTestCase {
     $this->click("_qf_Edit_next");
 
     // Is new contact created?
-    $this->assertTrue(
-      $this->isTextPresent("$sharedHousehold has been created."),
+    $this->assertElementContainsText('crm-notification-container', "$sharedHousehold has been created.",
       "Status message didn't show up after saving!"
     );
 
@@ -478,20 +476,21 @@ class WebTest_Contact_AddTest extends CiviSeleniumTestCase {
     $this->click("_qf_Contact_upload_view");
     $this->waitForPageToLoad($this->getTimeoutMsec());
     $name = $this->getText("xpath=//div[@class='crm-summary-display_name']");
-    $this->assertTrue($this->isTextPresent("$name has been created."));
+    $this->assertElementContainsText('crm-notification-container',  "$name has been created.");
 
     //make sure current employer is set
     $this->verifyText("xpath=id('contactinfo-block')/div/div/div[2]/div", 'Employer');
     $this->verifyText("xpath=id('contactinfo-block')/div/div/div[2]/div[2]/a[text()]", $currentEmployer);
 
     //make sure both shared address are set.
-    $this->assertTrue($this->isTextPresent("Address belongs to $currentEmployer"));
-    $this->assertTrue($this->isTextPresent("Address belongs to $sharedHousehold"));
+    $this->assertElementContainsText('address-block-1', "Address belongs to $currentEmployer");
+    $this->assertElementContainsText('address-block-2', "Address belongs to $sharedHousehold");
 
     // make sure relationships are created
     $this->click("xpath=id('tab_rel')/a");
-    $this->isTextPresent('Employee of');
-    $this->isTextPresent('Household Member of');
+    $this->waitForElementPresent('permission-legend');
+    $this->assertElementContainsText('option11', 'Employee of');
+    $this->assertElementContainsText('option11', 'Household Member of');
   }
 }
 
index 86634cf6e64651bda3b17bb14363b0401f293d9a..a50c53985d341112a7e51d73c4481d69f7510de5 100644 (file)
@@ -46,7 +46,7 @@ class WebTest_Contact_AddViaProfileTest extends CiviSeleniumTestCase {
     $this->webtestLogin();
 
     // Go directly to the URL of the screen that you will be testing (Create Profile).
-    $this->open($this->sboxPath . "civicrm/profile/create?reset=1&gid=1");
+    $this->openCiviPage('profile/create', 'reset=1&gid=1', '_qf_Edit_cancel');
 
     $firstName = 'Jo' . substr(sha1(rand()), 0, 4);
     $lastName = 'Ad' . substr(sha1(rand()), 0, 7);
@@ -62,14 +62,14 @@ class WebTest_Contact_AddViaProfileTest extends CiviSeleniumTestCase {
     $this->type("street_address-1", "902C El Camino Way SW");
     $this->type("city-1", "Dumfries");
     $this->type("postal_code-1", "1234");
-    $this->assertTrue($this->isTextPresent("United States"));
+    $this->assertElementContainsText('country-1', "United States");
     $this->select("state_province-1", "value=1019");
 
     // Clicking save.
     $this->click("_qf_Edit_next");
     $this->waitForPageToLoad($this->getTimeoutMsec());
 
-    $this->assertTrue($this->isTextPresent("Your information has been saved."));
+    $this->assertElementContainsText('css=.msg-text', "Your information has been saved.");
   }
 }
 
index f7a2ab3a439b5204139810af66476b9093871fda..bb9f64bb0182169d6ba5be91944c29925aa96e26 100644 (file)
@@ -75,9 +75,10 @@ class WebTest_Contact_AdvancedSearchTest extends CiviSeleniumTestCase {
     $this->waitForElementPresent("css=div#tagtree");
     $this->click("xpath=//ul/li/label[text()=\"$tagName\"]");
     $this->waitForElementPresent("css=.success");
+
     // is status message correct?
     $this->waitForTextPresent("Saved");
-    $this->assertTrue($this->isTextPresent("Saved"));
+    $this->assertElementContainsText('crm-notification-container', "Saved");
 
     // go to event tab and register for event ( auto add activity and contribution )
     $this->click("css=li#tab_participant a");
@@ -95,7 +96,7 @@ class WebTest_Contact_AdvancedSearchTest extends CiviSeleniumTestCase {
     $this->type("trxn_id", "trid$firstName");
     $this->click("_qf_Participant_upload-bottom");
     $this->waitForPageToLoad($this->getTimeoutMsec());
-    $this->assertTrue($this->isTextPresent("Event registration for $firstName adv$firstName has been added"));
+    $this->assertElementContainsText('crm-notification-container', "Event registration for $firstName adv$firstName has been added");
 
     // go to pledge tab and add pledge
     $this->click("css=li#tab_pledge a");
@@ -109,7 +110,7 @@ class WebTest_Contact_AdvancedSearchTest extends CiviSeleniumTestCase {
     $this->click("_qf_Pledge_upload-bottom");
     $this->waitForPageToLoad($this->getTimeoutMsec());
 
-    $this->assertTrue($this->isTextPresent("Pledge has been recorded and the payment schedule has been created."));
+    $this->assertElementContainsText('crm-notification-container', "Pledge has been recorded and the payment schedule has been created.");
 
     // go to Membership tab and add membership
     $this->click("css=li#tab_member a");
@@ -124,7 +125,7 @@ class WebTest_Contact_AdvancedSearchTest extends CiviSeleniumTestCase {
     $this->click("_qf_Membership_upload-bottom");
     $this->waitForPageToLoad($this->getTimeoutMsec());
 
-    $this->assertTrue($this->isTextPresent("Student membership for $firstName adv$firstName has been added"));
+    $this->assertElementContainsText('crm-notification-container', "Student membership for $firstName adv$firstName has been added");
 
     // go to relationship tab and add relationship
     $this->click("css=li#tab_rel a");
@@ -138,12 +139,12 @@ class WebTest_Contact_AdvancedSearchTest extends CiviSeleniumTestCase {
     $this->webtestFillDate("end_date", "+1 day");
     $this->click("details-save");
     $this->waitForPageToLoad($this->getTimeoutMsec());
-    $this->assertTrue($this->isTextPresent("New relationship created."));
+    $this->assertElementContainsText('crm-notification-container', "New relationship created.");
 
     //-------------- advance search --------------
 
     // Go directly to the URL of the screen that you will be testing (Advance Search).
-    $this->open($this->sboxPath . "civicrm/contact/search/advanced?reset=1");
+    $this->openCiviPage('contact/search/advanced', 'reset=1');
 
     //also create a dummy name to test false
     $dummyName = substr(sha1(rand()), 0, 7);
@@ -195,7 +196,7 @@ class WebTest_Contact_AdvancedSearchTest extends CiviSeleniumTestCase {
     $this->type("sort_name", "$dummyName");
     $this->click("_qf_Advanced_refresh");
     $this->waitForElementPresent("css=div.messages");
-    $this->assertTrue($this->isTextPresent("No matches found for"));
+    $this->assertElementContainsText('css=div.messages', "No matches found for");
   }
 
   /*
@@ -204,9 +205,9 @@ class WebTest_Contact_AdvancedSearchTest extends CiviSeleniumTestCase {
   function testActivitySearchByTypeTest() {
     $this->open($this->sboxPath);
     $this->webtestLogin();
-    $this->open($this->sboxPath . "civicrm/contact/search/advanced?reset=1");
+    $this->openCiviPage('contact/search/advanced', 'reset=1');
     $this->click("activity");
-    sleep(2);
+    $this->waitForElementPresent('activity_subject');
     $this->check("xpath=//div[@id='Activity']//div/label[text()='Tell a Friend']/../input");
     $this->click("_qf_Advanced_refresh");
     $this->waitForPageToLoad($this->getTimeoutMsec());
@@ -440,9 +441,7 @@ class WebTest_Contact_AdvancedSearchTest extends CiviSeleniumTestCase {
     // create contact type Individual with subtype
     // with most of values to required to search
     $Subtype = "Student";
-    $this->open($this->sboxPath . "civicrm/contact/add?reset=1&ct=Individual");
-    $this->waitForPageToLoad($this->getTimeoutMsec());
-    $this->waitForElementPresent("_qf_Contact_cancel");
+    $this->openCiviPage('contact/add', 'reset=1&ct=Individual', '_qf_Contact_cancel');
 
     // --- fill few values in Contact Detail block
     $this->type("first_name", "$firstName");
@@ -502,7 +501,7 @@ class WebTest_Contact_AdvancedSearchTest extends CiviSeleniumTestCase {
     // save contact
     $this->click("_qf_Contact_upload_view");
     $this->waitForPageToLoad($this->getTimeoutMsec());
-    $this->assertTrue($this->isTextPresent("$firstName adv$firstName"));
+    $this->assertElementContainsText('css=.crm-summary-display_name', "$firstName adv$firstName");
   }
 }
 
index b9fd6472e9794e7ac103cd952b22cf67af9c8414..95e1e581fd425250255536fbcc38f069816959ba 100644 (file)
@@ -46,7 +46,7 @@ class WebTest_Contact_AdvancedSearchedRelatedContactTest extends CiviSeleniumTes
     $paymentProcessorId = $this->webtestAddPaymentProcessor($processorName);
 
     // Go directly to the URL of the screen that you will be testing (New Event).
-    $this->open($this->sboxPath . "civicrm/event/add?reset=1&action=add");
+    $this->openCiviPage('event/add', 'reset=1&action=add');
 
     $eventTitle = 'My Conference - ' . substr(sha1(rand()), 0, 7);
     $eventDescription = "Here is a description for this conference.";
@@ -56,8 +56,7 @@ class WebTest_Contact_AdvancedSearchedRelatedContactTest extends CiviSeleniumTes
     $this->_testAddLocation($streetAddress);
 
     $this->_testAddFees(FALSE, FALSE, $paymentProcessorId);
-    $this->open($this->sboxPath . "civicrm/event/manage?reset=1");
-    $this->waitForPageToLoad($this->getTimeoutMsec());
+    $this->openCiviPage('event/manage', 'reset=1');
     $this->type('title', $eventTitle);
     $this->click('_qf_SearchEvent_refresh');
     $this->waitForPageToLoad($this->getTimeoutMsec());
@@ -92,8 +91,7 @@ class WebTest_Contact_AdvancedSearchedRelatedContactTest extends CiviSeleniumTes
     $displayName2 = "$firstName2 David";
     $this->_testAddRelationship($sortName2, $sortName, $relType);
 
-    $this->open($this->sboxPath . "civicrm/contact/search?reset=1");
-    $this->waitForElementPresent("_qf_Basic_refresh");
+    $this->openCiviPage('contact/search', 'reset=1', '_qf_Basic_refresh');
     $this->type("sort_name", $sortName);
     $this->select("contact_type", "value=Individual");
     $this->click("_qf_Basic_refresh");
@@ -113,14 +111,13 @@ class WebTest_Contact_AdvancedSearchedRelatedContactTest extends CiviSeleniumTes
     $this->click("_qf_Participant_upload-bottom");
     $this->waitForPageToLoad($this->getTimeoutMsec());
 
-    $this->open($this->sboxPath . "civicrm/contact/search/advanced?reset=1");
-    $this->waitForPageToLoad($this->getTimeoutMsec());
+    $this->openCiviPage('contact/search/advanced', 'reset=1');
 
     $this->type("sort_name", $sortName);
     $this->click('_qf_Advanced_refresh');
     $this->waitForPageToLoad(2 * $this->getTimeoutMsec());
 
-    $this->assertTrue($this->isTextPresent('1 Contact'));
+    $this->assertElementContainsText('search-status', '1 Contact');
 
     $this->click('css=div.crm-advanced_search_form-accordion div.crm-accordion-header');
     $this->select("component_mode", "label=Related Contacts");
@@ -128,7 +125,7 @@ class WebTest_Contact_AdvancedSearchedRelatedContactTest extends CiviSeleniumTes
     $this->click('_qf_Advanced_refresh');
     $this->waitForPageToLoad(2 * $this->getTimeoutMsec());
 
-    $this->assertTrue($this->isTextPresent('2 Contacts'));
+    $this->assertElementContainsText('search-status', '2 Contact');
 
     $this->select("task", "label=Add Contacts to Group");
 
@@ -143,8 +140,8 @@ class WebTest_Contact_AdvancedSearchedRelatedContactTest extends CiviSeleniumTes
     $this->click("_qf_AddToGroup_next-bottom");
     $this->waitForPageToLoad($this->getTimeoutMsec());
 
-    $this->assertTrue($this->isTextPresent("Added Contacts to ".$groupName));
-    $this->assertTrue($this->isTextPresent('2 contacts added to group'));
+    $this->assertElementContainsText('crm-notification-container', "Added Contacts to ".$groupName);
+    $this->assertElementContainsText('crm-notification-container', '2 contacts added to group');
     $this->_testSearchResult($relType);
   }
 
@@ -193,7 +190,7 @@ class WebTest_Contact_AdvancedSearchedRelatedContactTest extends CiviSeleniumTes
 
     // Wait for "saved" status msg
     $this->waitForPageToLoad($this->getTimeoutMsec());
-    $this->waitForTextPresent("'Location' information has been saved.");
+    $this->assertElementContainsText('crm-notification-container', "'Location' information has been saved.");
   }
 
   function _testAddFees($discount = FALSE, $priceSet = FALSE, $processorId) {
@@ -202,7 +199,7 @@ class WebTest_Contact_AdvancedSearchedRelatedContactTest extends CiviSeleniumTes
     $this->waitForElementPresent("_qf_Fee_upload-bottom");
     $this->click("CIVICRM_QFID_1_is_monetary");
     $this->check("payment_processor[{$processorId}]");
-        $this->select("financial_type_id", "value=4");
+    $this->select("financial_type_id", "value=4");
     if ($priceSet) {
       // get one - TBD
     }
@@ -228,8 +225,7 @@ class WebTest_Contact_AdvancedSearchedRelatedContactTest extends CiviSeleniumTes
 
   function _testAddRelationship($ContactName, $relatedName, $relType) {
 
-    $this->open($this->sboxPath . "civicrm/contact/search?reset=1");
-    $this->waitForElementPresent("_qf_Basic_refresh");
+    $this->openCiviPage('contact/search', 'reset=1', '_qf_Basic_refresh');
     $this->type("sort_name", $ContactName);
     $this->select("contact_type", "value=Individual");
     $this->click("_qf_Basic_refresh");
@@ -268,7 +264,7 @@ class WebTest_Contact_AdvancedSearchedRelatedContactTest extends CiviSeleniumTes
     $this->waitForElementPresent("current-relationships");
 
     //check the status message
-    $this->assertTrue($this->isTextPresent("New relationship created."));
+    $this->assertElementContainsText('crm-notification-container', "New 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']");
@@ -280,15 +276,13 @@ class WebTest_Contact_AdvancedSearchedRelatedContactTest extends CiviSeleniumTes
         'Status' => 'Enabled',
       )
     );
-    $this->assertTrue($this->isTextPresent($relType));
+    $this->assertElementContainsText('option11', $relType);
   }
 
   function _testSearchResult($relType) {
 
     //search related contact using Advanced Search
-    $this->open($this->sboxPath . "civicrm/contact/search/advanced?reset=1");
-    $this->waitForPageToLoad($this->getTimeoutMsec());
-    $this->waitForElementPresent("_qf_Advanced_refresh");
+    $this->openCiviPage('contact/search/advanced', 'reset=1', '_qf_Advanced_refresh');
     $this->select("component_mode", "label=Related Contacts");
     $this->select("display_relationship_type", "label={$relType}");
     $this->click("CiviEvent");
@@ -296,7 +290,7 @@ class WebTest_Contact_AdvancedSearchedRelatedContactTest extends CiviSeleniumTes
     $this->type("event_type", "Conference");
     $this->click("_qf_Advanced_refresh");
     $this->waitForPageToLoad($this->getTimeoutMsec());
-    $this->assertTrue($this->isTextPresent('2 Contacts'));
+    $this->assertElementContainsText('search-status', '2 Contacts');
   }
 
  function testAdvanceSearchForLog() {
@@ -326,8 +320,7 @@ class WebTest_Contact_AdvancedSearchedRelatedContactTest extends CiviSeleniumTes
     
 
     //advance search for created contacts
-    $this->open($this->sboxPath . "civicrm/contact/search/advanced?reset=1");
-    $this->waitForElementPresent('_qf_Advanced_refresh');
+    $this->openCiviPage('contact/search/advanced', 'reset=1', '_qf_Advanced_refresh');
     $this->type('sort_name', $lastNameSoft.', '.$firstNameSoft);
     $this->click('changeLog');
     $this->waitForElementPresent("log_date_low");
index 1766ccf7ba44493d80536fe4397587b9dd3873d2..2b5ba9909b426422bb37fceeb95ed661c3693766 100644 (file)
@@ -66,7 +66,7 @@ class WebTest_Grant_ContactContextAddTest extends CiviSeleniumTestCase {
     $this->waitForElementPresent('note');
 
     // check contact name on Grant form
-    $this->assertTrue($this->isTextPresent("$firstName $lastName"));
+    $this->assertElementContainsText('page-title', "$firstName $lastName");
 
     // Let's start filling the form with values.
 
index 9bbbc21e7ddb9e7a1a44e5d8bd607ee11e857dff..369dee37364a6f7936266d4ce1a984233cbebfec 100644 (file)
@@ -47,19 +47,17 @@ class WebTest_Grant_CustomFieldsetTest extends CiviSeleniumTestCase {
     $rand = substr(sha1(rand()), 0, 7);
 
     // Add new Grant Type
-    $this->open($this->sboxPath . 'civicrm/admin/options/grant_type?group=grant_type&reset=1');
-    $this->waitForPageToLoad($this->getTimeoutMsec());
+    $this->openCiviPage('admin/options/grant_type', 'group=grant_type&reset=1');
     $this->click("css=#grant_type > div.action-link > #new > span");
     $this->waitForPageToLoad($this->getTimeoutMsec());
     $grantType = 'GrantType' . $rand;
     $this->type('id=label', $grantType);
     $this->click('id=_qf_Options_next-top');
     $this->waitForPageToLoad($this->getTimeoutMsec());
-    $this->assertTrue($this->isTextPresent("The Grant Type '$grantType' has been saved."));
+    $this->assertElementContainsText('crm-notification-container', "The Grant Type '$grantType' has been saved.");
 
     // Create new Custom Field Set that extends the grant type
-    $this->open($this->sboxPath . 'civicrm/admin/custom/group?reset=1');
-    $this->waitForPageToLoad($this->getTimeoutMsec());
+    $this->openCiviPage('admin/custom/group', 'reset=1');
     $this->click("css=#newCustomDataGroup > span");
     $this->waitForElementPresent('_qf_Group_next-bottom');
     $grantFieldSet = 'Fieldset' . $rand;
@@ -69,7 +67,7 @@ class WebTest_Grant_CustomFieldsetTest extends CiviSeleniumTestCase {
     $this->click('id=collapse_display');
     $this->click('id=_qf_Group_next-bottom');
     $this->waitForElementPresent('_qf_Field_next-bottom');
-    $this->assertTrue($this->isTextPresent("Your custom field set '$grantFieldSet' has been added."));
+    $this->assertElementContainsText('crm-notification-container', "Your custom field set '$grantFieldSet' has been added.");
 
     // Add field to fieldset
     $grantField = 'GrantField' . $rand;
@@ -77,11 +75,10 @@ class WebTest_Grant_CustomFieldsetTest extends CiviSeleniumTestCase {
     $this->select('id=data_type_0', 'label=Money');
     $this->click('id=_qf_Field_next-bottom');
     $this->waitForPageToLoad($this->getTimeoutMsec());
-    $this->assertTrue($this->isTextPresent("Your custom field '$grantField' has been saved."));
+    $this->assertElementContainsText('crm-notification-container', "Your custom field '$grantField' has been saved.");
 
     // Create new Grant
-    $this->open($this->sboxPath . 'civicrm/grant/add?reset=1&action=add&context=standalone');
-    $this->waitForElementPresent('_qf_Grant_upload-bottom');
+    $this->openCiviPage('grant/add', 'reset=1&action=add&context=standalone', '_qf_Grant_upload-bottom');
     $this->select('id=profiles_1', 'label=New Individual');
     $this->waitForElementPresent('_qf_Edit_next');
     $firstName = 'First' . $rand;
@@ -92,7 +89,7 @@ class WebTest_Grant_CustomFieldsetTest extends CiviSeleniumTestCase {
     $this->select('id=status_id', 'label=Approved');
     $this->select('id=grant_type_id', "label=$grantType");
     $this->waitForTextPresent($grantField);
-    $this->assertTrue($this->isTextPresent($grantField));
+    $this->assertElementContainsText($grantFieldSet, $grantField);
     $this->type('id=amount_total', '100.00');
     $this->type("css=div#$grantFieldSet input.form-text", '99.99');
     $this->click('id=_qf_Grant_upload-bottom');
index eee48803f34b7ee8c1bb5c7e00ff9b27feb2bf71..fdc4692fd498c5dbfeafc108010dbac53e07d197 100644 (file)
@@ -48,11 +48,7 @@ class WebTest_Grant_StandaloneAddTest extends CiviSeleniumTestCase {
     $this->changePermissions($permission);
 
     // Go directly to the URL of the screen that you will be testing (New Contribution-standalone).
-    $this->open($this->sboxPath . "civicrm/grant/add?reset=1&context=standalone");
-
-    // As mentioned before, waitForPageToLoad is not always reliable. Below, we're waiting for the submit
-    // button at the end of this page to show up, to make sure it's fully loaded.
-    $this->waitForElementPresent("_qf_Grant_upload");
+    $this->openCiviPage('grant/add', 'reset=1&context=standalone', '_qf_Grant_upload');
 
     // Let's start filling the form with values.
 
@@ -106,16 +102,14 @@ class WebTest_Grant_StandaloneAddTest extends CiviSeleniumTestCase {
     $this->waitForElementPresent("_qf_GrantView_cancel-bottom");
 
     $expected = array(
-      2 => 'Submitted',
-      3 => 'Emergency',
-      8 => '$ 100.00',
-      10 => '$ 90.00',
-      13 => 'Grant Note',
+      'Grant Status' => 'Submitted',
+      'Grant Type' => 'Emergency',
+      'Amount Requested' => '$ 100.00',
+      'Amount Granted' => '$ 90.00',
+      'Notes' => 'Grant Note',
     );
 
-    foreach ($expected as $label => $value) {
-      $this->verifyText("xpath=id('GrantView')/div[2]/table[1]/tbody/tr[$label]/td[2]", preg_quote($value));
-    }
+    $this->webtestVerifyTabularData($expected);
   }
 }