From d2771e94aaf7b2760cc93655b598254ad5a0d47d Mon Sep 17 00:00:00 2001 From: Ravish Nair Date: Thu, 7 Mar 2013 20:25:12 +0530 Subject: [PATCH] -- improved webtests, applied patch and made modifications --- .../WebTest/Case/ActivityToCaseTest.php | 38 ++++++-------- tests/phpunit/WebTest/Case/AddCaseTest.php | 36 +++++--------- .../WebTest/Case/CaseCustomFieldsTest.php | 49 ++++++------------- .../WebTest/Case/CaseDashboardTest.php | 25 +++------- .../WebTest/Pledge/ContactContextAddTest.php | 4 +- .../ContactContextPledgePaymentAddTest.php | 24 ++++----- .../Pledge/StandaloneAddDeleteTest.php | 20 +++----- .../WebTest/Pledge/StandaloneAddTest.php | 8 +-- 8 files changed, 73 insertions(+), 131 deletions(-) diff --git a/tests/phpunit/WebTest/Case/ActivityToCaseTest.php b/tests/phpunit/WebTest/Case/ActivityToCaseTest.php index 189cdfef4e..ae0f4b806c 100644 --- a/tests/phpunit/WebTest/Case/ActivityToCaseTest.php +++ b/tests/phpunit/WebTest/Case/ActivityToCaseTest.php @@ -39,9 +39,7 @@ class WebTest_Case_ActivityToCaseTest extends CiviSeleniumTestCase { $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'); + $this->openCiviPage('admin/setting/component', 'reset=1', '_qf_Component_next-bottom'); $enabledComponents = $this->getSelectOptions('enableComponents-t'); if (!in_array('CiviCase', $enabledComponents)) { $this->addSelection('enableComponents-f', "label=CiviCase"); @@ -56,12 +54,7 @@ class WebTest_Case_ActivityToCaseTest extends CiviSeleniumTestCase { $this->changePermissions($permission); // Go directly to the URL of the screen that you will be testing (New Case-standalone). - $this->open($this->sboxPath . "civicrm/case/add?reset=1&action=add&atype=13&context=standalone"); - - // 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->waitForPageToLoad($this->getTimeoutMsec()); - $this->waitForElementPresent('_qf_Case_upload-bottom'); + $this->openCiviPage('case/add', 'reset=1&action=add&atype=13&context=standalone', '_qf_Case_upload-bottom'); // Adding contact with randomized first name (so we can then select that contact when creating case) // We're using pop-up New Contact dialog @@ -96,7 +89,7 @@ class WebTest_Case_ActivityToCaseTest extends CiviSeleniumTestCase { $this->waitForElementPresent('_qf_CaseView_cancel-bottom'); // Is status message correct? - $this->assertTextPresent("Case opened successfully.", "Save successful status message didn't show up after saving!"); + $this->assertElementContainsText('crm-notification-container', "Case opened successfully.", "Save successful status message didn't show up after saving!"); $customGroupTitle = 'Custom_' . substr(sha1(rand()), 0, 7); $this->_testAddNewActivity($firstName, $subject, $customGroupTitle, $contactName); @@ -129,7 +122,7 @@ class WebTest_Case_ActivityToCaseTest extends CiviSeleniumTestCase { // 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, " . $firstName2), "Contact not found in line " . __LINE__); + $this->assertElementContainsText('css=tr.crm-activity-form-block-target_contact_id td ul li.token-input-token-facebook', 'Anderson, ' . $firstName2, "Contact not found in line " . __LINE__); // Now we're filling the "Assigned To" field. // Typing contact's name into the field (using typeKeys(), not type()!)... @@ -148,7 +141,7 @@ class WebTest_Case_ActivityToCaseTest extends CiviSeleniumTestCase { $this->waitForElementPresent("css=tr.crm-activity-form-block-assignee_contact_id td ul li span.token-input-delete-token-facebook"); // ...and verifying if the page contains properly formatted display name for chosen contact. - $this->assertTrue($this->isTextPresent("Summerson, " . $firstName1), "Contact not found in line " . __LINE__); + $this->assertElementContainsText('css=tr.crm-activity-form-block-assignee_contact_id td ul li.token-input-token-facebook', 'Summerson, ' . $firstName1, "Contact not found in line " . __LINE__); // Putting the contents into subject field - assigning the text to variable, it'll come in handy later $subject = "This is subject of test activity being added through activity tab of contact summary screen."; @@ -190,7 +183,7 @@ class WebTest_Case_ActivityToCaseTest extends CiviSeleniumTestCase { $this->waitForPageToLoad($this->getTimeoutMsec()); // Is status message correct? - $this->assertTrue($this->isTextPresent("Activity '$subject' has been saved."), + $this->assertElementContainsText('crm-notification-container', "Activity '$subject' has been saved.", "Status message didn't show up after saving!" ); @@ -214,8 +207,7 @@ class WebTest_Case_ActivityToCaseTest extends CiviSeleniumTestCase { $this->waitForElementPresent("xpath=//div[@id='Activities']//table/tbody/tr[1]/td[9]/span/a[text()='View']"); // verify if custom data is present - $this->open($this->sboxPath . "civicrm/case?reset=1"); - $this->waitForPageToLoad($this->getTimeoutMsec()); + $this->openCiviPage('case', 'reset=1'); $this->click("xpath=//table[@class='caseSelector']/tbody//tr/td[2]/a[text()='{$contactName}']/../../td[9]/span/a[text()='Manage']"); $this->waitForElementPresent('_qf_CaseView_cancel-bottom'); @@ -225,9 +217,8 @@ class WebTest_Case_ActivityToCaseTest extends CiviSeleniumTestCase { $this->waitForElementPresent('view-activity'); $this->waitForElementPresent("css=table#crm-activity-view-table tr.crm-case-activityview-form-block-groupTitle"); - - $this->isTextPresent($customDataParams[0]); - $this->isTextPresent($textField); + $this->assertElementContainsText('crm-activity-view-table', "$customDataParams[0]"); + $this->assertElementContainsText('crm-activity-view-table', "$textField"); $this->click("xpath=//div[@class='ui-dialog-buttonset']/button/span[text()='Done']"); $this->waitForElementPresent("xpath=//div[@id='activities']//table[@id='activities-selector']/tbody/tr[1]/td[2]"); @@ -240,8 +231,7 @@ class WebTest_Case_ActivityToCaseTest extends CiviSeleniumTestCase { $this->select('activity_change_status', 'value=2'); $this->click("xpath=//div[@class='ui-dialog-buttonset']/button/span[text()='Ok']"); $this->waitForPageToLoad($this->getTimeoutMsec()); - $this->open($this->sboxPath . "civicrm/case?reset=1"); - $this->waitForPageToLoad($this->getTimeoutMsec()); + $this->openCiviPage('case', 'reset=1'); $this->click("xpath=//table[@class='caseSelector']/tbody//tr/td[2]/a[text()='{$contactName}']/../../td[9]/span/a[text()='Manage']"); $this->waitForElementPresent('_qf_CaseView_cancel-bottom'); $this->waitForElementPresent("xpath=//div[@id='activities']//table[@id='activities-selector']/tbody/tr[1]/td[2]"); @@ -252,7 +242,7 @@ class WebTest_Case_ActivityToCaseTest extends CiviSeleniumTestCase { function _addCustomData($customGroupTitle) { // 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"); @@ -270,7 +260,7 @@ class WebTest_Case_ActivityToCaseTest extends CiviSeleniumTestCase { $this->waitForElementPresent('_qf_Field_cancel-bottom'); //Is custom group created? - $this->assertTrue($this->isTextPresent("Your custom field set '{$customGroupTitle}' has been added. You can add custom fields now.")); + $this->assertElementContainsText('crm-notification-container', "Your custom field set '{$customGroupTitle}' has been added. You can add custom fields now."); // create a custom field - Integer Radio $this->click("data_type[0]"); @@ -306,7 +296,7 @@ class WebTest_Case_ActivityToCaseTest extends CiviSeleniumTestCase { $this->waitForPageToLoad($this->getTimeoutMsec()); //Is custom field created - $this->assertTrue($this->isTextPresent("Your custom field '$radioFieldLabel' has been saved.")); + $this->assertElementContainsText('crm-notification-container', "Your custom field '$radioFieldLabel' has been saved."); // create another custom field - text field $this->click("//a[@id='newCustomField']/span"); @@ -329,7 +319,7 @@ class WebTest_Case_ActivityToCaseTest extends CiviSeleniumTestCase { $this->waitForPageToLoad($this->getTimeoutMsec()); //Is custom field created - $this->assertTrue($this->isTextPresent("Your custom field '$textFieldLabel' has been saved.")); + $this->assertElementContainsText('crm-notification-container', "Your custom field '$textFieldLabel' has been saved."); $textFieldId = explode('&id=', $this->getAttribute("xpath=//div[@id='field_page']//table/tbody//tr/td/span[text()='$textFieldLabel']/../../td[8]/span/a[text()='Edit Field']/@href")); $textFieldId = $textFieldId[1]; diff --git a/tests/phpunit/WebTest/Case/AddCaseTest.php b/tests/phpunit/WebTest/Case/AddCaseTest.php index a793356128..ca99ffd2ae 100644 --- a/tests/phpunit/WebTest/Case/AddCaseTest.php +++ b/tests/phpunit/WebTest/Case/AddCaseTest.php @@ -40,9 +40,7 @@ class WebTest_Case_AddCaseTest extends CiviSeleniumTestCase { $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"); + $this->openCiviPage('admin/setting/component', 'reset=1', '_qf_Component_next-bottom'); $enabledComponents = $this->getSelectOptions("enableComponents-t"); if (!in_array("CiviCase", $enabledComponents)) { $this->addSelection("enableComponents-f", "label=CiviCase"); @@ -57,7 +55,7 @@ class WebTest_Case_AddCaseTest extends CiviSeleniumTestCase { $this->changePermissions($permission); // Go to reserved New Individual Profile to set value for logged in user's contact name (we'll need that later) - $this->open($this->sboxPath . "civicrm/profile/edit?reset=1&gid=4"); + $this->openCiviPage('profile/edit', 'reset=1&gid=4'); $testUserFirstName = "Testuserfirst"; $testUserLastName = "Testuserlast"; $this->waitForPageToLoad($this->getTimeoutMsec()); @@ -67,23 +65,17 @@ class WebTest_Case_AddCaseTest extends CiviSeleniumTestCase { $this->click("_qf_Edit_next"); $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!"); + $this->assertElementContainsText('crm-container', "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->open($this->sboxPath . "civicrm/case/add?reset=1&action=add&atype=13&context=standalone"); - - // 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->waitForPageToLoad($this->getTimeoutMsec()); - $this->waitForElementPresent("_qf_Case_upload-bottom"); + $this->openCiviPage('case/add', 'reset=1&action=add&atype=13&context=standalone', '_qf_Case_upload-bottom'); // Try submitting the form without creating or selecting a contact (test for CRM-7971) $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."); + $this->assertElementContainsText('Case', "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 @@ -124,7 +116,7 @@ class WebTest_Case_AddCaseTest extends CiviSeleniumTestCase { $this->waitForElementPresent("_qf_CaseView_cancel-bottom"); // Is status message correct? - $this->assertTextPresent("Case opened successfully.", "Save successful status message didn't show up after saving!"); + $this->assertElementContainsText('crm-notification-container', "Case opened successfully.", "Save successful status message didn't show up after saving!"); $summaryStrings = array( "Case Summary", @@ -211,18 +203,16 @@ class WebTest_Case_AddCaseTest extends CiviSeleniumTestCase { function _testSearchbyDate($firstName, $lastName, $action) { // Find Cases if ($action != "0") { - $this->open($this->sboxPath . "civicrm/case/search?reset=1"); - $this->waitForPageToLoad($this->getTimeoutMsec()); + $this->openCiviPage('case/search', 'reset=1'); $this->select("case_from_relative", "value=$action"); $this->select("case_to_relative", "value=$action"); $this->click("_qf_Search_refresh"); $this->waitForPageToLoad($this->getTimeoutMsec()); - $this->assertTrue($this->isTextPresent("$lastName, $firstName")); + $this->assertElementContainsText('Search', "$lastName, $firstName"); } else { //select date range - $this->open($this->sboxPath . "civicrm/case/search?reset=1"); - $this->waitForElementPresent("_qf_Search_refresh-bottom"); + $this->openCiviPage('case/search', 'reset=1', '_qf_Search_refresh-bottom'); $this->select("case_from_relative", "value=$action"); $this->webtestFillDate("case_from_start_date_low", "-1 month"); $this->webtestFillDate("case_from_start_date_high", "+1 month"); @@ -231,13 +221,11 @@ class WebTest_Case_AddCaseTest extends CiviSeleniumTestCase { $this->webtestFillDate("case_to_end_date_high", "+1 month"); $this->click("_qf_Search_refresh-bottom"); $this->waitForPageToLoad($this->getTimeoutMsec()); - $this->assertTrue($this->isTextPresent("$lastName, $firstName")); + $this->assertElementContainsText('Search', "$lastName, $firstName"); } //Advanced Search - $this->open($this->sboxPath . "civicrm/contact/search/advanced?reset=1"); - $this->waitForPageToLoad($this->getTimeoutMsec()); - $this->waitForElementPresent("_qf_Advanced_refresh"); + $this->openCiviPage('contact/search/advanced', 'reset=1', '_qf_Advanced_refresh'); $this->click("CiviCase"); $this->waitForElementPresent("xpath=//div[@id='case-search']/table/tbody/tr[3]/td[2]/input[3]"); if ($action != "0") { @@ -254,7 +242,7 @@ class WebTest_Case_AddCaseTest extends CiviSeleniumTestCase { } $this->click("_qf_Advanced_refresh"); $this->waitForPageToLoad($this->getTimeoutMsec()); - $this->assertTrue($this->isTextPresent("$lastName, $firstName")); + $this->assertElementContainsText('Advanced', "$lastName, $firstName"); } } diff --git a/tests/phpunit/WebTest/Case/CaseCustomFieldsTest.php b/tests/phpunit/WebTest/Case/CaseCustomFieldsTest.php index d0f0a73857..a1f621bc74 100644 --- a/tests/phpunit/WebTest/Case/CaseCustomFieldsTest.php +++ b/tests/phpunit/WebTest/Case/CaseCustomFieldsTest.php @@ -53,7 +53,7 @@ class WebTest_Case_CaseCustomFieldsTest extends CiviSeleniumTestCase { $customGrp1 = "CaseCustom_Data1_" . substr(sha1(rand()), 0, 7); // create custom group1 - $this->open($this->sboxPath . "civicrm/admin/custom/group?reset=1"); + $this->openCiviPage('admin/custom/group', 'reset=1'); $this->click("newCustomDataGroup"); $this->waitForPageToLoad($this->getTimeoutMsec()); $this->type("title", $customGrp1); @@ -77,11 +77,9 @@ class WebTest_Case_CaseCustomFieldsTest extends CiviSeleniumTestCase { $this->changePermissions($permission); // Go to reserved New Individual Profile to set value for logged in user's contact name (we'll need that later) - $this->open($this->sboxPath . "civicrm/profile/edit?reset=1&gid=4"); + $this->openCiviPage('profile/edit', 'reset=1&gid=4', '_qf_Edit_next'); $testUserFirstName = "Testuserfirst"; $testUserLastName = "Testuserlast"; - $this->waitForPageToLoad($this->getTimeoutMsec()); - $this->waitForElementPresent("_qf_Edit_next"); $this->type("first_name", $testUserFirstName); $this->type("last_name", $testUserLastName); $this->click("_qf_Edit_next"); @@ -92,12 +90,7 @@ class WebTest_Case_CaseCustomFieldsTest extends CiviSeleniumTestCase { $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->open($this->sboxPath . "civicrm/case/add?reset=1&action=add&atype=13&context=standalone"); - - // 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->waitForPageToLoad($this->getTimeoutMsec()); - $this->waitForElementPresent("_qf_Case_upload-bottom"); + $this->openCiviPage('case/add', 'reset=1&action=add&atype=13&context=standalone', '_qf_Case_upload-bottom'); // Try submitting the form without creating or selecting a contact (test for CRM-7971) $this->click("_qf_Case_upload-bottom"); @@ -156,9 +149,7 @@ class WebTest_Case_CaseCustomFieldsTest extends CiviSeleniumTestCase { $this->assertTextPresent("Case opened successfully.", "Save successful status message didn't show up after saving!"); $this->click("_qf_CaseView_cancel-bottom"); $this->waitForPageToLoad($this->getTimeoutMsec()); - $this->open($this->sboxPath . "civicrm/case?reset=1"); - - $this->waitForElementPresent("xpath=//table[@class='caseSelector']/tbody//tr/td[2]/a[text()='{$contactName}']/../../td[8]/a[text()='Open Case']"); + $this->openCiviPage('case', 'reset=1', "xpath=//table[@class='caseSelector']/tbody//tr/td[2]/a[text()='{$contactName}']/../../td[8]/a[text()='Open Case']"); $this->click("xpath=//table[@class='caseSelector']/tbody//tr/td[2]/a[text()='{$contactName}']/../../td[8]/a[text()='Open Case']"); $this->waitForElementPresent("xpath=//div[@class='ui-dialog-buttonset']/button/span[text()='Done']"); sleep(3); @@ -179,14 +170,14 @@ class WebTest_Case_CaseCustomFieldsTest extends CiviSeleniumTestCase { $this->click("xpath=//div[@class='ui-dialog-buttonset']/button/span[text()='Done']"); // verify if custom data is present - $this->open($this->sboxPath . "civicrm/case?reset=1"); + $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]"); sleep(2); - $this->waitForElementPresent("xpath=//div[@id='{$customGrp1}']/div[2]/a/span[text()='Edit']"); - $this->click("xpath=//div[@id='{$customGrp1}']/div[2]/a/span[text()='Edit']"); + $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); $custFname = "Miky" . substr(sha1(rand()), 0, 7); $custMname = "Davy" . substr(sha1(rand()), 0, 7); @@ -201,7 +192,7 @@ class WebTest_Case_CaseCustomFieldsTest extends CiviSeleniumTestCase { $this->type("{$cusId_3}", $custLname); $this->click("_qf_CustomData_upload"); sleep(2); - $this->open($this->sboxPath . "civicrm/case?reset=1"); + $this->openCiviPage('case', 'reset=1'); $this->click("xpath=//table[@class='caseSelector']/tbody//tr/td[2]/a[text()='{$contactName}']/../../td[8]/a[text()='Change Custom Data']"); sleep(3); $openCaseChangeData = array( @@ -240,8 +231,7 @@ class WebTest_Case_CaseCustomFieldsTest extends CiviSeleniumTestCase { $field3 = "Lname" . substr(sha1(rand()), 0, 7); // add custom fields for group 1 - $this->open($this->sboxPath . "civicrm/admin/custom/group/field/add?reset=1&action=add&gid=" . $customGrpId1); - $this->waitForPageToLoad($this->getTimeoutMsec()); + $this->openCiviPage('admin/custom/group/field/add', "reset=1&action=add&gid={$customGrpId1}"); $this->type("label", $field1); $this->check("is_searchable"); $this->click("_qf_Field_next_new-bottom"); @@ -258,7 +248,7 @@ class WebTest_Case_CaseCustomFieldsTest extends CiviSeleniumTestCase { $this->waitForPageToLoad($this->getTimeoutMsec()); // get id of custom fields - $this->open($this->sboxPath . "civicrm/admin/custom/group/field?reset=1&action=browse&gid=" . $customGrpId1); + $this->openCiviPage('admin/custom/group/field', "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); @@ -274,33 +264,26 @@ class WebTest_Case_CaseCustomFieldsTest extends CiviSeleniumTestCase { function _testDeleteCustomData($customGrpId1, $customId) { // delete all custom data - $this->open($this->sboxPath . "civicrm/admin/custom/group/field?action=delete&reset=1&gid=" . $customGrpId1 . "&id=" . $customId[0]); - $this->waitForPageToLoad($this->getTimeoutMsec()); + $this->openCiviPage('admin/custom/group/field', "action=delete&reset=1&gid={$customGrpId1}&id={$customId[0]}"); $this->click("_qf_DeleteField_next-bottom"); $this->waitForPageToLoad($this->getTimeoutMsec()); - $this->open($this->sboxPath . "civicrm/admin/custom/group/field?action=delete&reset=1&gid=" . $customGrpId1 . "&id=" . $customId[1]); - $this->waitForPageToLoad($this->getTimeoutMsec()); + $this->openCiviPage('admin/custom/group/field', "action=delete&reset=1&gid={$customGrpId1}&id={$customId[1]}"); $this->click("_qf_DeleteField_next-bottom"); $this->waitForPageToLoad($this->getTimeoutMsec()); - $this->open($this->sboxPath . "civicrm/admin/custom/group/field?action=delete&reset=1&gid=" . $customGrpId1 . "&id=" . $customId[2]); - $this->waitForPageToLoad($this->getTimeoutMsec()); + $this->openCiviPage('admin/custom/group/field', "action=delete&reset=1&gid={$customGrpId1}&id={$customId[2]}"); $this->click("_qf_DeleteField_next-bottom"); $this->waitForPageToLoad($this->getTimeoutMsec()); - $this->open($this->sboxPath . "civicrm/admin/custom/group?action=delete&reset=1&id=" . $customGrpId1); - $this->waitForPageToLoad($this->getTimeoutMsec()); + $this->openCiviPage('admin/custom/group', "action=delete&reset=1&id={$customGrpId1}"); $this->click("_qf_DeleteGroup_next-bottom"); $this->waitForPageToLoad($this->getTimeoutMsec()); } function _testAdvansearchCaseData($customId, $custFname, $custMname, $custLname) { - $this->open($this->sboxPath . "civicrm/contact/search/advanced?reset=1"); - // search casecontact - $this->waitForPageToLoad($this->getTimeoutMsec()); - $this->waitForElementPresent("_qf_Advanced_refresh"); + $this->openCiviPage('contact/search/advanced', 'reset=1', '_qf_Advanced_refresh'); $this->click("CiviCase"); sleep(2); $cusId_1 = 'custom_' . $customId[0]; @@ -311,7 +294,7 @@ class WebTest_Case_CaseCustomFieldsTest extends CiviSeleniumTestCase { $this->type("{$cusId_3}", $custLname); $this->click("_qf_Advanced_refresh"); $this->waitForPageToLoad($this->getTimeoutMsec()); - $this->assertTrue($this->isTextPresent('1 Contact')); + $this->assertElementContainsText('crm-container', '1 Contact'); } } diff --git a/tests/phpunit/WebTest/Case/CaseDashboardTest.php b/tests/phpunit/WebTest/Case/CaseDashboardTest.php index ca98ebdcb0..95af874ea5 100644 --- a/tests/phpunit/WebTest/Case/CaseDashboardTest.php +++ b/tests/phpunit/WebTest/Case/CaseDashboardTest.php @@ -40,9 +40,7 @@ class WebTest_Case_CaseDashboardTest extends CiviSeleniumTestCase { $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"); + $this->openCiviPage('admin/setting/component', 'reset=1', '_qf_Component_next-bottom'); $enabledComponents = $this->getSelectOptions("enableComponents-t"); if (!in_array("CiviCase", $enabledComponents)) { $this->addSelection("enableComponents-f", "label=CiviCase"); @@ -57,27 +55,22 @@ class WebTest_Case_CaseDashboardTest extends CiviSeleniumTestCase { $this->changePermissions($permission); // Go directly to the URL of the screen that you will be testing (Dashboard). - $this->open($this->sboxPath . "civicrm/case?reset=1"); - - $this->waitForPageToLoad($this->getTimeoutMsec()); - $this->waitForElementPresent("css=a.button"); + $this->openCiviPage('case', 'reset=1', 'css=a.button'); // Should default to My Cases $this->assertTrue($this->isChecked("name=allupcoming value=0"), 'Case dashboard should default to My Cases.'); // The header text of the table changes too - $this->assertTextPresent("Summary of Case Involvement"); + $this->assertElementContainsText('crm-container', "Summary of Case Involvement"); $this->click("name=allupcoming value=1"); $this->waitForPageToLoad($this->getTimeoutMsec()); $this->waitForElementPresent("css=a.button"); $this->assertTrue($this->isChecked("name=allupcoming value=1"), 'Selection of All Cases failed.'); - $this->assertTextPresent("Summary of All Cases"); + $this->assertElementContainsText('crm-container', "Summary of All Cases"); // Go back to dashboard - $this->open($this->sboxPath . "civicrm/case?reset=1"); - $this->waitForPageToLoad($this->getTimeoutMsec()); - $this->waitForElementPresent("css=a.button"); + $this->openCiviPage('case', 'reset=1', 'css=a.button'); // Click on find my cases and check if right radio is checked $this->click("name=find_my_cases"); @@ -86,9 +79,7 @@ class WebTest_Case_CaseDashboardTest extends CiviSeleniumTestCase { $this->assertTrue($this->isChecked("name=case_owner value=2"), 'Find my cases button not properly setting search form value to my cases.'); // Go back to dashboard - $this->open($this->sboxPath . "civicrm/case?reset=1"); - $this->waitForPageToLoad($this->getTimeoutMsec()); - $this->waitForElementPresent("css=a.button"); + $this->openCivipage('case', 'reset=1', 'css=a.button'); // Click on a drilldown cell and check if right radio is checked $this->click("css=a.crm-case-summary-drilldown"); @@ -97,9 +88,7 @@ class WebTest_Case_CaseDashboardTest extends CiviSeleniumTestCase { $this->assertTrue($this->isChecked("name=case_owner value=1"), 'Drilldown on dashboard summary cells not properly setting search form value to all cases.'); // Go back to dashboard and reset to my cases - $this->open($this->sboxPath . "civicrm/case?reset=1"); - $this->waitForPageToLoad($this->getTimeoutMsec()); - $this->waitForElementPresent("css=a.button"); + $this->openCiviPage('case', 'reset=1', 'css=a.button'); $this->click("name=allupcoming value=0"); $this->waitForPageToLoad($this->getTimeoutMsec()); $this->waitForElementPresent("css=a.button"); diff --git a/tests/phpunit/WebTest/Pledge/ContactContextAddTest.php b/tests/phpunit/WebTest/Pledge/ContactContextAddTest.php index c588f13cd3..7d6bdbf646 100644 --- a/tests/phpunit/WebTest/Pledge/ContactContextAddTest.php +++ b/tests/phpunit/WebTest/Pledge/ContactContextAddTest.php @@ -68,7 +68,7 @@ class WebTest_Pledge_ContactContextAddTest extends CiviSeleniumTestCase { $this->waitForElementPresent('_qf_Pledge_upload-bottom'); // check contact name on pledge form - $this->assertTrue($this->isTextPresent("$firstName $lastName")); + $this->assertElementContainsText('css=tr.crm-pledge-form-block-displayName', "$firstName $lastName"); // Let's start filling the form with values. $this->type("amount", "100"); @@ -103,7 +103,7 @@ class WebTest_Pledge_ContactContextAddTest extends CiviSeleniumTestCase { $this->click("_qf_Pledge_upload-bottom"); $this->waitForPageToLoad($this->getTimeoutMsec()); - $this->assertTrue($this->isTextPresent("Pledge has been recorded and the payment schedule has been created.")); + $this->assertElementContainsText('crm-notification-container', "Pledge has been recorded and the payment schedule has been created."); $this->waitForElementPresent("xpath=//div[@id='Pledges']//table//tbody/tr[1]/td[10]/span[1]/a[text()='View']"); //click through to the Pledge view screen diff --git a/tests/phpunit/WebTest/Pledge/ContactContextPledgePaymentAddTest.php b/tests/phpunit/WebTest/Pledge/ContactContextPledgePaymentAddTest.php index dec5dfd635..61be1bf37b 100644 --- a/tests/phpunit/WebTest/Pledge/ContactContextPledgePaymentAddTest.php +++ b/tests/phpunit/WebTest/Pledge/ContactContextPledgePaymentAddTest.php @@ -44,7 +44,7 @@ class WebTest_Pledge_ContactContextPledgePaymentAddTest extends CiviSeleniumTest // 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(); - $this->open($this->sboxPath . 'civicrm/admin/setting/localization?reset=1'); + $this->openCiviPage('admin/setting/localization', 'reset=1'); $this->select("currencyLimit-f","value=FJD"); $this->click("add"); $this->click("_qf_Localization_next-bottom"); @@ -73,7 +73,7 @@ class WebTest_Pledge_ContactContextPledgePaymentAddTest extends CiviSeleniumTest $this->waitForElementPresent('_qf_Pledge_upload-bottom'); // check contact name on pledge form - $this->assertTrue($this->isTextPresent("$firstName $lastName")); + $this->assertElementContainsText('css=tr.crm-pledge-form-block-displayName', "$firstName $lastName"); // Let's start filling the form with values. $this->select("currency","value=FJD"); @@ -110,7 +110,7 @@ class WebTest_Pledge_ContactContextPledgePaymentAddTest extends CiviSeleniumTest $this->click("_qf_Pledge_upload-bottom"); $this->waitForPageToLoad($this->getTimeoutMsec()); - $this->assertTrue($this->isTextPresent("Pledge has been recorded and the payment schedule has been created.")); + $this->assertElementContainsText('crm-notification-container', "Pledge has been recorded and the payment schedule has been created."); $this->waitForElementPresent("xpath=//div[@id='Pledges']//table//tbody/tr[1]/td[10]/span/a[text()='View']"); //click through to the Pledge view screen @@ -223,11 +223,11 @@ class WebTest_Pledge_ContactContextPledgePaymentAddTest extends CiviSeleniumTest 'Send additional reminders' => '4 days after the last one sent', ) ); - $this->open($this->sboxPath . 'civicrm/admin/setting/localization?reset=1'); - $this->select("currencyLimit-t","value=FJD"); - $this->click("remove"); - $this->click("_qf_Localization_next-bottom"); - $this->waitForPageToLoad($this->getTimeoutMsec()); + $this->openCiviPage('admin/setting/localization', 'reset=1'); + $this->select("currencyLimit-t","value=FJD"); + $this->click("remove"); + $this->click("_qf_Localization_next-bottom"); + $this->waitForPageToLoad($this->getTimeoutMsec()); } function testAddPledgePaymentWithAdjustTotalPledgeAmount() { @@ -266,7 +266,7 @@ class WebTest_Pledge_ContactContextPledgePaymentAddTest extends CiviSeleniumTest $this->waitForElementPresent('_qf_Pledge_upload-bottom'); // check contact name on pledge form - $this->assertTrue($this->isTextPresent("$firstName $lastName")); + $this->assertElementContainsText('css=tr.crm-pledge-form-block-displayName', "$firstName $lastName"); // Let's start filling the form with values. $this->type("amount", "30"); @@ -301,7 +301,7 @@ class WebTest_Pledge_ContactContextPledgePaymentAddTest extends CiviSeleniumTest $this->click("_qf_Pledge_upload-bottom"); $this->waitForPageToLoad($this->getTimeoutMsec()); - $this->assertTrue($this->isTextPresent("Pledge has been recorded and the payment schedule has been created.")); + $this->assertElementContainsText('crm-notification-container', "Pledge has been recorded and the payment schedule has been created."); $this->waitForElementPresent("xpath=//div[@id='Pledges']//table//tbody/tr[1]/td[10]/span/a[text()='View']"); //click through to the Pledge view screen @@ -441,7 +441,7 @@ class WebTest_Pledge_ContactContextPledgePaymentAddTest extends CiviSeleniumTest $this->waitForElementPresent('_qf_Pledge_upload-bottom'); // check contact name on pledge form - $this->assertTrue($this->isTextPresent("$firstName $lastName")); + $this->assertElementContainsText('css=tr.crm-pledge-form-block-displayName', "$firstName $lastName"); // Let's start filling the form with values. $this->type("amount", "30"); @@ -476,7 +476,7 @@ class WebTest_Pledge_ContactContextPledgePaymentAddTest extends CiviSeleniumTest $this->click("_qf_Pledge_upload-bottom"); $this->waitForPageToLoad($this->getTimeoutMsec()); - $this->assertTrue($this->isTextPresent("Pledge has been recorded and the payment schedule has been created.")); + $this->assertElementContainsText('crm-notification-container', "Pledge has been recorded and the payment schedule has been created."); //Add payments $this->waitForElementPresent("xpath=//div[@id='Pledges']//table//tbody/tr[1]/td[10]/span/a[text()='View']"); diff --git a/tests/phpunit/WebTest/Pledge/StandaloneAddDeleteTest.php b/tests/phpunit/WebTest/Pledge/StandaloneAddDeleteTest.php index 9fe4eb8ef3..23d734d205 100644 --- a/tests/phpunit/WebTest/Pledge/StandaloneAddDeleteTest.php +++ b/tests/phpunit/WebTest/Pledge/StandaloneAddDeleteTest.php @@ -41,11 +41,7 @@ class WebTest_Pledge_StandaloneAddDeleteTest extends CiviSeleniumTestCase { $this->webtestLogin(); // Go directly to the URL of the screen that you will be testing (New Pledge-standalone). - $this->open($this->sboxPath . 'civicrm/pledge/add?reset=1&context=standalone'); - - // 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_Pledge_upload'); + $this->openCiviPage('pledge/add', 'reset=1&context=standalone', '_qf_Pledge_upload'); // create new contact using dialog $firstName = 'Ma' . substr(sha1(rand()), 0, 4); @@ -61,7 +57,7 @@ class WebTest_Pledge_StandaloneAddDeleteTest extends CiviSeleniumTestCase { $this->click('_qf_Pledge_upload-bottom'); $this->waitForPageToLoad("30000"); - $this->assertTrue($this->isTextPresent('Pledge has been recorded and the payment schedule has been created.')); + $this->assertElementContainsText('crm-notification-container', "Pledge has been recorded and the payment schedule has been created."); // verify if Pledge is created $this->waitForElementPresent("xpath=//div[@id='Pledges']//table//tbody/tr[1]/td[10]/span/a[text()='View']"); @@ -92,8 +88,8 @@ class WebTest_Pledge_StandaloneAddDeleteTest extends CiviSeleniumTestCase { $this->click("xpath=//form[@id='Contribution']//div[2]/table/tbody/tr[3]/td[2]/a"); $this->type('total_amount', '300.00'); $this->click('_qf_Contribution_upload-bottom'); - $this->waitForPageToLoad("30000"); - $this->assertTrue($this->isTextPresent("The contribution record has been saved.")); + $this->waitForPageToLoad("30000"); + $this->assertElementContainsText('crm-notification-container', "The contribution record has been saved."); $this->waitForElementPresent("xpath=//div[@id='Pledges']//table//tbody/tr[1]/td[10]/span/a[text()='View']"); $this->click("xpath=//div[@id='Pledges']//table//tbody/tr[1]/td[1]/span/a"); @@ -103,8 +99,8 @@ class WebTest_Pledge_StandaloneAddDeleteTest extends CiviSeleniumTestCase { $this->click("xpath=//form[@id='Contribution']//div[2]/table/tbody/tr[3]/td[2]/a"); $this->type('total_amount', '250.00'); $this->click('_qf_Contribution_upload-bottom'); - $this->waitForPageToLoad("30000"); - $this->assertTrue($this->isTextPresent("The contribution record has been saved.")); + $this->waitForPageToLoad("30000"); + $this->assertElementContainsText('crm-notification-container', "The contribution record has been saved."); $this->waitForElementPresent("xpath=//div[@id='Pledges']//table//tbody/tr[1]/td[10]/span/a[text()='View']"); $this->click("xpath=//div[@id='Pledges']//table//tbody/tr[1]/td[1]/span/a"); @@ -114,8 +110,8 @@ class WebTest_Pledge_StandaloneAddDeleteTest extends CiviSeleniumTestCase { $this->click("xpath=//form[@id='Contribution']//div[2]/table/tbody/tr[3]/td[2]/a"); $this->type('total_amount', '170.00'); $this->click('_qf_Contribution_upload-bottom'); - $this->waitForPageToLoad("30000"); - $this->assertTrue($this->isTextPresent("The contribution record has been saved.")); + $this->waitForPageToLoad("30000"); + $this->assertElementContainsText('crm-notification-container', "The contribution record has been saved."); // delete the contribution associated with the 2nd payment $this->waitForElementPresent("xpath=//div[@id='Pledges']//table//tbody/tr[1]/td[10]/span/a[text()='View']"); diff --git a/tests/phpunit/WebTest/Pledge/StandaloneAddTest.php b/tests/phpunit/WebTest/Pledge/StandaloneAddTest.php index 0ecfd5e5c8..6cdc0c146c 100644 --- a/tests/phpunit/WebTest/Pledge/StandaloneAddTest.php +++ b/tests/phpunit/WebTest/Pledge/StandaloneAddTest.php @@ -41,11 +41,7 @@ class WebTest_Pledge_StandaloneAddTest extends CiviSeleniumTestCase { $this->webtestLogin(); // Go directly to the URL of the screen that you will be testing (New Pledge-standalone). - $this->open($this->sboxPath . 'civicrm/pledge/add?reset=1&context=standalone'); - - // 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_Pledge_upload'); + $this->openCiviPage('pledge/add', 'reset=1&context=standalone', '_qf_Pledge_upload'); // create new contact using dialog $firstName = 'Ma' . substr(sha1(rand()), 0, 4); @@ -84,7 +80,7 @@ class WebTest_Pledge_StandaloneAddTest extends CiviSeleniumTestCase { $this->click('_qf_Pledge_upload-bottom'); $this->waitForPageToLoad($this->getTimeoutMsec()); - $this->assertTrue($this->isTextPresent('Pledge has been recorded and the payment schedule has been created.')); + $this->assertElementContainsText('crm-notification-container', "Pledge has been recorded and the payment schedule has been created."); // verify if Pledge is created $this->waitForElementPresent("xpath=//div[@id='Pledges']//table//tbody/tr[1]/td[10]/span/a[text()='View']"); -- 2.25.1