Webtest Fix
authorRohan Katkar <rohan.katkar@webaccessglobal.com>
Fri, 12 Sep 2014 12:48:40 +0000 (18:18 +0530)
committerRohan Katkar <rohan.katkar@webaccessglobal.com>
Fri, 12 Sep 2014 12:48:40 +0000 (18:18 +0530)
tests/phpunit/WebTest/Campaign/PetitionUsageScenarioTest.php
tests/phpunit/WebTest/Campaign/SurveyUsageScenarioTest.php

index 5e903e1a555094f4f380ac062e4215a396b99311..c0768853491537077f20d6ad32596977daf6cf61 100644 (file)
@@ -79,9 +79,8 @@ class WebTest_Campaign_PetitionUsageScenarioTest extends CiviSeleniumTestCase {
     $this->type("description", "This is a test campaign");
 
     // include groups for the campaign
-    $this->addSelection("includeGroups-f", "label=Advisory Board");
+    $this->addSelection("includeGroups", "label=Advisory Board");
     $this->click("//option[@value=4]");
-    $this->click("add");
 
     // fill the end date for campaign
     $this->webtestFillDate("end_date", "+1 year");
@@ -117,15 +116,13 @@ class WebTest_Campaign_PetitionUsageScenarioTest extends CiviSeleniumTestCase {
     $this->waitForText('crm-notification-container', "Petition has been saved.");
 
     $this->waitForElementPresent("link=Add Petition");
-
-    $this->waitForElementPresent("petitions");
+    $this->waitForElementPresent("search_form_petition");
     $this->click("search_form_petition");
     $this->type("petition_title", $title);
 
     $this->click("xpath=//div[@class='crm-accordion-body']/table/tbody/tr[2]/td/a[text()='Search']");
-
-    $this->waitForElementPresent("xpath=//div[@id='petitions_wrapper']/table[@id='petitions']/tbody/tr/td[10]/span[2][text()='more']/ul/li/a[text()='Sign']");
-    $url = $this->getAttribute("xpath=//div[@id='petitions_wrapper']/table[@id='petitions']/tbody/tr/td[10]/span[2][text()='more']/ul/li/a[text()='Sign']@href");
+    $this->waitForElementPresent("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody/tr/td[10]/span[2][text()='more']/ul/li[2]/a[text()='Sign']");
+    $url = $this->getAttribute("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody/tr/td[10]/span[2][text()='more']/ul/li[2]/a[text()='Sign']@href");
 
     ////////////// Retrieve Sign Petition Url /////////////////////////
 
@@ -158,13 +155,13 @@ class WebTest_Campaign_PetitionUsageScenarioTest extends CiviSeleniumTestCase {
     $this->openCiviPage("campaign", "reset=1&subPage=petition", "link=Add Petition");
 
     // check for unconfirmed petition signature
-    $this->waitForElementPresent("petitions");
+    $this->waitForElementPresent("search_form_petition");
     $this->click("search_form_petition");
     $this->type("petition_title", $title);
     $this->click("xpath=//div[@class='crm-accordion-body']/table/tbody/tr[2]/td/a[text()='Search']");
 
-    $this->waitForElementPresent("xpath=//div[@id='petitions_wrapper']/table[@id='petitions']/tbody/tr/td[10]/span[2][text()='more']");
-    $this->click("xpath=//div[@id='petitions_wrapper']/table[@id='petitions']/tbody/tr/td[10]/span[2][text()='more']/ul/li/a[text()='Signatures']");
+    $this->waitForElementPresent("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody/tr/td[10]/span[2][text()='more']");
+    $this->click("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody/tr/td[10]/span[2][text()='more']/ul/li[3]/a[text()='Signatures']");
     $this->waitForPageToLoad($this->getTimeoutMsec());
 
     // verify tabular data
@@ -210,14 +207,14 @@ class WebTest_Campaign_PetitionUsageScenarioTest extends CiviSeleniumTestCase {
 
     $this->waitForElementPresent("link=Add Petition");
 
-    $this->waitForElementPresent("petitions");
+    $this->waitForElementPresent("search_form_petition");
     $this->click("search_form_petition");
     $this->type("petition_title", $title);
 
     $this->click("xpath=//div[@class='crm-accordion-body']/table/tbody/tr[2]/td/a[text()='Search']");
 
-    $this->waitForElementPresent("xpath=//div[@id='petitions_wrapper']/table[@id='petitions']/tbody/tr/td[10]/span[2][text()='more']/ul/li/a[text()='Sign']");
-    $url = $this->getAttribute("xpath=//div[@id='petitions_wrapper']/table[@id='petitions']/tbody/tr/td[10]/span[2][text()='more']/ul/li/a[text()='Sign']@href");
+    $this->waitForElementPresent("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody/tr/td[10]/span[2][text()='more']/ul/li[2]/a[text()='Sign']");
+    $url = $this->getAttribute("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody/tr/td[10]/span[2][text()='more']/ul/li[2]/a[text()='Sign']@href");
 
     // logout and sign as anonymous.
     $this->webtestLogout();
@@ -251,13 +248,13 @@ class WebTest_Campaign_PetitionUsageScenarioTest extends CiviSeleniumTestCase {
     $this->openCiviPage("campaign", "reset=1&subPage=petition", "link=Add Petition");
 
     // check for confirmed petition signature
-    $this->waitForElementPresent("petitions");
+    $this->waitForElementPresent("search_form_petition");
     $this->click("search_form_petition");
     $this->type("petition_title", $title);
     $this->click("xpath=//div[@class='crm-accordion-body']/table/tbody/tr[2]/td/a[text()='Search']");
 
-    $this->waitForElementPresent("xpath=//div[@id='petitions_wrapper']/table[@id='petitions']/tbody/tr/td[10]/span[2][text()='more']");
-    $this->click("xpath=//div[@id='petitions_wrapper']/table[@id='petitions']/tbody/tr/td[10]/span[2][text()='more']/ul/li/a[text()='Signatures']");
+    $this->waitForElementPresent("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody/tr/td[10]/span[2][text()='more']");
+    $this->click("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody/tr/td[10]/span[2][text()='more']/ul/li[3]/a[text()='Signatures']");
     $this->waitForPageToLoad($this->getTimeoutMsec());
 
     // verify tabular data
index 5b51d103ff8c990191d3a52664f5fbffc4ba7cd9..ceb453b56e7ab9cda69365e4dffec016cdfef834 100644 (file)
@@ -358,10 +358,12 @@ class WebTest_Campaign_SurveyUsageScenarioTest extends CiviSeleniumTestCase {
     $this->type('title', "$customGroup");
     $this->select('extends[0]', "value=Contact");
     $this->click('_qf_Group_next-bottom');
-    $this->waitForElementPresent('_qf_Field_cancel-bottom');
+    $this->waitForElementPresent('newCustomField');
     $this->waitForText('crm-notification-container', $customGroup);
 
     // Add custom fields
+    $this->click('newCustomField');
+    $this->waitForElementPresent("xpath=//div[@class='ui-dialog-buttonset']/button[3]/span[2]");
     $field1 = "Checkbox $title";
     $this->type('label', $field1);
     $this->select('data_type[1]', "value=CheckBox");
@@ -385,9 +387,9 @@ class WebTest_Campaign_SurveyUsageScenarioTest extends CiviSeleniumTestCase {
     $this->type('option_label_3', $label3);
     $this->type('option_value_3', $value3);
 
-    $this->click('_qf_Field_next-bottom');
-    $this->waitForPageToLoad($this->getTimeoutMsec());
-    $this->waitForText('crm-notification-container', $field1);
+    $this->click("xpath=//*[@id='_qf_Field_done-bottom']");
+    $this->waitForElementPresent('newCustomField');
+    $this->isElementPresent("xpath=//table[@id='options']/tbody//tr/td[1]/span[text()='{$field1}']");
 
     // Create a profile for survey
     $this->openCiviPage("admin/uf/group", "reset=1");
@@ -398,40 +400,49 @@ class WebTest_Campaign_SurveyUsageScenarioTest extends CiviSeleniumTestCase {
     $surveyProfile = "Survey Profile $title";
     $this->type('title', $surveyProfile);
     $this->click('_qf_Group_next-bottom');
-    $this->waitForElementPresent('_qf_Field_cancel-bottom');
+    $this->waitForElementPresent("xpath=//div[@id='crm-main-content-wrapper']/div/div[2]/a/span");
     $this->waitForText('crm-notification-container', $surveyProfile);
 
     // Add fields to the profile
     // Phone ( Primary )
+    $this->click("xpath=//div[@id='crm-main-content-wrapper']/div/div[2]/a/span");
+    $this->waitForElementPresent('field_name[0]');
     $this->select('field_name[0]', "value=Contact");
+    $this->waitForElementPresent('field_name[1]');
     $this->select('field_name[1]', "value=phone");
     $this->click('field_name[1]');
     $this->select('visibility', "value=Public Pages and Listings");
     $this->check('is_searchable');
     $this->check('in_selector');
-    $this->clickLink('_qf_Field_next_new-bottom', '_qf_Field_cancel-bottom');
+    $this->waitForElementPresent("xpath=//div[@class='ui-dialog-buttonset']/button[2]/span[2]");
+    $this->click("xpath=//div[@class='ui-dialog-buttonset']/button[2]/span[2]");
 
     // Custom Data Fields
+    $this->waitForElementPresent("xpath=//select[@id='field_name_1'][@style='display: none;']");
     $this->select('field_name[0]', "value=Contact");
+    $this->waitForElementPresent('field_name[1]');
     $this->select('field_name[1]', "label=$field1 :: $customGroup");
     $this->click('field_name[1]');
     $this->select('visibility', "value=Public Pages and Listings");
     $this->check('is_searchable');
     $this->check('in_selector');
-    $this->click('_qf_Field_next-bottom');
-    $this->waitForPageToLoad($this->getTimeoutMsec());
+    $this->click("xpath=//div[@class='ui-dialog-buttonset']/button[1]/span[2]");
+    $this->waitForElementPresent("xpath=//table[@id='options']");
+    $this->isElementPresent("xpath=//table[@id='options']/tbody//tr/td[1]/span", $field1);
 
     // Create a survey
     $this->openCiviPage("survey/add", "reset=1", "_qf_Main_upload-bottom");
 
     // fill in a unique title for the survey
     $surveyTitle = "Survey $title";
+    $this->waitForElementPresent('title');
     $this->type('title', $surveyTitle);
 
     // select the created campaign
     //$this->select("campaign_id", "label=Campaign $title");
 
     // select the activity type
+    $this->waitForElementPresent('activity_type_id');
     $this->select("activity_type_id", "label=Survey");
 
     // fill in reserve survey respondents
@@ -481,14 +492,16 @@ class WebTest_Campaign_SurveyUsageScenarioTest extends CiviSeleniumTestCase {
     $this->waitForElementPresent("//select[@id='group']/option[text()='$groupName']");
 
     // select group
+    $this->waitForElementPresent('group');
     $this->click('group');
+    $this->waitForElementPresent('group');
     $this->select('group', "label=$groupName");
     $this->click('_qf_Search_refresh');
 
-    $this->waitForElementPresent('Go');
-    $this->click("CIVICRM_QFID_ts_all_4");
+    $this->waitForElementPresent('toggleSelect');
+    $this->click('toggleSelect');
     $this->select('task', "Reserve Respondents");
-    $this->click("Go");
+
     $this->waitForElementPresent('_qf_Reserve_done_reserve-bottom');
 
     $this->clickLink('_qf_Reserve_done_reserve-bottom', 'access');
@@ -531,17 +544,25 @@ class WebTest_Campaign_SurveyUsageScenarioTest extends CiviSeleniumTestCase {
     //$this->waitForElementPresent("xpath=//ul[@id='crmasmList1']/li");
     $this->click('_qf_Search_refresh');
 
-    $this->waitForElementPresent('Go');
     //$this->click("xpath=//*[@class='selector']//tbody//tr[@id='rowid{$id1}']/td[1]");
-    $this->click("mark_x_{$id1}");
-    $this->click("Go");
+    $this->waitForElementPresent("xpath=//table[@class='selector row-highlight']/tbody//tr[@id='rowid{$id1}']/td/input");
+    $this->click("xpath=//table[@class='selector row-highlight']/tbody//tr[@id='rowid{$id1}']/td/input");
+    $this->waitForElementPresent('task');
+    $this->select('task', "Record Survey Responses");
     $this->waitForElementPresent('_qf_Interview_cancel_interview');
 
+    $this->waitForElementPresent("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody/tr[@id='row_{$id1}']/td[6]/input[@type='text']");    
+
     $this->type("field_{$id1}_phone-Primary-1", 9876543210);
-    $this->click("//table[@id='voterRecords']/tbody//tr[@id='row_{$id1}']/td[7]/input[2]/../label[text()='$label1']");
-    $this->click("//table[@id='voterRecords']/tbody//tr[@id='row_{$id1}']/td[7]/input[6]/../label[text()='$label2']");
+    $this->waitForElementPresent("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody/tr[@id='row_{$id1}']/td[7]/input[2]/../label[text()='$label1']");
+    $this->click("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody/tr[@id='row_{$id1}']/td[7]/input[2]/../label[text()='$label1']");
+
+    $this->waitForElementPresent("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody/tr[@id='row_{$id1}']/td[7]/input[4]/../label[text()='$label2']");
+    $this->click("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody/tr[@id='row_{$id1}']/td[7]/input[6]/../label[text()='$label2']");
+
     $this->select("field_{$id1}_result", $optionLabel1);
-    $this->click("interview_voter_button_{$id1}");
+    $this->click("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody/tr[@id='row_{$id1}']/td[10]/a");
+    $this->click('_qf_Interview_cancel_interview');
     // 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
@@ -584,19 +605,21 @@ class WebTest_Campaign_SurveyUsageScenarioTest extends CiviSeleniumTestCase {
     //$this->click("xpath=//div[@id='search_form_gotv']/div[2]/table/tbody/tr[6]/td/a[text()='Search']");
     $this->click("link=Search");
 
-    $this->waitForElementPresent("xpath=//table[@id='gotvVoterRecords']/tbody/tr/td[7]");
-    $this->check("xpath=//table[@id='gotvVoterRecords']/tbody/tr/td[7]/input");
+    $this->waitForElementPresent("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody/tr/td[7]/input");
+    $this->click("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody/tr/td[7]/input");
 
     // Check title of the activities created
     $this->openCiviPage("activity/search", "reset=1", '_qf_Search_refresh');
+    $this->waitForElementPresent('activity_survey_id');
     $this->select('activity_survey_id', "label=$surveyTitle");
     $this->click('_qf_Search_refresh');
     $this->waitForPageToLoad($this->getTimeoutMsec());
 
-    $this->verifyText("xpath=//table/tbody//tr/td[5]/a[text()='Smith, $firstName1']/../../td[3]",
+    $this->waitForElementPresent("xpath=//table[@class='selector row-highlight']");
+    $this->verifyText("xpath=//table[@class='selector row-highlight']/tbody//tr/td[5]/a[text()='Smith, $firstName1']/../../td[3]",
       preg_quote("$surveyTitle - Respondent Interview")
     );
-    $this->verifyText("xpath=//table/tbody//tr/td[5]/a[text()='John, $firstName2']/../../td[3]",
+    $this->verifyText("xpath=//table[@class='selector row-highlight']/tbody//tr/td[5]/a[text()='John, $firstName2']/../../td[3]",
       preg_quote("$surveyTitle - Respondent Reservation")
     );
   }