webtests improvements
authorPratik Joshi <pratik.joshi@webaccess.co.in>
Fri, 8 Mar 2013 11:38:15 +0000 (17:08 +0530)
committerPratik Joshi <pratik.joshi@webaccess.co.in>
Fri, 8 Mar 2013 11:38:15 +0000 (17:08 +0530)
tests/phpunit/WebTest/Member/BatchUpdateViaProfileTest.php
tests/phpunit/WebTest/Profile/ProfileGroupSubscriptionTest.php
tests/phpunit/WebTest/Profile/SearchTest.php
tests/phpunit/WebTest/Report/AddTest.php
tests/phpunit/WebTest/Report/DonarReportTest.php

index aaa687437724e76363561bf6b94fb6cbcb97491d..d47791efa3c34c02995beea7b0e9eea0498b488d 100644 (file)
@@ -225,8 +225,8 @@ class WebTest_Member_BatchUpdateViaProfileTest extends CiviSeleniumTestCase {
   function _addCustomData() {
     $customGroupTitle = 'Custom_' . substr(sha1(rand()), 0, 4);
     // Go directly to the URL of the screen that you will be testing (New Custom Group).
-    $this->open($this->sboxPath . "civicrm/admin/custom/group?reset=1");
-
+    $this->openCiviPage('admin/custom/group', 'reset=1');
+    
     //add new custom data
     $this->click("//a[@id='newCustomDataGroup']/span");
     $this->waitForPageToLoad($this->getTimeoutMsec());
index c46e9579d551ee703b7afd31a311d3e15c1b47f4..6b2a08df6acf578783df63a0c23d706462245577 100644 (file)
@@ -47,10 +47,8 @@ class WebTest_Profile_ProfileGroupSubscriptionTest extends CiviSeleniumTestCase
 
     // Go directly to the URL of the screen that you will be
     // testing (Add new profile ).
-    $this->open($this->sboxPath . 'civicrm/admin/uf/group?reset=1');
-
-    $this->waitForPageToLoad($this->getTimeoutMsec());
-
+    $this->openCiviPage('admin/uf/group', 'reset=1');
+    
     $this->click('newCiviCRMProfile-top');
 
     $this->waitForElementPresent('_qf_Group_next-bottom');
@@ -82,7 +80,7 @@ class WebTest_Profile_ProfileGroupSubscriptionTest extends CiviSeleniumTestCase
     $this->waitForPageToLoad($this->getTimeoutMsec());
 
     //check for  profile create
-    $this->assertTrue($this->isTextPresent("Your CiviCRM Profile '$profileTitle' has been added. You can add fields to this profile now"));
+    $this->assertElementContainsText('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('field_name[0]');
@@ -110,12 +108,12 @@ class WebTest_Profile_ProfileGroupSubscriptionTest extends CiviSeleniumTestCase
     $this->waitForPageToLoad($this->getTimeoutMsec());
 
     //now use profile create mode for group subscription
-    $this->click("xpath=id('field_page')/div[1]/a[4]/span");
+    $this->click("xpath=//div[@id='field_page']/div/a[4]/span");
 
     $this->waitForElementPresent('email-Primary');
 
     //check for group field
-    $this->assertTrue($this->isTextPresent('Group(s)'), "Groups field was not found.");
+    $this->assertElementContainsText('crm-profile-block', 'Group(s)', "Groups field was not found.");
 
     //fill the subscription form
     $radomEmail = substr(sha1(rand()), 0, 7) . "@example.com";
@@ -123,20 +121,20 @@ class WebTest_Profile_ProfileGroupSubscriptionTest extends CiviSeleniumTestCase
     $this->type("email-Primary", $radomEmail);
 
     // check advisory group ( may be we should create a separate group to test this)
-    $this->click("group_4");
-
+    $this->click("group_3");
+    
     $this->click('_qf_Edit_next');
 
     $this->waitForPageToLoad($this->getTimeoutMsec());
 
     // assert for subscription message
-    $this->assertTrue($this->isTextPresent("Your subscription request has been submitted for group "), "Subscription message is not shown");
+    $this->assertElementContainsText('messages', "Your subscription request has been submitted for group ", "Subscription message is not shown");
 
     //check if profile is saved
-    $this->assertTrue($this->isTextPresent("Your information has been saved."), "Profile is not saved");
+    $this->assertElementContainsText('css=span.msg-text', 'Your information has been saved.', 'Profile is not saved');
 
     // delete the profile
-    $this->open($this->sboxPath . 'civicrm/admin/uf/group?reset=1');
+    $this->openCiviPage('admin/uf/group', 'reset=1');
     $this->_testdeleteProfile($profileTitle);
   }
 
@@ -147,7 +145,7 @@ class WebTest_Profile_ProfileGroupSubscriptionTest extends CiviSeleniumTestCase
     $this->waitForElementPresent('_qf_Group_next-bottom');
     $this->click('_qf_Group_next-bottom');
     $this->waitForElementPresent('newCiviCRMProfile-bottom');
-    $this->assertTrue($this->isTextPresent("Your CiviCRM Profile '$profileTitle' has been deleted."));
+    $this->assertElementContainsText('crm-notification-container', "Your CiviCRM Profile '{$profileTitle}' has been deleted.");
   }
 }
 
