From 24f591b0f7887547a8d5df4511af3848fbbada35 Mon Sep 17 00:00:00 2001 From: jitendrapurohit Date: Tue, 26 Apr 2016 18:49:18 +0530 Subject: [PATCH] CRM-18454: webtest fixes CRM-18454: webtest fixes --- tests/phpunit/CiviTest/CiviSeleniumTestCase.php | 2 ++ tests/phpunit/WebTest/ACL/AssignUsersToRolesTest.php | 2 +- tests/phpunit/WebTest/Case/AddCaseTest.php | 6 +++--- tests/phpunit/WebTest/Contact/CustomDataAddTest.php | 2 +- .../phpunit/WebTest/Contribute/ContributionPageAddTest.php | 5 +++-- tests/phpunit/WebTest/Contribute/PCPAddTest.php | 4 ++-- tests/phpunit/WebTest/Contribute/StandaloneAddTest.php | 4 ++-- .../Contribute/UpdateBatchPendingContributionTest.php | 4 ++-- 8 files changed, 16 insertions(+), 13 deletions(-) diff --git a/tests/phpunit/CiviTest/CiviSeleniumTestCase.php b/tests/phpunit/CiviTest/CiviSeleniumTestCase.php index 4fb2fda525..e2da3a3c16 100644 --- a/tests/phpunit/CiviTest/CiviSeleniumTestCase.php +++ b/tests/phpunit/CiviTest/CiviSeleniumTestCase.php @@ -627,6 +627,8 @@ class CiviSeleniumTestCase extends PHPUnit_Extensions_SeleniumTestCase { $tableLocator = "[@id='$tableId']"; } foreach ($expected as $label => $value) { + //assertContains() accepts param as string + $value = "$value"; if ($xpathPrefix) { $this->waitForElementPresent("xpath=//table{$tableLocator}/tbody/tr/td{$xpathPrefix}[text()='{$label}']/../following-sibling::td"); $this->assertElementContainsText("xpath=//table{$tableLocator}/tbody/tr/td{$xpathPrefix}[text()='{$label}']/../following-sibling::td", $value); diff --git a/tests/phpunit/WebTest/ACL/AssignUsersToRolesTest.php b/tests/phpunit/WebTest/ACL/AssignUsersToRolesTest.php index 525d85bcf3..39ea8db299 100644 --- a/tests/phpunit/WebTest/ACL/AssignUsersToRolesTest.php +++ b/tests/phpunit/WebTest/ACL/AssignUsersToRolesTest.php @@ -145,7 +145,7 @@ class WebTest_ACL_AssignUsersToRolesTest extends CiviSeleniumTestCase { $smartGroupTitle = "SmartGroup" . substr(sha1(rand()), 0, 4); $this->type("title", $smartGroupTitle); $this->clickLink("_qf_SaveSearch_next-bottom"); - $this->waitForText('crm-notification-container', "Your smart group has been saved as \'$smartGroupTitle\'"); + $this->waitForText('crm-notification-container', "Your smart group has been saved as '$smartGroupTitle'"); //Create ACL role $this->openCiviPage("admin/options/acl_role", "reset=1", "xpath=//a[@class='button new-option']"); diff --git a/tests/phpunit/WebTest/Case/AddCaseTest.php b/tests/phpunit/WebTest/Case/AddCaseTest.php index 379664e09f..6c4bb2d6be 100644 --- a/tests/phpunit/WebTest/Case/AddCaseTest.php +++ b/tests/phpunit/WebTest/Case/AddCaseTest.php @@ -195,7 +195,7 @@ class WebTest_Case_AddCaseTest extends CiviSeleniumTestCase { $this->waitForElementPresent("xpath=//table[@id='caseRoles-selector-$id']/tbody/tr[4]/td[2]/a"); // check that expected roles are listed in the Case Roles pane foreach ($caseRoles as $role) { - $this->assertElementContainsText("xpath=//table[@id='caseRoles-selector-$id']/tbody/tr[4]/td[1]", $role); + $this->assertElementContainsText("css=div.crm-case-roles-block", $role); } // check that case creator role has been assigned to logged in user $this->assertElementContainsText("xpath=//table[@id='caseRoles-selector-$id']/tbody/tr[4]/td[2]", $creatorName); @@ -208,7 +208,7 @@ class WebTest_Case_AddCaseTest extends CiviSeleniumTestCase { $id = $this->urlArg('id'); // check that expected auto-created activities are listed in the Case Activities table foreach ($activityTypes as $aType) { - $this->assertText("case_id_$id", $aType); + $this->assertElementContainsText("case_id_$id", $aType); } } @@ -219,7 +219,7 @@ class WebTest_Case_AddCaseTest extends CiviSeleniumTestCase { public function _testVerifyOpenCaseActivity($subject, $openCaseData) { $id = $this->urlArg('id'); // check that open case subject is present - $this->assertText("case_id_$id", $subject); + $this->assertElementContainsText("case_id_$id", $subject); // click open case activity pop-up dialog $this->click("xpath=//table[@id='case_id_{$id}']/tbody//tr/td[2]/div[text()='{$subject}']/../../td[8]/a[text()='View']"); $this->waitForElementPresent("ActivityView"); diff --git a/tests/phpunit/WebTest/Contact/CustomDataAddTest.php b/tests/phpunit/WebTest/Contact/CustomDataAddTest.php index 1c3d2b1dcc..bb0b27ad0c 100644 --- a/tests/phpunit/WebTest/Contact/CustomDataAddTest.php +++ b/tests/phpunit/WebTest/Contact/CustomDataAddTest.php @@ -232,7 +232,7 @@ class WebTest_Contact_CustomDataAddTest extends CiviSeleniumTestCase { //verify the money custom field value in the proper format $this->assertTrue($this->isElementPresent("xpath=//div[@id='custom-set-content-{$customFieldsetId}']/div/div[2]/div[2]")); - $this->verifyText("xpath=//div[@id='custom-set-content-{$customFieldsetId}']/div/div[2]/div[2]", '12,345,678.98'); + $this->assertElementContainsText("xpath=//div[@id='custom-set-content-{$customFieldsetId}']/div/div[2]/div[2]", '12,345,678.98'); } public function testCustomDataChangeLog() { diff --git a/tests/phpunit/WebTest/Contribute/ContributionPageAddTest.php b/tests/phpunit/WebTest/Contribute/ContributionPageAddTest.php index 377e79fde7..9263fade25 100644 --- a/tests/phpunit/WebTest/Contribute/ContributionPageAddTest.php +++ b/tests/phpunit/WebTest/Contribute/ContributionPageAddTest.php @@ -259,8 +259,9 @@ class WebTest_Contribute_ContributionPageAddTest extends CiviSeleniumTestCase { $this->waitForElementPresent("financial_type_id"); $this->type("sort_name", $firstName); $this->select('financial_type_id', "label=Donation"); - $this->clickLink('_qf_Search_refresh', "xpath=//table[@class='selector row-highlight']/tbody/tr/td[10]/span//a[text()='View']", FALSE); - $this->click("xpath=//div[@id='contributionSearch']/table[@class='selector row-highlight']/tbody/tr/td[10]/span//a[text()='View']"); + $this->clickLink('_qf_Search_refresh', "xpath=//table[@class='selector row-highlight']/tbody/tr/td[4][text()='Donation']/../td[10]/span//a[text()='View']", FALSE); + $this->click("xpath=//table[@class='selector row-highlight']/tbody/tr/td[4][text()='Donation']/../td[10]/span//a[text()='View']"); + $this->waitForElementPresent("xpath=//table/tbody/tr/td[text()='From']/following-sibling::td"); $this->waitForAjaxContent(); $expected = array( 'From' => "{$firstName} {$lastName}", diff --git a/tests/phpunit/WebTest/Contribute/PCPAddTest.php b/tests/phpunit/WebTest/Contribute/PCPAddTest.php index 8f903f2532..8b9d9eb642 100644 --- a/tests/phpunit/WebTest/Contribute/PCPAddTest.php +++ b/tests/phpunit/WebTest/Contribute/PCPAddTest.php @@ -203,8 +203,8 @@ class WebTest_Contribute_PCPAddTest extends CiviSeleniumTestCase { // Check PCP Summary Report $this->openCiviPage('report/instance/17', 'reset=1'); - $this->verifyText("PCP", preg_quote($pcpTitle)); - $this->verifyText("PCP", preg_quote("{$lastName}, {$firstName}")); + $this->assertElementContainsText("PCP", $pcpTitle); + $this->assertElementContainsText("PCP", "{$lastName}, {$firstName}"); } } diff --git a/tests/phpunit/WebTest/Contribute/StandaloneAddTest.php b/tests/phpunit/WebTest/Contribute/StandaloneAddTest.php index 5b67c6c1c0..70f39ac2cd 100644 --- a/tests/phpunit/WebTest/Contribute/StandaloneAddTest.php +++ b/tests/phpunit/WebTest/Contribute/StandaloneAddTest.php @@ -225,7 +225,7 @@ class WebTest_Contribute_StandaloneAddTest extends CiviSeleniumTestCase { $this->select("financial_type_id", "label={$financialType['name']}"); $this->clickLink("_qf_Search_refresh"); $this->assertElementContainsText("xpath=//div[@class='crm-content-block']//div[@id='search-status']/table/tbody/tr[1]/td[1]", "2 Result"); - $this->assertElementContainsText("xpath=//div[@class='crm-content-block']//div[@id='search-status']/table/tbody/tr[1]/td[2]", "Financial Type ID In {$financialType['name']}"); + $this->assertElementContainsText("xpath=//div[@class='crm-content-block']//div[@id='search-status']/table/tbody/tr[1]/td[2]", "Financial Type In {$financialType['name']}"); $this->openCiviPage("contact/search/advanced", "reset=1", "_qf_Advanced_refresh-top"); $this->clickAjaxLink('CiviContribute', "financial_type_id"); @@ -234,7 +234,7 @@ class WebTest_Contribute_StandaloneAddTest extends CiviSeleniumTestCase { $this->select("financial_type_id", "label={$financialType['name']}"); $this->clickLink("_qf_Advanced_refresh-top"); $this->assertElementContainsText("xpath=//div[@class='crm-content-block']//div[@id='search-status']//table/tbody/tr[1]/td[1]", "2 Contacts"); - $this->assertElementContainsText("xpath=//div[@class='crm-content-block']//div[@id='search-status']//table/tbody/tr[1]/td[2]", "Financial Type ID In {$financialType['name']}"); + $this->assertElementContainsText("xpath=//div[@class='crm-content-block']//div[@id='search-status']//table/tbody/tr[1]/td[2]", "Financial Type In {$financialType['name']}"); } /** diff --git a/tests/phpunit/WebTest/Contribute/UpdateBatchPendingContributionTest.php b/tests/phpunit/WebTest/Contribute/UpdateBatchPendingContributionTest.php index 953b2a2aa2..8ebd8dc429 100644 --- a/tests/phpunit/WebTest/Contribute/UpdateBatchPendingContributionTest.php +++ b/tests/phpunit/WebTest/Contribute/UpdateBatchPendingContributionTest.php @@ -93,8 +93,8 @@ class WebTest_Contribute_UpdateBatchPendingContributionTest extends CiviSelenium // Search the participants $this->openCiviPage("event/search", "reset=1", '_qf_Search_refresh'); - $eventName = 'Rain'; - $this->select2("event_id", $eventName); + $eventName = 'Rain-forest Cup Youth Soccer Tournament'; + $this->select2("event_id", $eventName, TRUE); $this->click('_qf_Search_refresh'); $this->openCiviPage("contribute/search", "reset=1", "contribution_date_low"); -- 2.25.1