}
function testIndividualAdd() {
- // Logging in. Remember to wait for page to load. In most cases,
- // you can rely on 30000 as the value that allows your test to pass, however,
- // sometimes your test might fail because of this. In such cases, it's better to pick one element
- // somewhere at the end of page and use waitForElementPresent on it - this assures you, that whole
- // page contents loaded and you can continue your test execution.
$this->webtestLogin();
- // Go directly to the URL of New Individual.
- $this->open($this->sboxPath . "civicrm/contact/add?reset=1&ct=Individual");
- $this->waitForPageToLoad($this->getTimeoutMsec());
+ $this->openCiviPage("contact/add", "reset=1&ct=Individual");
// add contact1
//select prefix
$this->addActivity($firstName, $lastName, $subject);
// contact2: duplicate of contact1.
- $this->open($this->sboxPath . "civicrm/contact/add?reset=1&ct=Individual");
+ $this->openCiviPage("contact/add", "reset=1&ct=Individual");
//fill in first name
$this->type("first_name", $firstName);
$this->webtestAddContact($fname2, $lname2, $email2);
// Can not use helper for 2nd contact since it is a dupe
- $this->open($this->sboxPath . "civicrm/contact/add?reset=1&ct=Individual");
- $this->waitForPageToLoad($this->getTimeoutMsec());
+ $this->openCiviPage("contact/add", "reset=1&ct=Individual");
$this->type("first_name", $fname2);
$this->type("last_name", $lname2);
$this->type("email_1_email", $email2);
$this->assertElementContainsText('crm-notification-container', "Contact Saved");
// Find and Merge Contacts with Supervised Rule
- $this->open($this->sboxPath . 'civicrm/contact/dedupefind?reset=1&rgid=1&action=renew');
- $this->waitForPageToLoad($this->getTimeoutMsec());
+ $this->openCiviPage("contact/dedupefind", "reset=1&rgid=1&action=renew");
// reload the page
- $this->open($this->sboxPath . 'civicrm/contact/dedupefind?reset=1&rgid=1&action=update');
- $this->waitForPageToLoad($this->getTimeoutMsec());
+ $this->openCiviPage("contact/dedupefind", "reset=1&rgid=1&action=update");
// Select the contacts to be merged
$this->select("name=option51_length", "value=100");
- $this->waitForTextPresent("$firstName $lastName");
- // sleep seems to work here, not sure why
- sleep(3);
+ $this->waitForElementPresent("xpath=//a[text()='$firstName $lastName']/../../td[4]/a[text()='merge']");
$this->click("xpath=//a[text()='$firstName $lastName']/../../td[4]/a[text()='merge']");
$this->waitForElementPresent('_qf_Merge_cancel-bottom');
- $this->click("css=div.crm-contact-merge-form-block div.action-link a");
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->waitForElementPresent('_qf_Merge_cancel-bottom');
+ $this->clickLink("css=div.crm-contact-merge-form-block div.action-link a", '_qf_Merge_cancel-bottom');
// Move the activities, groups, etc to the main contact and merge using Merge and Goto Next Pair
$this->check('move_prefix_id');
$this->check('move_rel_table_activities');
$this->check('move_rel_table_groups');
$this->check('move_rel_table_tags');
- $this->click('_qf_Merge_next-bottom');
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->waitForElementPresent('_qf_Merge_cancel-bottom');
+ $this->clickLink('_qf_Merge_next-bottom', '_qf_Merge_cancel-bottom');
$this->assertTrue($this->isTextPresent('Contacts Merged'), "Contacts Merged text was not found after merge.");
// Check that we are viewing the next Merge Pair (our 2nd contact, since the merge list is ordered by contact_id)
$this->assertTrue($this->isTextPresent("{$fname2} {$lname2}"), "Redirect for Goto Next Pair after merge did not work.");
// Ensure that the duplicate contact has been deleted
- $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', $firstName);
$this->check('deleted_contacts');
$this->click('_qf_Advanced_refresh');
$this->assertTrue($this->isTextPresent('1 Contact'), "Deletion of duplicate contact during merge was not successful. Dupe contact not found when searching trash.");
// Search for the main contact
- $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', $firstName);
$this->click('_qf_Advanced_refresh');
$this->waitForElementPresent("xpath=//form[@id='Advanced']/div[3]/div/div[2]/table/tbody/tr");
// Verify group merged
$this->click("css=li#tab_group a");
- $this->waitForElementPresent("xpath=//div[@id='groupContact']//table/tbody/tr");
- $this->verifyText("xpath=//div[@id='groupContact']//table/tbody/tr/td/a",
+ $this->waitForElementPresent("xpath=//form[@id='GroupContact']//div[@class='view-content']//div[@class='dataTables_wrapper']/table/tbody/tr");
+ $this->verifyText("xpath=//form[@id='GroupContact']//div[@class='view-content']//div[@class='dataTables_wrapper']/table/tbody/tr/td/a",
preg_quote("$group")
);
// button at the end of this page to show up, to make sure it's fully loaded.
$this->waitForElementPresent("_qf_Activity_upload");
- // Let's start filling the form with values.
// ...and verifying if the page contains properly formatted display name for chosen contact.
$this->assertTrue($this->isTextPresent("Anderson, " . $withContact), "Contact not found in line " . __LINE__);
function testMergeTest() {
- // Logging in. Remember to wait for page to load. In most cases,
- // you can rely on 30000 as the value that allows your test to pass, however,
- // sometimes your test might fail because of this. In such cases, it's better to pick one element
- // somewhere at the end of page and use waitForElementPresent on it - this assures you, that whole
- // page contents loaded and you can continue your test execution.
$this->webtestLogin();
- // Go directly to the URL of New Individual.
- $this->open($this->sboxPath . "civicrm/contact/add?reset=1&ct=Individual");
- $this->waitForPageToLoad($this->getTimeoutMsec());
+ $this->openCiviPage("contact/add", "reset=1&ct=Individual");
// add contact1
//fill in first name
$this->assertElementContainsText('crm-notification-container', "Contact Saved");
// contact2: duplicate of contact1.
- $this->open($this->sboxPath . "civicrm/contact/add?reset=1&ct=Individual");
+ $this->openCiviPage("contact/add", "reset=1&ct=Individual");
//fill in first name
$this->type("first_name", $firstName);
$this->assertElementContainsText('crm-notification-container', "Contact Saved");
// Find and Merge Contacts with Supervised Rule
- $this->open($this->sboxPath . 'civicrm/contact/dedupefind?reset=1&rgid=1&action=renew');
- $this->waitForPageToLoad($this->getTimeoutMsec());
+ $this->openCiviPage("contact/dedupefind", "reset=1&rgid=1&action=renew");
// Select the contacts to be merged
$this->select("name=option51_length", "value=100");
$this->waitForElementPresent("xpath=//a[text()='$firstName $lastName']");
$this->click("xpath=//a[text()='$firstName $lastName']/../../td[4]/a[text()='merge']");
$this->waitForElementPresent('_qf_Merge_cancel-bottom');
- $this->click("css=div.crm-contact-merge-form-block div.action-link a");
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->waitForElementPresent("xpath=//form[@id='Merge']/div[2]/table/tbody/tr[2]/td[4]/span[text()='(overwrite)']");
+ $this->clickLink("css=div.crm-contact-merge-form-block div.action-link a", "xpath=//form[@id='Merge']/div[2]/table/tbody/tr[2]/td[4]/span[text()='(overwrite)']");
$this->waitForElementPresent("xpath=//form[@id='Merge']/div[2]/table/tbody/tr[3]/td[4]/span[text()='(add)']");
$this->waitForElementPresent('_qf_Merge_cancel-bottom');
$this->assertTrue($this->isElementPresent("xpath=//div[@id='phone-block']/div/div/div[4]/div[2][contains(text(), '9876543120')]"));
//Merge with the feature of (add)
- // Go directly to the URL of New Individual.
- $this->open($this->sboxPath . "civicrm/contact/add?reset=1&ct=Individual");
- $this->waitForPageToLoad($this->getTimeoutMsec());
+ $this->openCiviPage("contact/add", "reset=1&ct=Individual");
// add contact1
//fill in first name
$this->assertElementContainsText('crm-notification-container', "Contact Saved");
// contact2: duplicate of contact1.
- $this->open($this->sboxPath . "civicrm/contact/add?reset=1&ct=Individual");
+ $this->openCiviPage("contact/add", "reset=1&ct=Individual");
//fill in first name
$this->type("first_name", $firstName1);
$this->assertElementContainsText('crm-notification-container', "Contact Saved");
// Find and Merge Contacts with Supervised Rule
- $this->open($this->sboxPath . 'civicrm/contact/dedupefind?reset=1&rgid=1&action=renew');
- $this->waitForPageToLoad($this->getTimeoutMsec());
+ $this->openCiviPage("contact/dedupefind", "reset=1&rgid=1&action=renew");
// Select the contacts to be merged
$this->select("name=option51_length", "value=100");
$this->waitForElementPresent("xpath=//table[@class='pagerDisplay']/tbody//tr/td[1]/a[text()='$firstName1 $lastName1']/../../td[2]/a[text()='$firstName1 $lastName1']");
$this->click("xpath=//table[@class='pagerDisplay']/tbody//tr/td[1]/a[text()='$firstName1 $lastName1']/../../td[2]/a[text()='$firstName1 $lastName1']/../../td[4]/a[text()='merge']");
$this->waitForElementPresent('_qf_Merge_cancel-bottom');
- $this->click("css=div.crm-contact-merge-form-block div.action-link a");
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->waitForElementPresent("xpath=//form[@id='Merge']/div[2]/table/tbody/tr[2]/td[4]/span[text()='(overwrite)']");
+ $this->clickLink("css=div.crm-contact-merge-form-block div.action-link a", "xpath=//form[@id='Merge']/div[2]/table/tbody/tr[2]/td[4]/span[text()='(overwrite)']");
$this->waitForElementPresent("xpath=//form[@id='Merge']/div[2]/table/tbody/tr[3]/td[4]/span[text()='(add)']");
$this->waitForElementPresent("xpath=//form[@id='Merge']/div[2]/table/tbody/tr[4]/td[4]/span[text()='(overwrite)']");
$this->select('location_email_1_locTypeId', 'value=3');
}
function testBatchMerge(){
- // Logging in. Remember to wait for page to load. In most cases,
- // you can rely on 30000 as the value that allows your test to pass, however,
- // sometimes your test might fail because of this. In such cases, it's better to pick one element
- // somewhere at the end of page and use waitForElementPresent on it - this assures you, that whole
- // page contents loaded and you can continue your test execution.
$this->webtestLogin();
// add contact1 and its duplicate
//add contact2 and its duplicate
//These are the contacts with conflicts in communication preference.these contacts will be skipped during merge.
- $this->open($this->sboxPath . "civicrm/contact/add?reset=1&ct=Individual");
- $this->waitForPageToLoad($this->getTimeoutMsec());
+ $this->openCiviPage("contact/add", "reset=1&ct=Individual");
//fill in first name
$firstName1 = "Kurt".substr(sha1(rand()), 0, 7);
$this->assertElementContainsText('crm-notification-container', "Contact Saved");
//duplicate of contact2.
- $this->open($this->sboxPath . "civicrm/contact/add?reset=1&ct=Individual");
+ $this->openCiviPage("contact/add", "reset=1&ct=Individual");
//fill in first name
$this->type("first_name", $firstName1);
$this->_createContacts($firstName3,$lastName3);
// Find and Merge Contacts with Supervised Rule
- $this->open($this->sboxPath . 'civicrm/contact/dedupefind?reset=1&rgid=1&action=renew');
- $this->waitForPageToLoad($this->getTimeoutMsec());
- sleep(3);
+ $this->openCiviPage("contact/dedupefind", "reset=1&rgid=1&action=renew", "css=#DedupeFind table.pagerDisplay tbody tr");
$this->select("name=option51_length", "value=100");
$totalContacts = $this->getXpathCount("//table[@class='pagerDisplay']/tbody/tr");
));
$this->chooseOkOnNextConfirmation();
$this->waitForPageToLoad($this->getTimeoutMsec());
- sleep(5);
+ $this->waitForElementPresent('civicrm-footer');
+ $this->assertElementContainsText('crm-notification-container', "safe mode");
+
+ // If we are still on the dedupe table page, count unmerged contacts
+ if ($this->isElementPresent("//table[@class='pagerDisplay']")) {
+ // Wait for datatable to load
+ $this->waitForElementPresent("//table[@class='pagerDisplay']/tbody/tr");
+ $unMergedContacts = $this->getXpathCount("//table[@class='pagerDisplay']/tbody/tr");
+ }
+ else {
+ $unMergedContacts = 0;
+ }
- $unMergedContacts = $this->getXpathCount("//table[@class='pagerDisplay']/tbody/tr");
$mergedContacts = $totalContacts - $unMergedContacts;
- $this->assertElementContainsText('crm-notification-container', "safe mode");
//check the existence of merged contacts
$contactEmails = array(
3 => "{$firstName3}.{$lastName3}@example.com"
);
- foreach( $contactEmails as $key => $value ) {
+ foreach($contactEmails as $key => $value) {
$this->click('sort_name_navigation');
$this->type('css=input#sort_name_navigation', $value);
$this->typeKeys('css=input#sort_name_navigation', $value);
$this->waitForElementPresent("css=div.ac_results-inner li");
// Visit contact summary page.
- $this->click("css=div.ac_results-inner li");
- $this->waitForPageToLoad($this->getTimeoutMsec());
- sleep(2);
+ $this->clickLink("css=div.ac_results-inner li", 'civicrm-footer');
}
}
*/
function _createContacts($firstName,$lastName){
// add contact
- $this->open($this->sboxPath . "civicrm/contact/add?reset=1&ct=Individual");
+ $this->openCiviPage("contact/add", "reset=1&ct=Individual");
//fill in first name
$this->type('first_name', $firstName);
$this->assertElementContainsText('crm-notification-container', "Contact Saved");
//duplicate of above contact.
- $this->open($this->sboxPath . "civicrm/contact/add?reset=1&ct=Individual");
+ $this->openCiviPage("contact/add", "reset=1&ct=Individual");
//fill in first name
$this->type("first_name", $firstName);