* opening all civi pages, and using the $args param is also strongly encouraged
* This will make it much easier to run webtests in other CMSs in the future
*/
- function openCiviPage($url, $args = NULL, $waitFor = NULL) {
+ function openCiviPage($url, $args = NULL, $waitFor = 'civicrm-footer') {
// Construct full url with args
// This could be extended in future to work with other CMS style urls
if ($args) {
$added = FALSE;
foreach ((array) $components as $comp) {
if (!in_array($comp, $enabledComponents)) {
+ $this->addSelection("enableComponents-f", "label=$comp");
$this->click("//option[@value='$comp']");
$this->click("add");
$added = TRUE;
$this->webtestLogin(TRUE);
$this->changeAdminLinks();
$this->waitForElementPresent('edit-submit');
- foreach ($permission as $key => $value) {
+ foreach ((array) $permission as $key => $value) {
$this->check($value);
}
$this->click('edit-submit');
$this->open($this->sboxPath . "user/logout");
$this->waitForPageToLoad($this->getTimeoutMsec());
$this->webtestLogin();
- $this->waitForPageToLoad($this->getTimeoutMsec());
}
function addProfile($profileTitle, $profileFields) {
$this->click("_qf_GroupContact_next");
$this->waitForPageToLoad($this->getTimeoutMsec());
+ // Enable CiviCampaign module if necessary
$this->enableComponents(array('CiviCampaign'));
// add the required Drupal permission
- $permissions = array('edit-2-administer-civicampaign');
- $this->changePermissions($permissions);
+ $this->changePermissions(array('edit-2-administer-civicampaign'));
// Go directly to the URL of the screen that you will be testing
$this->openCiviPage("campaign/add", "reset=1", "_qf_Campaign_upload-bottom");
$this->click("_qf_Campaign_upload-bottom");
$this->waitForPageToLoad($this->getTimeoutMsec());
- //$this->assertElementContainsText("crm-notification-container", "$title");
+ $this->assertElementContainsText("crm-notification-container", "$title");
// create a custom data set for activities -> survey
$this->openCiviPage('admin/custom/group', "action=add&reset=1", "_qf_Group_next-bottom");
// save the custom group
$this->click("_qf_Group_next-bottom");
- $this->waitForPageToLoad();
+ $this->waitForPageToLoad($this->getTimeoutMsec());
// add a custom field to the custom group
$this->type("label", "Field $title");
$this->click("_qf_Main_upload-bottom");
$this->waitForElementPresent("_qf_Questions_upload_next-bottom");
- //Select the profile for the survey
+ // Select the profile for the survey
$this->select("//form[@id='Questions']/div[2]/table/tbody/tr[1]/td[2]/div/div/span/select", "label=New Individual");
// select the question created for the survey
$this->waitForElementPresent("_qf_Reserve_done_reserve-bottom");
$this->click("_qf_Reserve_done_reserve-bottom");
$this->waitForPageToLoad($this->getTimeoutMsec());
- $this->assertElementContainsText("crm-notification-container", "3");
+ $this->assertElementContainsText("crm-notification-container", "Contact(s) have been reserved");
// Release Respondents
$this->openCiviPage("survey/search", "reset=1&op=release", "_qf_Search_refresh");
$groupName = $this->WebtestAddGroup();
// Adding contact
- // We're using Quick Add block on the main page for this.
$firstName1 = substr(sha1(rand()), 0, 7);
$this->webtestAddContact($firstName1, "Smith", "$firstName1.smith@example.org");
$url1 = explode('cid=', $this->getLocation());
$this->select('extends[0]', "value=Contact");
$this->click('_qf_Group_next-bottom');
$this->waitForElementPresent('_qf_Field_cancel-bottom');
- $this->assertTrue($this->isTextPresent("Your custom field set '$customGroup' has been added. You can add custom fields now."));
+ $this->assertElementContainsText("crm-notification-container", $customGroup);
// Add custom fields
$field1 = "Checkbox $title";
$this->click('_qf_Field_next-bottom');
$this->waitForPageToLoad($this->getTimeoutMsec());
- $this->assertTrue($this->isTextPresent("Your custom field '$field1' has been saved."));
+ $this->assertElementContainsText("crm-notification-container", $field1);
// Create a profile for survey
$this->openCiviPage("admin/uf/group", "reset=1");
$this->type('title', $surveyProfile);
$this->click('_qf_Group_next-bottom');
$this->waitForElementPresent('_qf_Field_cancel-bottom');
- $this->assertTrue($this->isTextPresent("Your CiviCRM Profile '$surveyProfile' has been added. You can add fields to this profile now. "));
+ $this->assertElementContainsText("crm-notification-container", $surveyProfile);
// Add fields to the profile
// Phone ( Primary )
$this->waitForPageToLoad($this->getTimeoutMsec());
// Enable CiviCampaign module if necessary
- $this->openCiviPage("admin/setting/component", "reset=1");
-
- $this->waitForElementPresent('_qf_Component_next-bottom');
- $enabledComponents = $this->getSelectOptions('enableComponents-t');
- if (!in_array("CiviCampaign", $enabledComponents)) {
- $this->addSelection('enableComponents-f', "label=CiviCampaign");
- $this->click("//option[@value='CiviCampaign']");
- $this->click('add');
- $this->click('_qf_Component_next-bottom');
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->assertTrue($this->isTextPresent('Changes Saved.'));
- }
+ $this->enableComponents(array('CiviCampaign'));
// add the required Drupal permission
$permissions = array('edit-2-administer-civicampaign');
$this->select('campaign_survey_id', "label=$surveyTitle");
// need to wait for Groups field to reload dynamically
- sleep(3);
+ $this->waitForElementPresent("//select[@class='campaignGroupsSelect']/option[text()='$groupName']");
// select group
$this->click('campaignGroupsSelect1');
$this->waitForPageToLoad($this->getTimeoutMsec());
// wait for Access Keys div to appear at bottom of page - since this page may take a while
$this->waitForElementPresent('access');
- $this->assertTrue($this->isTextPresent("Reservation has been added for 2 Contact(s)."));
+ $this->assertElementContainsText("crm-notification-container", "2");
$this->openCiviPage("report/survey/detail", "reset=1", '_qf_SurveyDetails_submit');
$this->select('campaign_survey_id', "label=$surveyTitle");
// need to wait for Groups field to reload dynamically
- sleep(3);
+ $this->waitForElementPresent("//select[@class='campaignGroupsSelect']/option[text()='$groupName']");
// select group
$this->click('campaignGroupsSelect1');
$this->waitForElementPresent('_qf_Interview_cancel_interview');
$this->type("field_{$id1}_phone-Primary-1", 9876543210);
- $this->click("xpath=//table[@id='voterRecords']/tbody//tr[@id='row_{$id1}']/td[5]/input[2]/../label[text()='$label1']");
- $this->click("xpath=//table[@id='voterRecords']/tbody//tr[@id='row_{$id1}']/td[5]/input[6]/../label[text()='$label2']");
+ $this->click("//table[@id='voterRecords']/tbody//tr[@id='row_{$id1}']/td[5]/input[2]/../label[text()='$label1']");
+ $this->click("//table[@id='voterRecords']/tbody//tr[@id='row_{$id1}']/td[5]/input[6]/../label[text()='$label2']");
$this->select("field_{$id1}_result", $optionLabel1);
$this->click("interview_voter_button_{$id1}");
sleep(3);
// select survey
$this->select('campaign_survey_id', "label=$surveyTitle");
// need to wait for Groups field to reload dynamically
- sleep(3);
+ $this->waitForElementPresent("//select[@class='campaignGroupsSelect']/option[text()='$groupName']");
// select group
$this->click('campaignGroupsSelect1');
$this->select('campaignGroupsSelect1', "label=$groupName");
$this->waitForElementPresent("xpath=//ul[@id='crmasmList1']/li");
$this->click("xpath=//div[@id='search_form_gotv']/div[2]/table/tbody/tr[6]/td/a[text()='Search']");
-
+
$this->waitForElementPresent("xpath=//table[@id='gotvVoterRecords']/tbody/tr/td[7]");
$this->check("xpath=//table[@id='gotvVoterRecords']/tbody/tr/td[7]/input");
}
function testAddCase() {
- $this->open($this->sboxPath);
-
- // Log in as admin first to verify permissions for CiviCase
$this->webtestLogin();
// Enable CiviCase module if necessary
- $this->open($this->sboxPath . "civicrm/admin/setting/component?reset=1");
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->waitForElementPresent("_qf_Component_next-bottom");
- $enabledComponents = $this->getSelectOptions("enableComponents-t");
- if (!in_array("CiviCase", $enabledComponents)) {
- $this->addSelection("enableComponents-f", "label=CiviCase");
- $this->click("//option[@value='CiviCase']");
- $this->click("add");
- $this->click("_qf_Component_next-bottom");
- $this->waitForPageToLoad($this->getTimeoutMsec());
- }
+ $this->enableComponents("CiviCase");
+
$customGrp1 = "CaseCustom_Data1_" . substr(sha1(rand()), 0, 7);
// create custom group1
$customGrpId1 = $elements['queryString']['gid'];
$customId = $this->_testGetCustomFieldId($customGrpId1);
- $cusId_1 = 'custom_' . $customId[0] . '_-1';
- $cusId_2 = 'custom_' . $customId[1] . '_-1';
- $cusId_3 = 'custom_' . $customId[2] . '_-1';
+ $cusId_1 = 'custom_' . $customId[0] . '_-1';
+ $cusId_2 = 'custom_' . $customId[1] . '_-1';
+ $cusId_3 = 'custom_' . $customId[2] . '_-1';
// let's give full CiviCase permissions.
$permission = array('edit-2-access-all-cases-and-activities', 'edit-2-access-my-cases-and-activities', 'edit-2-administer-civicase', 'edit-2-delete-in-civicase');
$this->waitForPageToLoad($this->getTimeoutMsec());
$this->waitForElementPresent("profilewrap4");
- // Is status message correct?
- $this->assertTextPresent("Thank you. Your information has been saved.", "Save successful status message didn't show up after saving profile to update testUserName!");
-
// Go directly to the URL of the screen that you will be testing (New Case-standalone).
$this->openCiviPage('case/add', 'reset=1&action=add&atype=13&context=standalone', '_qf_Case_upload-bottom');
$this->click("_qf_Case_upload-bottom");
$this->waitForPageToLoad($this->getTimeoutMsec());
$this->waitForElementPresent("css=span.crm-error");
- $this->assertTextPresent("Please select a contact or create new contact", "Expected form rule error for submit without selecting contact did not show up after clicking Save.");
// Adding contact with randomized first name (so we can then select that contact when creating case)
// We're using pop-up New Contact dialog
$caseTypeLabel = "Adult Day Care Referral";
// activity types we expect for this case type
- $activityTypes = array("ADC referral", "Follow up", "Medical evaluation", "Mental health evaluation");
- $caseRoles = array("Senior Services Coordinator", "Health Services Coordinator", "Benefits Specialist", "Client");
+ $activityTypes = array("ADC referral", "Follow up", "Medical evaluation", "Mental health evaluation");
+ $caseRoles = array("Senior Services Coordinator", "Health Services Coordinator", "Benefits Specialist", "Client");
$caseStatusLabel = "Ongoing";
- $subject = "Safe daytime setting - senior female";
+ $subject = "Safe daytime setting - senior female";
$this->select("medium_id", "value=1");
$location = "Main offices";
$this->type("activity_location", $location);
// verify if custom data is present
$this->openCiviPage('case', 'reset=1');
- $this->waitForPageToLoad($this->getTimeoutMsec());
$this->click("xpath=//table[@class='caseSelector']/tbody//tr/td[2]/a[text()='{$contactName}']/../../td[9]/span/a[text()='Manage']");
$this->waitForPageToLoad($this->getTimeoutMsec());
- $this->click("xpath=//div[@id='{$customGrp1}']/div[2]");
+ $this->click("css=#{$customGrp1} .crm-accordion-header");
+ $this->waitForElementPresent("css=#{$customGrp1} a.button");
+ $cusId_1 = 'custom_' . $customId[0] . '_1';
+ $cusId_2 = 'custom_' . $customId[1] . '_1';
+ $cusId_3 = 'custom_' . $customId[2] . '_1';
+ $this->click("css=#{$customGrp1} a.button");
sleep(2);
- $this->waitForElementPresent("xpath=//div[@id='{$customGrp1}']/div[2]/div/a/span[text()='Edit']");
- $this->click("xpath=//div[@id='{$customGrp1}']/div[2]/div/a/span[text()='Edit']");
- sleep(3);
+ $this->waitForElementPresent("{$cusId_1}");
$custFname = "Miky" . substr(sha1(rand()), 0, 7);
$custMname = "Davy" . substr(sha1(rand()), 0, 7);
$custLname = "Kristy" . substr(sha1(rand()), 0, 7);
- $cusId_1 = 'custom_' . $customId[0] . '_1';
- $cusId_2 = 'custom_' . $customId[1] . '_1';
- $cusId_3 = 'custom_' . $customId[2] . '_1';
- $this->click("xpath=//div[@id='{$customGrp1}']/div[2]");
- sleep(3);
$this->type("{$cusId_1}", $custFname);
$this->type("{$cusId_2}", $custMname);
$this->type("{$cusId_3}", $custLname);
$customId = array();
// Create a custom data to add in profile
-
$field1 = "Fname" . substr(sha1(rand()), 0, 7);
$field2 = "Mname" . substr(sha1(rand()), 0, 7);
$field3 = "Lname" . substr(sha1(rand()), 0, 7);
// add custom fields for group 1
- $this->openCiviPage('admin/custom/group/field/add', "reset=1&action=add&gid={$customGrpId1}");
+ $this->openCiviPage('admin/custom/group/field/add', array('reset' => 1, 'action' => 'add', 'gid' => $customGrpId1));
$this->type("label", $field1);
$this->check("is_searchable");
$this->click("_qf_Field_next_new-bottom");
$this->waitForPageToLoad($this->getTimeoutMsec());
// get id of custom fields
- $this->openCiviPage('admin/custom/group/field', "reset=1&action=browse&gid={$customGrpId1}");
+ $this->openCiviPage("admin/custom/group/field", array('reset' => 1, 'action' => 'browse', 'gid' => $customGrpId1));
$custom1 = explode('&id=', $this->getAttribute("xpath=//div[@id='field_page']//table/tbody//tr[1]/td[8]/span/a[text()='Edit Field']/@href"));
$custom1 = $custom1[1];
array_push($customId, $custom1);
function _testDeleteCustomData($customGrpId1, $customId) {
// delete all custom data
- $this->openCiviPage('admin/custom/group/field', "action=delete&reset=1&gid={$customGrpId1}&id={$customId[0]}");
+ $this->openCiviPage("admin/custom/group/field", array('action' => 'delete', 'reset' => '1', 'gid' => $customGrpId1, 'id' => $customId[0]));
$this->click("_qf_DeleteField_next-bottom");
$this->waitForPageToLoad($this->getTimeoutMsec());
- $this->openCiviPage('admin/custom/group/field', "action=delete&reset=1&gid={$customGrpId1}&id={$customId[1]}");
+ $this->openCiviPage("admin/custom/group/field", array('action' => 'delete', 'reset' => '1', 'gid' => $customGrpId1, 'id' => $customId[1]));
$this->click("_qf_DeleteField_next-bottom");
$this->waitForPageToLoad($this->getTimeoutMsec());
- $this->openCiviPage('admin/custom/group/field', "action=delete&reset=1&gid={$customGrpId1}&id={$customId[2]}");
+ $this->openCiviPage("admin/custom/group/field", array('action' => 'delete', 'reset' => '1', 'gid' => $customGrpId1, 'id' => $customId[2]));
$this->click("_qf_DeleteField_next-bottom");
$this->waitForPageToLoad($this->getTimeoutMsec());
- $this->openCiviPage('admin/custom/group', "action=delete&reset=1&id={$customGrpId1}");
+ $this->openCiviPage("admin/custom/group", "action=delete&reset=1&id=" . $customGrpId1);
$this->click("_qf_DeleteGroup_next-bottom");
$this->waitForPageToLoad($this->getTimeoutMsec());
}
// search casecontact
$this->openCiviPage('contact/search/advanced', 'reset=1', '_qf_Advanced_refresh');
$this->click("CiviCase");
- sleep(2);
+ $this->waitForElementPresent('case_from_relative');
$cusId_1 = 'custom_' . $customId[0];
$cusId_2 = 'custom_' . $customId[1];
$cusId_3 = 'custom_' . $customId[2];
}
function testAnonymousAddUser() {
- // This is the path where our testing install resides.
- // The rest of URL is defined in CiviSeleniumTestCase base class, in
- // class attributes.
- $this->open($this->sboxPath);
-
// Make sure Drupal account settings allow visitors to register for account w/o admin approval
// login as admin
$this->webtestLogin(TRUE);
$this->click('edit-submit');
$this->waitForPageToLoad($this->getTimeoutMsec());
// logout
- $this->open($this->sboxPath . 'civicrm/logout?reset=1');
- $this->waitForPageToLoad($this->getTimeoutMsec());
+ $this->openCiviPage('logout', 'reset=1', NULL);
// Go directly to the URL of the screen that will Create User Anonymously.
$this->open($this->sboxPath . "user/register");
$emailId = substr(sha1(rand()), 0, 7) . '@web.com';
$this->type("edit-mail", $emailId);
-
//Add profile Details
$firstName = 'Ma' . substr(sha1(rand()), 0, 4);
$lastName = 'An' . substr(sha1(rand()), 0, 7);
$this->click("edit-submit");
$this->waitForPageToLoad($this->getTimeoutMsec());
- $this->assertTrue($this->isTextPresent("A welcome message with further instructions has been sent to your e-mail address."));
+
+ // In case the site is set up to login immediately upon registration
+ $this->open($this->sboxPath . "user/logout");
$this->webtestLogin();
- $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", $emailId);
$this->click("_qf_Basic_refresh");
$this->waitForPageToLoad($this->getTimeoutMsec());