index c2507cee523d1858cb0a731c02f5d1109e226aee..c48eb2616455110e147e42476e31156459d0d064 100644 (file)
@@ -47,10 +47,8 @@ class WebTest_Profile_SearchTest extends CiviSeleniumTestCase {
 
     // Go directly to the URL of the screen where you will be
     // Add new profile.
-    $this->open($this->sboxPath . 'civicrm/admin/uf/group?reset=1');
-
-    $this->waitForPageToLoad($this->getTimeoutMsec());
-
+    $this->openCiviPage('admin/uf/group', 'reset=1');
+    
     $this->click('newCiviCRMProfile-bottom');
 
     $this->waitForElementPresent('_qf_Group_next-bottom');
@@ -64,7 +62,7 @@ class WebTest_Profile_SearchTest extends CiviSeleniumTestCase {
     $this->waitForPageToLoad($this->getTimeoutMsec());
 
     //check for  profile create
-    $this->assertTrue($this->isTextPresent("Your CiviCRM Profile '$profileTitle' has been added. You can add fields to this profile now"));
+    $this->assertElementContainsText('crm-notification-container', "Your CiviCRM Profile '{$profileTitle}' has been added. You can add fields to this profile now.");
 
     // Get profile id (gid) from URL
     $elements = $this->parseURL();
@@ -84,9 +82,9 @@ class WebTest_Profile_SearchTest extends CiviSeleniumTestCase {
     $this->click('_qf_Field_next_new-bottom');
     $this->waitForPageToLoad($this->getTimeoutMsec());
     //check for field add
-    $this->assertTrue($this->isTextPresent("Your CiviCRM Profile Field 'Last Name' has been saved to '$profileTitle'."));
-    $this->assertTrue($this->isTextPresent("You can add another profile field."));
-                                           
+    $this->assertElementContainsText('crm-notification-container', "Your CiviCRM Profile Field 'Last Name' has been saved to '$profileTitle'.");
+    $this->assertElementContainsText('crm-notification-container', 'You can add another profile field.');
+
     // Add Email field.
     $this->click('field_name[0]');
     $this->select('field_name[0]', 'value=Contact');
@@ -101,8 +99,8 @@ class WebTest_Profile_SearchTest extends CiviSeleniumTestCase {
     $this->click('_qf_Field_next_new-bottom');
     $this->waitForPageToLoad($this->getTimeoutMsec());
     //check for field add
-    $this->assertTrue($this->isTextPresent("Your CiviCRM Profile Field 'Email' has been saved to '$profileTitle'."));
-    $this->assertTrue($this->isTextPresent("You can add another profile field."));
+    $this->assertElementContainsText('crm-notification-container', "Your CiviCRM Profile Field 'Email' has been saved to '$profileTitle'.");
+    $this->assertElementContainsText('crm-notification-container', 'You can add another profile field.'); 
 
     // Add Sample Custom Field.
     $this->click('field_name[0]');
@@ -132,7 +130,9 @@ class WebTest_Profile_SearchTest extends CiviSeleniumTestCase {
     // Select Custom option
     $this->click('CIVICRM_QFID_Edu_2');
     $this->click('_qf_Edit_next');
-    $this->isTextPresent('Thank you. Your information has been saved.');
+    $this->waitForPageToLoad($this->getTimeoutMsec());
+
+    $this->assertElementContainsText('css=span.msg-text', 'Your information has been saved.');
 
     // Search Contact via profile.
     $this->waitForElementPresent("xpath=//div[@id='crm-container']//div/a[text()='ยป Back to Listings']");
@@ -146,16 +146,16 @@ class WebTest_Profile_SearchTest extends CiviSeleniumTestCase {
     // Select Custom option
     $this->click('CIVICRM_QFID_Edu_2');
     $this->click('_qf_Search_refresh');
+    $this->waitForPageToLoad($this->getTimeoutMsec());
 
     // Verify Data.
-    $this->waitForElementPresent("xpath=//table/tbody/tr[2]/td[2][text()='$lastName']");
-    $this->waitForElementPresent("xpath=//table/tbody/tr[2]/td[3][text()='$lastName']");
-    $this->waitForElementPresent("xpath=//table/tbody/tr[2]/td[4][text()='jhon@$lastName.com']");
-    $this->waitForElementPresent("xpath=//table/tbody/tr[2]/td[5][text()='Education']");
+    $this->assertTrue($this->isElementPresent("xpath=//table/tbody/tr[2]/td[2][text()='$lastName']"));
+    $this->assertTrue($this->isElementPresent("xpath=//table/tbody/tr[2]/td[3][text()='$lastName']"));
+    $this->assertTrue($this->isElementPresent("xpath=//table/tbody/tr[2]/td[4][text()='jhon@$lastName.com']"));
+    $this->assertTrue($this->isElementPresent("xpath=//table/tbody/tr[2]/td[5][text()='Education']"));
 
     // Go back to Profile fields admin
-    $this->open($this->sboxPath . 'civicrm/admin/uf/group/field?reset=1&action=browse&gid=' . $profileId);
-    $this->waitForPageToLoad($this->getTimeoutMsec());
+    $this->openCiviPage('admin/uf/group/field', "reset=1&action=browse&gid=$profileId");
 
     // Edit first profile field
     $this->waitForElementPresent("xpath=//table/tbody/tr[1]/td[9]");
@@ -170,9 +170,7 @@ class WebTest_Profile_SearchTest extends CiviSeleniumTestCase {
     $this->assertTrue($this->isElementPresent("visibility"), 'Visibility field not present when editing existing profile field.');
     $this->click("xpath=//tr[@id='profile_visibility']/td[1]/a");
     $this->waitForElementPresent("xpath=//div[@id='crm-notification-container']/div/div[2]/p[2]");
-    $this->assertTrue($this->isTextPresent("Is this field hidden from other users"));
+    $this->assertElementContainsText('crm-notification-container', 'Is this field hidden from other users');
     $this->select('visibility', 'value=Public Pages and Listings');
   }
-}
-
-
+}
\ No newline at end of file
index 82a50f7f94481fab23cdeb837028014ae94848e0..792738276f8dab4450f5c91e3fbeb4afc4004189 100644 (file)
@@ -52,11 +52,7 @@ class WebTest_Report_AddTest extends CiviSeleniumTestCase {
     $this->webtestAddContact($firstName, "Anderson", $emailId);
 
     // Go directly to the URL of the screen that you will be testing (New Tag).
-    $this->open($this->sboxPath . "civicrm/report/contact/summary?reset=1");
-
-    // 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_Summary_submit");
+    $this->openCiviPage('report/contact/summary', 'reset=1', '_qf_Summary_submit' );
 
     // enable email field
     $this->click("fields[email]");
@@ -73,14 +69,14 @@ class WebTest_Report_AddTest extends CiviSeleniumTestCase {
     $this->waitForPageToLoad($this->getTimeoutMsec());
 
     // Is filter statistics present?
-    $this->assertTrue($this->isTextPresent("Contains $firstName"), "Statistics did not found!");
-
+    $this->assertElementContainsText("xpath=//tr/th[@class='statistics'][text()='Contact Name']/../td", "Contains $firstName", "Statistics did not found!");
+    
     // Is Contact Name present in result?
-    $this->assertTrue($this->isTextPresent($displayName), "Contact Name did not found!");
+    $this->assertElementContainsText('css=td.crm-report-civicrm_contact_sort_name', $displayName, "Contact Name did not found!");
 
     // Is email Id present on result?
-    $this->assertTrue($this->isTextPresent($emailId), "Email did not found!");
-
+    $this->assertElementContainsText('css=td.crm-report-civicrm_email_email', $emailId, "Email did not found!");
+  
     // check criteria
     $this->click("css=div.crm-report_criteria-accordion div.crm-accordion-header");
     $this->waitForElementPresent("sort_name_value");
@@ -133,24 +129,24 @@ class WebTest_Report_AddTest extends CiviSeleniumTestCase {
     $this->waitForPageToLoad($this->getTimeoutMsec());
 
     // Open report list
-    $this->open($this->sboxPath . "civicrm/report/list?reset=1");
-    $this->waitForPageToLoad($this->getTimeoutMsec());
-
+    $this->openCiviPage('report/list', 'reset=1');
+    
     // Is report is resent in list?
-    $this->assertTrue($this->isTextPresent($reportName));
+    $this->assertElementContainsText('css=table.report-layout', $reportName);
 
     // Visit report
     $this->click("link=$reportName");
     $this->waitForPageToLoad($this->getTimeoutMsec());
 
-    // Is filter statistics present?
-    $this->assertTrue($this->isTextPresent("Contains $firstName"), "Statistics did not found!");
 
+   // Is filter statistics present?
+    $this->assertElementContainsText("xpath=//tr/th[@class='statistics'][text()='Contact Name']/../td", "Contains $firstName", "Statistics did not found!");
+    
     // Is Contact Name present in result?
-    $this->assertTrue($this->isTextPresent($displayName), "Contact Name did not found!");
+    $this->assertElementContainsText('css=td.crm-report-civicrm_contact_sort_name', $displayName, "Contact Name did not found!");
 
     // Is email Id present on result?
-    $this->assertTrue($this->isTextPresent($emailId), "Email did not found!");
+    $this->assertElementContainsText('css=td.crm-report-civicrm_email_email', $emailId, "Email did not found!");
 
     // check report criteria
     $this->click("css=div.crm-report_criteria-accordion div.crm-accordion-header");
index 520dbd7f32f30ab6f8aa4aedcb9ff5f5a652fca7..316cda0fbc56d665719673b896a8d85c7d53c677 100644 (file)
@@ -46,12 +46,8 @@ class WebTest_Report_DonarReportTest extends CiviSeleniumTestCase {
     $this->webtestLogin();
 
     // now create new donar detail report instance
-    $this->open($this->sboxPath . "civicrm/report/contribute/detail?reset=1");
-
-    // 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_Detail_submit");
-
+    $this->openCiviPage('report/contribute/detail', 'reset=1', '_qf_Detail_submit');
+    
     // preview result
     $this->click("_qf_Detail_submit");
     $this->waitForPageToLoad($this->getTimeoutMsec());
@@ -84,11 +80,10 @@ class WebTest_Report_DonarReportTest extends CiviSeleniumTestCase {
     $this->waitForPageToLoad($this->getTimeoutMsec());
 
     // Open report list
-    $this->open($this->sboxPath . "civicrm/report/list?reset=1");
-    $this->waitForPageToLoad($this->getTimeoutMsec());
+    $this->openCiviPage('report/list', 'reset=1');
 
     // Is report is resent in list?
-    $this->assertTrue($this->isTextPresent($reportName));
+    $this->assertElementContainsText('css=div#Contribute > table.report-layout', $reportName);
 
     // Visit report
     $this->click("link=$reportName");
@@ -108,15 +103,13 @@ class WebTest_Report_DonarReportTest extends CiviSeleniumTestCase {
 
     //Is greater than or equal to 100
     //check for criteria
-    $this->assertTrue($this->isTextPresent("Is greater than or equal to 10"), "Criteria is not selected");
+    $this->assertElementContainsText('css=table.statistics-table', "Is greater than or equal to 10", "Criteria is not selected");
 
     //click on next link
-    $this->click("_qf_Detail_submit_print");
+    $this->click("_qf_Detail_submit_save");
     $this->waitForPageToLoad($this->getTimeoutMsec());
 
     // check if criteria still exits
-    $this->assertTrue($this->isTextPresent("Is greater than or equal to 10"), "Criteria is not selected");
+    $this->assertElementContainsText('css=table.statistics-table', "Is greater than or equal to 10", "Criteria is not selected");
   }
-}
-
-
+}
\ No newline at end of file