*/
require_once 'CiviTest/CiviSeleniumTestCase.php';
+
+/**
+ * Class WebTest_Campaign_SurveyUsageScenarioTest
+ */
class WebTest_Campaign_SurveyUsageScenarioTest extends CiviSeleniumTestCase {
protected function setUp() {
$this->webtestLogin();
$this->openCiviPage("campaign/add", "reset=1", "_qf_Campaign_upload-bottom");
-
+ $this->waitForElementPresent('title');
$this->type("title", "Campaign $title");
// select the campaign type
+ $this->waitForElementPresent('campaign_type_id');
$this->select("campaign_type_id", "value=2");
// fill in the description
$this->type("description", "This is a test campaign");
// include groups for the campaign
- $this->addSelection("includeGroups-f", "label=$groupName");
+ $this->addSelection("includeGroups", "label=$groupName");
$this->click("//option[@value=4]");
- $this->click("add");
// fill the end date for campaign
$this->webtestFillDate("end_date", "+1 year");
$this->waitForPageToLoad($this->getTimeoutMsec());
// add a custom field to the custom group
+ $this->waitForElementPresent('label');
$this->type("label", "Field $title");
$this->select("data_type[1]", "value=Radio");
$this->type("option_value_2", "2");
// save the custom field
- $this->click("_qf_Field_next-bottom");
+ $this->click("_qf_Field_done-bottom");
$this->waitForElementPresent("newCustomField");
$this->waitForText('crm-notification-container', "$title");
// save the profile
$this->click("_qf_Group_next-bottom");
- $this->waitForElementPresent("_qf_Field_next-bottom");
- $this->waitForText('crm-notification-container', "$title");
+ $this->waitForElementPresent("xpath=//div[@id='crm-main-content-wrapper']/div/div[2]/a/span");
+ $this->click("xpath=//div[@id='crm-main-content-wrapper']/div/div[2]/a/span");
// add a profile field for activity
+ $this->waitForElementPresent('field_name[0]');
$this->select("field_name[0]", "value=Activity");
$this->waitForElementPresent("field_name[1]");
$this->select("field_name[1]", "label=Field $title :: Group $title");
- $this->click("_qf_Field_next-bottom");
- $this->waitForPageToLoad($this->getTimeoutMsec());
+ $this->waitForElementPresent("xpath=//div[@class='ui-dialog-buttonset']/button[1]/span[2]");
+ $this->click("xpath=//div[@class='ui-dialog-buttonset']/button[1]/span[2]");
$this->waitForText('crm-notification-container', "$title");
// create a survey
$this->select("campaign_survey_id", "label=Survey $title");
$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->click("_qf_Reserve_done_reserve-bottom");
// Interview Respondents
$this->openCiviPage("survey/search", "reset=1&op=interview", "_qf_Search_refresh");
-
// search for the respondents
+ $this->waitForElementPresent('campaign_survey_id');
$this->select("campaign_survey_id", "label=Survey $title");
-
$this->click("_qf_Search_refresh");
- $this->waitForElementPresent("Go");
- $this->click("CIVICRM_QFID_ts_all_4");
- $this->click("Go");
-
+ $this->waitForElementPresent('toggleSelect');
+ $this->click('toggleSelect');
+ $this->select('task', "Record Survey Responses");
$this->waitForElementPresent("_qf_Interview_cancel_interview");
$this->click("CIVICRM_QFID_1_2");
- $this->select("css=#voterRecords .odd .result select", "value=Label $title 1");
- $this->click("css=#voterRecords .odd td a");
+ $this->select("xpath=//table[@class='display crm-copy-fields dataTable no-footer']/tbody/tr[1]/td[8]/select","value=Label $title 1");
+ $this->click("xpath=//table[@class='display crm-copy-fields dataTable no-footer']/tbody/tr[1]/td[9]/a");
$this->click("CIVICRM_QFID_2_8");
- $this->select("css=#voterRecords .even .result select", "value=Label $title 2");
- $this->click("css=#voterRecords .even td a");
+ $this->select("xpath=//table[@class='display crm-copy-fields dataTable no-footer']/tbody/tr[2]/td[8]/select","value=Label $title 2");
+ $this->click("xpath=//table[@class='display crm-copy-fields dataTable no-footer']/tbody/tr[2]/td[9]/a");
$this->click("_qf_Interview_cancel_interview");
$this->waitForPageToLoad($this->getTimeoutMsec());
$this->select("campaign_survey_id", "label=Survey $title");
$this->click("_qf_Search_refresh");
-
- $this->waitForElementPresent("Go");
- $this->click("CIVICRM_QFID_ts_all_4");
+ $this->waitForElementPresent('toggleSelect');
+ $this->click('toggleSelect');
+ $this->waitForElementPresent('task');
$this->select('task', "Reserve Respondents");
- $this->click("Go");
-
$this->waitForElementPresent("_qf_Reserve_done_reserve-bottom");
$this->click("_qf_Reserve_done_reserve-bottom");
- $this->waitForPageToLoad($this->getTimeoutMsec());
$this->waitForText('crm-notification-container', "1 Contact\(s\) have been reserved");
// Release Respondents
$this->select("campaign_survey_id", "label=Survey $title");
$this->click("_qf_Search_refresh");
-
- $this->waitForElementPresent("Go");
- $this->click("xpath=id('mark_x_$id')");
- $this->click("CIVICRM_QFID_ts_sel_2");
+ $this->waitForElementPresent('toggleSelect');
+ $this->click('toggleSelect');
+ $this->waitForElementPresent('task');
$this->select("task", "label=Release Respondents");
- $this->clickLink("Go", "_qf_Release_done-bottom", FALSE);
- $this->clickLink("_qf_Release_done-bottom", 'access', FALSE);
+ $this->waitForElementPresent('_qf_Release_done-bottom');
+ $this->click("_qf_Release_done-bottom");
$this->waitForText('crm-notification-container', "released");
// check whether contact is available for reserving again
// search for the respondents
$this->select("campaign_survey_id", "label=Survey $title");
- $this->click("_qf_Search_refresh");
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->assertTrue($this->isTextPresent("1 Result"), "Result didn't show up after saving!");
+ $this->waitForElementPresent('_qf_Search_refresh');
+ $this->clickLink("_qf_Search_refresh");
+ $this->waitForText("xpath=//div[@id='search-status']/table/tbody/tr[1]/td[1]",'1 Result');
}
function testSurveyReportTest() {
$customGroup = "Custom Group $title";
$this->type('title', "$customGroup");
$this->select('extends[0]', "value=Contact");
- $this->click('_qf_Group_next-bottom');
- $this->waitForElementPresent('_qf_Field_cancel-bottom');
+ $this->clickLink('_qf_Group_next-bottom');
$this->waitForText('crm-notification-container', $customGroup);
// Add custom fields
+ $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");
$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");
$surveyProfile = "Survey Profile $title";
$this->type('title', $surveyProfile);
$this->click('_qf_Group_next-bottom');
- $this->waitForElementPresent('_qf_Field_cancel-bottom');
- $this->waitForText('crm-notification-container', $surveyProfile);
+ $this->waitForText('crm-notification-container', "Your CiviCRM Profile '$surveyProfile' has been added. You can add fields to this profile now.");
// Add fields to the profile
// Phone ( Primary )
+ $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->waitForElementPresent('field_name[0]');
$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
$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');
//$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]");
+ $this->click("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody/tr[@id='row_{$id1}']/td[7]/input[2]");
+ $this->waitForElementPresent("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody/tr[@id='row_{$id1}']/td[7]/input[4]");
+ $this->click("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody/tr[@id='row_{$id1}']/td[7]/input[4]");
+
$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
//$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")
);
}