From: Pratik Joshi Date: Fri, 1 Mar 2013 16:36:48 +0000 (+0530) Subject: more webtest cleanup and code improvement X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=b25525771f4807d9a5ec9a157d40a0350dcdec50;p=civicrm-core.git more webtest cleanup and code improvement --- diff --git a/tests/phpunit/WebTest/Profile/BatchUpdateTest.php b/tests/phpunit/WebTest/Profile/BatchUpdateTest.php index b38e62a34b..396617e921 100644 --- a/tests/phpunit/WebTest/Profile/BatchUpdateTest.php +++ b/tests/phpunit/WebTest/Profile/BatchUpdateTest.php @@ -44,19 +44,19 @@ class WebTest_Profile_BatchUpdateTest extends CiviSeleniumTestCase { // Log in using webtestLogin() method $this->webtestLogin(); - + // Add new individual using Quick Add block on the main page $firstName1 = "John_" . substr(sha1(rand()), 0, 7); $lastName1 = "Smiths_x" . substr(sha1(rand()), 0, 7); $Name1 = $lastName1 . ', ' . $firstName1; $this->webtestAddContact($firstName1, $lastName1, "$firstName1.$lastName1@example.com"); $this->waitForPageToLoad($this->getTimeoutMsec()); - + // Add new individual using Quick Add block on the main page $firstName2 = "James_" . substr(sha1(rand()), 0, 7); $lastName2 = "Smiths_x" . substr(sha1(rand()), 0, 7); $Name2 = $lastName2 . ', ' . $firstName2; - + $firstName3 = "James_" . substr(sha1(rand()), 0, 7); $lastName3 = "Smiths_x" . substr(sha1(rand()), 0, 7); $Name3 = $lastName3 . ', ' . $firstName3; @@ -73,9 +73,7 @@ class WebTest_Profile_BatchUpdateTest extends CiviSeleniumTestCase { 'label' => 'Last Name' )); $this->addProfile($profileTitle, $profileFields); - - $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', "Smiths_x"); $this->click('_qf_Basic_refresh'); $this->waitForElementPresent('_qf_Basic_next_print'); @@ -96,9 +94,9 @@ class WebTest_Profile_BatchUpdateTest extends CiviSeleniumTestCase { $this->isElementPresent("xpath=//form[@id='Batch']/div[2]/table/tbody//tr/td[text()='{$Name2}']"); $this->isElementPresent("xpath=//form[@id='Batch']/div[2]/table/tbody//tr/td[text()='{$Name1}']"); $this->isElementPresent("xpath=//form[@id='Batch']/div[2]/table/tbody//tr/td[text()='{$Name3}']"); - // selecting first check of profile + // selecting first check of profile $this->click("xpath=//form[@id='Batch']/div[2]/table/tbody/tr/td[2]/input"); - + $this->waitForElementPresent('_qf_Batch_next'); $this->click("xpath=//table[@class='crm-copy-fields']/thead/tr/td[2]/img"); sleep(5); @@ -108,28 +106,24 @@ class WebTest_Profile_BatchUpdateTest extends CiviSeleniumTestCase { $this->waitForElementPresent('_qf_Result_done'); $this->click('_qf_Result_done'); - // Find contact and assert for contact sub type - $this->open($this->sboxPath . "civicrm/contact/search?reset=1"); - $this->waitForElementPresent('_qf_Basic_refresh'); - + // Find contact and assert for contact sub type + $this->openCiviPage('contact/search', 'reset=1', '_qf_Basic_refresh'); $this->type('sort_name', $firstName2); $this->click('_qf_Basic_refresh'); $this->waitForElementPresent("xpath=//div[@class='crm-search-results']/table/tbody//td/span/a[text()='View']"); $this->click("xpath=//div[@class='crm-search-results']/table/tbody//td/span/a[text()='View']"); - $this->waitForPageToLoad($this->getTimeoutMsec()); + $this->waitForPageToLoad($this->getTimeoutMsec()); $xpath = "xpath=//div[@id='contact-summary']/div/div[2]/div/div/div[2]/div[@class='crm-content crm-contact_type_label']"; $this->verifyText($xpath, preg_quote("Student")); - $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', $firstName3); $this->click('_qf_Basic_refresh'); $this->waitForElementPresent("xpath=//div[@class='crm-search-results']/table/tbody//td/span/a[text()='View']"); $this->click("xpath=//div[@class='crm-search-results']/table/tbody//td/span/a[text()='View']"); - $this->waitForPageToLoad($this->getTimeoutMsec()); - + $this->waitForPageToLoad($this->getTimeoutMsec()); + $xpath = "xpath=//div[@id='contact-summary']/div/div[2]/div/div/div[2]/div[@class='crm-content crm-contact_type_label']"; $this->verifyText($xpath, preg_quote("Staff")); } @@ -161,15 +155,13 @@ class WebTest_Profile_BatchUpdateTest extends CiviSeleniumTestCase { $this->_addProfile($profileTitle, $customDataArr, $profileFor); //setting ckeditor as WYSIWYG - $this->open($this->sboxPath . "civicrm/admin/setting/preferences/display?reset=1"); - $this->waitForElementPresent('_qf_Display_next-bottom'); + $this->openCiviPage('admin/setting/preferences/display', 'reset=1', '_qf_Display_next-bottom'); $this->select('editor_id', 'CKEditor'); $this->click('_qf_Display_next-bottom'); $this->waitForPageToLoad($this->getTimeoutMsec()); // Find Contact - $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', $lastName); $this->click('_qf_Basic_refresh'); $this->waitForElementPresent('_qf_Basic_next_print'); @@ -192,7 +184,7 @@ class WebTest_Profile_BatchUpdateTest extends CiviSeleniumTestCase { // selecting first check of profile $this->click("xpath=//form[@id='Batch']/div[2]/table/tbody/tr/td[2]/table/tbody/tr/td/input[2]"); - + // selecting second check of profile $this->click("xpath=//form[@id='Batch']/div[2]/table/tbody/tr/td[3]/input[2]"); // clicking copy values to rows of first check and verifying @@ -314,15 +306,13 @@ class WebTest_Profile_BatchUpdateTest extends CiviSeleniumTestCase { $this->assertTrue($assertCheck, 'copy rows for field two failed[radio button]'); //test with tinymce editor - $this->open($this->sboxPath . "civicrm/admin/setting/preferences/display?reset=1"); - $this->waitForElementPresent('_qf_Display_next-bottom'); + $this->openCiviPage('admin/setting/preferences/display', 'reset=1', '_qf_Display_next-bottom'); $this->select('editor_id', 'TinyMCE'); $this->click('_qf_Display_next-bottom'); $this->waitForPageToLoad($this->getTimeoutMsec()); // Find Contact - $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', $lastName); $this->click('_qf_Basic_refresh'); $this->waitForElementPresent('_qf_Basic_next_print'); @@ -361,10 +351,8 @@ class WebTest_Profile_BatchUpdateTest extends CiviSeleniumTestCase { $this->assertTrue($assertCheck, 'Rich Text Area coping failed [TinyMCE]'); //campaign test for interview - // Enable CiviCampaign module if necessary - $this->open($this->sboxPath . "civicrm/admin/setting/component?reset=1"); - $this->waitForPageToLoad($this->getTimeoutMsec()); - $this->waitForElementPresent("_qf_Component_next-bottom"); + //enable CiviCampaign module if necessary + $this->openCiviPage('admin/setting/component', 'reset=1', '_qf_Component_next-bottom'); $enabledComponents = $this->getSelectOptions("enableComponents-t"); if (!in_array("CiviCampaign", $enabledComponents)) { $this->addSelection("enableComponents-f", "label=CiviCampaign"); @@ -372,12 +360,11 @@ class WebTest_Profile_BatchUpdateTest extends CiviSeleniumTestCase { $this->click("add"); $this->click("_qf_Component_next-bottom"); $this->waitForPageToLoad($this->getTimeoutMsec()); - $this->assertTrue($this->isTextPresent("Your changes have been saved.")); + $this->assertElementContainsText('crm-notification-container', 'Changes Saved'); } //Adding a survey - $this->open($this->sboxPath . "civicrm/survey/add?reset=1"); - $this->waitForElementPresent('_qf_Main_upload-bottom'); + $this->openCiviPage('survey/add', 'reset=1', '_qf_Main_upload-bottom'); $surveyTitle = "BatchUpdateTest Survey" . substr(sha1(rand()), 0, 7); $this->type("title", $surveyTitle); $this->select('activity_type_id', 'label=Survey'); @@ -619,7 +606,7 @@ class WebTest_Profile_BatchUpdateTest extends CiviSeleniumTestCase { //setting options per line to check CRM-9938 $this->type("options_per_line", 2); - + //clicking save $this->click('_qf_Field_next'); $this->waitForPageToLoad($this->getTimeoutMsec()); @@ -772,5 +759,4 @@ class WebTest_Profile_BatchUpdateTest extends CiviSeleniumTestCase { return $returnArray; } -} - +} \ No newline at end of file diff --git a/tests/phpunit/WebTest/Profile/MultiRecordProfileAddTest.php b/tests/phpunit/WebTest/Profile/MultiRecordProfileAddTest.php index 5710cb2549..70cc419f30 100644 --- a/tests/phpunit/WebTest/Profile/MultiRecordProfileAddTest.php +++ b/tests/phpunit/WebTest/Profile/MultiRecordProfileAddTest.php @@ -60,7 +60,7 @@ class WebTest_Profile_MultiRecordProfileAddTest extends CiviSeleniumTestCase { $this->webtestLogin(); $this->_addNewProfile(TRUE, FALSE, TRUE); } - + function testAddNewNonMultiProfile() { // This is the path where our testing install resides. // The rest of URL is defined in CiviSeleniumTestCase base class, in @@ -75,7 +75,7 @@ class WebTest_Profile_MultiRecordProfileAddTest extends CiviSeleniumTestCase { $this->webtestLogin(); $this->_addNewProfile(FALSE); } - + function testNonSearchableMultiProfile() { // This is the path where our testing install resides. // The rest of URL is defined in CiviSeleniumTestCase base class, in @@ -90,18 +90,15 @@ class WebTest_Profile_MultiRecordProfileAddTest extends CiviSeleniumTestCase { $this->webtestLogin(); $this->_addNewProfile(TRUE, TRUE); } - + function _addNewProfile($checkMultiRecord = TRUE, $checkSearchable = FALSE, $userCheck = FALSE) { - $params = $this->_testCustomAdd($checkSearchable); // Go directly to the URL of the screen that you will be // testing (Add new profile ). $this->open($this->sboxPath . 'civicrm/admin/uf/group?reset=1'); - $this->waitForPageToLoad($this->getTimeoutMsec()); - - $this->click('newCiviCRMProfile-top'); + $this->click('newCiviCRMProfile-top'); $this->waitForElementPresent('_qf_Group_next-bottom'); //Name of profile @@ -149,7 +146,7 @@ class WebTest_Profile_MultiRecordProfileAddTest extends CiviSeleniumTestCase { $this->waitForElementPresent('field_name[0]'); $this->click('field_name[0]'); $this->select('field_name[0]', 'value=Contact'); - $this->click("//option[@value='Contact']"); + $this->click("//option[@value='Contact']"); $this->click('field_name_1'); $this->select('field_name_1', 'label='.$params['textFieldLabel'].' :: '.$params['customGroupTitle']); if ($checkMultiRecord) { @@ -186,7 +183,7 @@ class WebTest_Profile_MultiRecordProfileAddTest extends CiviSeleniumTestCase { $this->click('field_name[0]'); $this->select('field_name[0]', 'value=Student'); $this->click("//option[@value='Student']"); - + $this->click('field_name_1'); $this->select('field_name_1', 'value=first_name'); $this->click('is_multi_summary'); @@ -224,20 +221,18 @@ class WebTest_Profile_MultiRecordProfileAddTest extends CiviSeleniumTestCase { $recordNew = $this->_addRecords('Create'); $this->waitForPageToLoad($this->getTimeoutMsec()); $elements = $this->parseURL( ); - $gid = $elements['queryString']['gid']; $id = $elements['queryString']['id']; - + if ($userCheck) { - // Add Drupal user - $this->open($this->sboxPath . "civicrm/contact/view/useradd?reset=1&action=add&cid=$id"); - $this->waitForElementPresent('cms_name'); + //add drupal user + $this->openCiviPage('contact/view/useradd', "reset=1&action=add&cid=$id", 'cms_name'); $this->type('cms_name', $recordNew['firstname']); $this->type('cms_pass', $recordNew['firstname']); $this->type('cms_confirm_pass', $recordNew['firstname']); $this->click('_qf_Useradd_next-bottom'); $this->waitForPageToLoad($this->getTimeoutMsec()); - $this->open( $this->settings->sandboxPATH . "user/logout"); + $this->open($this->sboxPath . "user/logout"); $this->waitForPageToLoad($this->getTimeoutMsec()); $this->open("{$this->sboxPath}user"); // Make sure login form is available @@ -264,10 +259,10 @@ class WebTest_Profile_MultiRecordProfileAddTest extends CiviSeleniumTestCase { $record2 = $this->_addRecords(); $this->waitForPageToLoad($this->getTimeoutMsec()); $this->verifyText("//div[@id='browseValues']/div/div/table/tbody/tr[3]/td[1]", preg_quote($record2['text'])); - + // Check Max Record Limit $this->verifyElementNotPresent("//div[@id='crm-profile-block']/a/span"); - + //Check for edit functionality sleep(3); $this->click("//div[@id='browseValues']/div/div/table/tbody/tr/td[3]/span/a[text()='Edit']"); @@ -277,14 +272,14 @@ class WebTest_Profile_MultiRecordProfileAddTest extends CiviSeleniumTestCase { $this->click("//div[@id='profile-dialog']/div/form/div[2]/div[2]/span/input[@id='_qf_Edit_next']"); $this->waitForPageToLoad($this->getTimeoutMsec()); $this->verifyText("//div[@id='browseValues']/div/div/table/tbody/tr[1]/td[1]", preg_quote($recordNew['text'].'edit')); - + // Check the delete functionality $this->click("//div[@id='browseValues']/div/div/table/tbody/tr/td[3]/span/a[text()='Delete']"); $this->waitForElementPresent("//html/body/div[5]"); sleep(3); $this->assertTrue($this->isTextPresent('Are you sure you want to delete this record?')); $this->click('_qf_Edit_upload_delete'); - + // Check the view functionality sleep(3); $this->click("//div[@id='browseValues']/div/div/table/tbody/tr/td[3]/span/a[text()='View']"); @@ -295,7 +290,7 @@ class WebTest_Profile_MultiRecordProfileAddTest extends CiviSeleniumTestCase { $this->verifyElementNotPresent("//div[@id='profile-dialog']/div/div/div/div[1]/div[2]/a"); return; } - + // Check Search Functionality if (!$userCheck) { $this->click("//div[@id='profile-dialog']/div/div/div/div/div[2]/a");