From 44c45561d5bcda5c0e8fc243f9e76894c24174eb Mon Sep 17 00:00:00 2001 From: jitendrapurohit Date: Wed, 23 Apr 2014 17:42:42 +0530 Subject: [PATCH] Web Test Fix --- .../phpunit/CiviTest/CiviSeleniumTestCase.php | 2 +- .../WebTest/ACL/AssignUsersToRolesTest.php | 4 +- .../WebTest/Admin/MoveCustomDataTest.php | 2 +- .../WebTest/Admin/RelationshipTypeAddTest.php | 14 ++-- .../WebTest/Case/ActivityToCaseTest.php | 80 +++++++++---------- .../phpunit/WebTest/Contact/SignatureTest.php | 13 ++- 6 files changed, 54 insertions(+), 61 deletions(-) diff --git a/tests/phpunit/CiviTest/CiviSeleniumTestCase.php b/tests/phpunit/CiviTest/CiviSeleniumTestCase.php index dd18e94941..ec2e16bbb0 100644 --- a/tests/phpunit/CiviTest/CiviSeleniumTestCase.php +++ b/tests/phpunit/CiviTest/CiviSeleniumTestCase.php @@ -1893,7 +1893,7 @@ class CiviSeleniumTestCase extends PHPUnit_Extensions_SeleniumTestCase { $this->type("//*[@id='select2-drop']/div/input", $label); $this->typeKeys("//*[@id='select2-drop']/div/input", $label); $this->waitForElementPresent("//*[@class='select2-result-label']"); - $this->clickAt("//*[@class='select2-results']/li[1]"); + $this->clickAt("//*[@class='select2-result-label']"); } } } diff --git a/tests/phpunit/WebTest/ACL/AssignUsersToRolesTest.php b/tests/phpunit/WebTest/ACL/AssignUsersToRolesTest.php index ce76ab5c88..500bf8077b 100755 --- a/tests/phpunit/WebTest/ACL/AssignUsersToRolesTest.php +++ b/tests/phpunit/WebTest/ACL/AssignUsersToRolesTest.php @@ -48,9 +48,9 @@ class WebTest_ACL_AssignUsersToRolesTest extends CiviSeleniumTestCase { $label = "TestAclRole" . substr(sha1(rand()), 0, 4); $this->type("label", $label); - $this->clickLink("_qf_Options_next-bottom"); + $this->click("_qf_Options_next-bottom"); - $this->waitForText('crm-notification-container', "The Acl Role '{$label}' has been saved"); + $this->waitForText('crm-notification-container', "The ACL Role '{$label}' has been saved."); $this->openCiviPage("acl/entityrole", "action=add&reset=1"); diff --git a/tests/phpunit/WebTest/Admin/MoveCustomDataTest.php b/tests/phpunit/WebTest/Admin/MoveCustomDataTest.php index 5fb6bd3a47..b80bd1dc58 100644 --- a/tests/phpunit/WebTest/Admin/MoveCustomDataTest.php +++ b/tests/phpunit/WebTest/Admin/MoveCustomDataTest.php @@ -339,7 +339,7 @@ class WebTest_Admin_MoveCustomDataTest extends CiviSeleniumTestCase { $this->waitForPageToLoad($this->getTimeoutMsec()); //Is custom field created? - $this->waitForText('crm-notification-container', "Your custom field '$fieldLabel' has been saved."); + $this->waitForText('crm-notification-container', "Custom field '$fieldLabel' has been saved."); //get the custom id of the custom field that was just created $results = $this->webtest_civicrm_api("CustomField", "get", array('label' => $fieldLabel, 'custom_group_id' => $group_id)); diff --git a/tests/phpunit/WebTest/Admin/RelationshipTypeAddTest.php b/tests/phpunit/WebTest/Admin/RelationshipTypeAddTest.php index 403fa9a495..29b80533e0 100644 --- a/tests/phpunit/WebTest/Admin/RelationshipTypeAddTest.php +++ b/tests/phpunit/WebTest/Admin/RelationshipTypeAddTest.php @@ -44,7 +44,7 @@ class WebTest_Admin_RelationshipTypeAddTest extends CiviSeleniumTestCase { //load the form to add new relationship type. $this->click('link=Add Relationship Type'); - $this->waitForPageToLoad($this->getTimeoutMsec()); + $this->waitForElementPresent('_qf_RelationshipType_next-bottom'); //enter the relationship type values. $labelAB = 'Test Relationship Type A - B -' . rand(); @@ -57,11 +57,11 @@ class WebTest_Admin_RelationshipTypeAddTest extends CiviSeleniumTestCase { //save the data. $this->click('_qf_RelationshipType_next-bottom'); - $this->waitForPageToLoad($this->getTimeoutMsec()); //does data saved. $this->waitForText('crm-notification-container', 'The Relationship Type has been saved.'); + $this->waitForElementPresent('link=Add Relationship Type'); //validate data. $data = array( 'Relationship A to B' => $labelAB, @@ -87,7 +87,7 @@ class WebTest_Admin_RelationshipTypeAddTest extends CiviSeleniumTestCase { //validate form rules. $this->click('link=Add Relationship Type'); - $this->waitForPageToLoad($this->getTimeoutMsec()); + $this->waitForElementPresent('_qf_RelationshipType_next-bottom'); $this->select('contact_types_a', 'value=Individual'); $this->select('contact_types_b', 'value=Individual'); @@ -95,8 +95,7 @@ class WebTest_Admin_RelationshipTypeAddTest extends CiviSeleniumTestCase { $this->type('description', $description); $this->click('_qf_RelationshipType_next-bottom'); - $this->waitForPageToLoad($this->getTimeoutMsec()); - $this->waitForText('crm-notification-container', 'Relationship Label-A to B is a required field.'); + $this->waitForText("xpath=//*[@id='RelationshipType']/div[2]/table/tbody/tr[1]/td[2]/label[@class='error']", 'This field is required.'); //enter the relationship type values. $labelAB = 'Test Relationship Type A - B - DUPLICATE TO BE' . rand(); @@ -107,17 +106,16 @@ class WebTest_Admin_RelationshipTypeAddTest extends CiviSeleniumTestCase { $this->select('contact_types_b', "value=Individual"); $this->type('description', 'Test Relationship Type Description'); $this->click('_qf_RelationshipType_next-bottom'); - $this->waitForPageToLoad($this->getTimeoutMsec()); + $this->waitForElementPresent('link=Add Relationship Type'); $this->openCiviPage('admin/reltype', 'reset=1&action=browse'); $this->click('link=Add Relationship Type'); - $this->waitForPageToLoad($this->getTimeoutMsec()); + $this->waitForElementPresent('_qf_RelationshipType_next-bottom'); $this->type('label_a_b', $labelAB); $this->type('label_b_a', $labelBA); $this->click('_qf_RelationshipType_next-bottom'); - $this->waitForPageToLoad($this->getTimeoutMsec()); $this->waitForText('crm-notification-container', 'Label already exists in Database.'); } } diff --git a/tests/phpunit/WebTest/Case/ActivityToCaseTest.php b/tests/phpunit/WebTest/Case/ActivityToCaseTest.php index 8127057da8..48a2a4ecd3 100644 --- a/tests/phpunit/WebTest/Case/ActivityToCaseTest.php +++ b/tests/phpunit/WebTest/Case/ActivityToCaseTest.php @@ -54,7 +54,7 @@ class WebTest_Case_ActivityToCaseTest extends CiviSeleniumTestCase { $contactName = "{$lastName}, {$firstName}"; $displayName = "{$firstName} {$lastName}"; $email = "{$lastName}.{$firstName}@example.org"; - $this->webtestNewDialogContact($firstName, $lastName, $email, $type = 4); + $this->webtestNewDialogContact($firstName, $lastName, $email, $type = 4, "s2id_client_id"); // Fill in other form values. We'll use a case type which is included in CiviCase sample data / xml files. $caseTypeLabel = "Adult Day Care Referral"; @@ -73,7 +73,7 @@ class WebTest_Case_ActivityToCaseTest extends CiviSeleniumTestCase { $today = date('F jS, Y', strtotime('now')); $this->type('duration', "20"); - $this->clickLink('_qf_Case_upload-bottom', '_qf_CaseView_cancel-bottom'); + $this->clickLink('_qf_Case_upload-bottom', '_qf_CaseView_cancel-bottom', FALSE); // Is status message correct? $this->waitForText('crm-notification-container', "Case opened successfully."); @@ -106,26 +106,26 @@ class WebTest_Case_ActivityToCaseTest extends CiviSeleniumTestCase { $this->waitForElementPresent("_qf_Activity_upload-bottom"); // ...and verifying if the page contains properly formatted display name for chosen contact. - $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__); + $this->waitForText("xpath=//div[@id='s2id_target_contact_id']", '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()!)... - $this->click("css=tr.crm-activity-form-block-assignee_contact_id input#token-input-assignee_contact_id"); - $this->type("css=tr.crm-activity-form-block-assignee_contact_id input#token-input-assignee_contact_id", $firstName1); - $this->typeKeys("css=tr.crm-activity-form-block-assignee_contact_id input#token-input-assignee_contact_id", $firstName1); + $this->click("xpath=//div[@id='s2id_assignee_contact_id']/ul/li/input"); + $this->keyDown("xpath=//div[@id='s2id_assignee_contact_id']/ul/li/input", " "); + $this->type("xpath=//div[@id='s2id_assignee_contact_id']/ul/li/input", $firstName1); + $this->typeKeys("xpath=//div[@id='s2id_assignee_contact_id']/ul/li/input", $firstName1); // ...waiting for drop down with results to show up... - $this->waitForElementPresent("css=div.token-input-dropdown-facebook"); - $this->waitForElementPresent("css=li.token-input-dropdown-item2-facebook"); + $this->waitForElementPresent("xpath=//div[@class='select2-result-label']"); //..need to use mouseDownAt on first result (which is a li element), click does not work - $this->mouseDownAt("css=li.token-input-dropdown-item2-facebook"); + $this->clickAt("xpath=//div[@class='select2-result-label']"); // ...again, waiting for the box with contact name to show up... - $this->waitForElementPresent("css=tr.crm-activity-form-block-assignee_contact_id td ul li span.token-input-delete-token-facebook"); + $this->waitForText("xpath=//div[@id='s2id_assignee_contact_id']","$firstName1"); // ...and verifying if the page contains properly formatted display name for chosen contact. - $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__); + $this->assertElementContainsText("xpath=//div[@id='s2id_assignee_contact_id']", "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."; @@ -152,8 +152,9 @@ class WebTest_Case_ActivityToCaseTest extends CiviSeleniumTestCase { $this->select("priority_id", "value=1"); $textField = 'This is test custom data'; - $this->click($customGroupTitle); - $this->click("xpath=//div[@id='{$customGroupTitle}']/table/tbody/tr[2]/td[2]/table/tbody/tr/td[1]/input"); + $this->click("xpath=//div[@id='customData']//div[@class='custom-group custom-group-$customGroupTitle crm-accordion-wrapper collapsed']"); + $this->waitForElementPresent("xpath=//div[@class='crm-accordion-body']//table/tbody/tr[2]/td[2]/table/tbody/tr/td[1]/input"); + $this->click("xpath=//div[@class='crm-accordion-body']//table/tbody/tr[2]/td[2]/table/tbody/tr/td[1]/input"); $this->type($customDataParams[1], $textField); // Scheduling follow-up. @@ -164,47 +165,40 @@ class WebTest_Case_ActivityToCaseTest extends CiviSeleniumTestCase { // Clicking save. $this->click("_qf_Activity_upload-bottom"); - $this->waitForPageToLoad($this->getTimeoutMsec()); // Is status message correct? $this->waitForText('crm-notification-container', $subject); // click through to the Activity view screen - $this->waitForElementPresent("xpath=//div[@id='Activities']//table/tbody/tr[2]/td[8]"); - $this->click("xpath=//div[@id='Activities']//table/tbody/tr[2]/td[8]/span[2]/ul/li/a[text()='File On Case']"); + $this->waitForElementPresent("xpath=//div[@id='contact-activity-selector-activity_wrapper']//table/tbody/tr[1]/td[8]"); + $this->click("xpath=//div[@id='contact-activity-selector-activity_wrapper']//table/tbody/tr[2]/td[8]/span[2]/ul/li/a[text()='File On Case']"); $this->waitForElementPresent("css=div#fileOnCaseDialog"); - $this->waitForElementPresent('case_activity_subject'); + $this->waitForElementPresent('file_on_case_activity_subject'); // file activity on case - $this->type('unclosed_cases', $firstName); - $this->click('unclosed_cases'); - $this->waitForElementPresent("css=div.ac_results-inner li"); - $this->click("css=div.ac_results-inner li"); - $this->assertContains($firstName, $this->getValue('unclosed_cases'), - "autocomplete expected $firstName but didn’t find it in " . - $this->getValue('unclosed_cases') - ); - - $this->click("xpath=//div[@class='ui-dialog-buttonset']/button/span[text()='Ok']"); - $this->waitForElementPresent("xpath=//div[@id='Activities']//table/tbody/tr[1]/td[8]/span/a[text()='View']"); + $this->select2('file_on_case_unclosed_case_id', $firstName); + $this->assertElementContainsText("xpath=//div[@id='s2id_file_on_case_unclosed_case_id']", "$firstName", 'Contact not found in line ' . __LINE__); + $this->click("xpath=//div[@class='ui-dialog-buttonset']/button/span[text()='Save']"); + $this->waitForElementPresent("xpath=//div[@id='contact-activity-selector-activity_wrapper']//table/tbody/tr[1]/td[8]/span/a[text()='View']"); // verify if custom data is present $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]"); + $id = $this->urlArg('id'); + $this->waitForElementPresent("xpath=//div[@id='activities']//table[@id='case_id_".$id."']/tbody/tr[1]/td[2]"); - $this->click("xpath=//div[@id='activities']//table[@id='activities-selector']//a[text()='{$subject}']"); + $this->click("xpath=//div[@id='activities']//table[@id='case_id_".$id."']/tbody/tr[1]/td[2]//a[text()='{$subject}']"); - $this->waitForElementPresent('view-activity'); + $this->waitForElementPresent('ActivityView'); $this->waitForElementPresent("css=table#crm-activity-view-table tr.crm-case-activityview-form-block-groupTitle"); $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]"); + $this->click("xpath=//span[@class='ui-button-icon-primary ui-icon ui-icon-closethick']"); + $this->waitForElementPresent("xpath=//div[@id='activities']//table[@id='case_id_".$id."']/tbody/tr[1]/td[2]"); - $this->click("xpath=//div[@id='activities']//table[@id='activities-selector']/tbody//tr/td[2]/a[text()='{$subject}']/../../td[6]/a[text()='Scheduled']"); + $this->click("xpath=//div[@id='activities']//table[@id='case_id_".$id."']/tbody//tr/td[2]/a[text()='{$subject}']/../../td[6]/a[text()='Scheduled']"); $this->waitForElementPresent("xpath=//html/body/div[7]"); $this->waitForElementPresent('activity_change_status'); @@ -215,9 +209,10 @@ class WebTest_Case_ActivityToCaseTest extends CiviSeleniumTestCase { $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]"); - $this->click("xpath=//div[@id='activities']//table[@id='activities-selector']//a[text()='{$subject}']"); - $this->waitForElementPresent('view-activity'); + $id2 = $this->urlArg('id'); + $this->waitForElementPresent("xpath=//div[@id='activities']//table[@id='case_id_".$id2."']/tbody/tr[1]/td[2]"); + $this->click("xpath=//div[@id='activities']//table[@id='case_id_".$id2."']//a[text()='{$subject}']"); + $this->waitForElementPresent('ActivityView'); $this->waitForElementPresent("css=table#crm-activity-view-table tr.crm-case-activityview-form-block-groupTitle"); } @@ -277,11 +272,11 @@ class WebTest_Case_ActivityToCaseTest extends CiviSeleniumTestCase { $this->waitForPageToLoad($this->getTimeoutMsec()); //Is custom field created - $this->waitForText('crm-notification-container', "Your custom field '$radioFieldLabel' has been saved."); + $this->waitForText('crm-notification-container', "Custom field '$radioFieldLabel' has been saved."); // create another custom field - text field $this->click("//a[@id='newCustomField']/span"); - $this->waitForPageToLoad($this->getTimeoutMsec()); + $this->waitForElementPresent('_qf_Field_cancel-bottom'); $textFieldLabel = 'Custom Field Text_' . substr(sha1(rand()), 0, 4); $this->type('label', $textFieldLabel); @@ -297,11 +292,12 @@ class WebTest_Case_ActivityToCaseTest extends CiviSeleniumTestCase { //clicking save $this->click('_qf_Field_next'); - $this->waitForPageToLoad($this->getTimeoutMsec()); + $this->waitForElementPresent("//a[@id='newCustomField']/span"); //Is custom field created - $this->waitForText('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")); + $this->waitForText('crm-notification-container', "Custom field '$textFieldLabel' has been saved."); + $this->waitForElementPresent("xpath=//div[@id='field_page']//div//table/tbody//tr/td/span[text()='$textFieldLabel']"); + $textFieldId = explode('&id=', $this->getAttribute("xpath=//div[@id='field_page']//div//table/tbody//tr/td/span[text()='$textFieldLabel']/../../td[8]/span/a[text()='Edit Field']/@href")); $textFieldId = $textFieldId[1]; return array($radioOptionLabel1, "custom_{$textFieldId}_-1"); diff --git a/tests/phpunit/WebTest/Contact/SignatureTest.php b/tests/phpunit/WebTest/Contact/SignatureTest.php index 6a98c2653b..f73d90de67 100644 --- a/tests/phpunit/WebTest/Contact/SignatureTest.php +++ b/tests/phpunit/WebTest/Contact/SignatureTest.php @@ -50,7 +50,7 @@ class WebTest_Contact_SignatureTest extends CiviSeleniumTestCase { $this->openCiviPage("contact/add", "reset=1&action=update&cid=$contactId"); - $this->click("//tr[@id='Email_Block_1']/td[1]/div[2]/div[1]"); + $this->click("//tr[@id='Email_Block_1']/td[1]/div[3]/div[1]"); // HTML format message $signature = 'Contact Signature in html'; @@ -68,7 +68,7 @@ class WebTest_Contact_SignatureTest extends CiviSeleniumTestCase { // Go for Ckeck Your Editor, Click on Send Mail $this->click("//a[@id='crm-contact-actions-link']/span"); //after clicking on 'Send an Email', wait for the text in tinymce editor to load - $this->clickLink('link=Send an Email', "xpath=//body[@id='tinymce']/p[2]"); + $this->clickLink('link=Send an Email', "xpath=//body[@id='tinymce']/p[2]", FALSE); $this->click('subject'); $subject = 'Subject_' . substr(sha1(rand()), 0, 8); @@ -78,7 +78,6 @@ class WebTest_Contact_SignatureTest extends CiviSeleniumTestCase { $this->_checkSignature('html_message', $signature, 'TinyMCE'); $this->click('_qf_Email_upload-top'); - $this->waitForPageToLoad($this->getTimeoutMsec()); // Go for Activity Search $this->_checkActivity($subject, $signature); @@ -105,7 +104,7 @@ class WebTest_Contact_SignatureTest extends CiviSeleniumTestCase { $this->_selectEditor('CKEditor'); $this->openCiviPage("contact/add", "reset=1&action=update&cid={$contactId}"); - $this->click("//tr[@id='Email_Block_1']/td[1]/div[2]/div[1]"); + $this->click("//tr[@id='Email_Block_1']/td[1]/div[3]/div[1]"); // HTML format message $signature = 'Contact Signature in html'; @@ -122,7 +121,7 @@ class WebTest_Contact_SignatureTest extends CiviSeleniumTestCase { // Go for Ckeck Your Editor, Click on Send Mail $this->click("//a[@id='crm-contact-actions-link']/span"); - $this->clickLink('link=Send an Email', 'subject'); + $this->clickLink('link=Send an Email', 'subject', FALSE); $this->click('subject'); $subject = 'Subject_' . substr(sha1(rand()), 0, 7); @@ -132,7 +131,7 @@ class WebTest_Contact_SignatureTest extends CiviSeleniumTestCase { $this->_checkSignature('html_message', $signature, 'CKEditor'); $this->click('_qf_Email_upload-top'); - $this->waitForPageToLoad($this->getTimeoutMsec()); + $this->waitForElementPresent("//a[@id='crm-contact-actions-link']/span"); // Go for Activity Search $this->_checkActivity($subject, $signature); @@ -180,7 +179,7 @@ class WebTest_Contact_SignatureTest extends CiviSeleniumTestCase { $this->clickLink('_qf_Search_refresh', 'Search'); // View your Activity - $this->clickLink("xpath=id('Search')/div[3]/div/div[2]/table/tbody/tr[2]/td[9]/span/a[text()='View']", '_qf_ActivityView_next-bottom'); + $this->clickLink("xpath=id('Search')/div[3]/div/div[2]/table/tbody/tr[2]/td[9]/span/a[text()='View']", '_qf_ActivityView_cancel-bottom', FALSE); // Is signature correct? in Activity $this->assertTextPresent($signature); -- 2.25.1