From: jitendrapurohit Date: Thu, 21 Apr 2016 13:24:18 +0000 (+0530) Subject: CRM-18454: webtest fixes X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=b02d5792ce9aeaddf7ed35b94e88f2d3df6212d3;p=civicrm-core.git CRM-18454: webtest fixes --- diff --git a/tests/phpunit/CiviTest/CiviSeleniumTestCase.php b/tests/phpunit/CiviTest/CiviSeleniumTestCase.php index 0493eacb80..8be6a5382c 100644 --- a/tests/phpunit/CiviTest/CiviSeleniumTestCase.php +++ b/tests/phpunit/CiviTest/CiviSeleniumTestCase.php @@ -629,11 +629,11 @@ class CiviSeleniumTestCase extends PHPUnit_Extensions_SeleniumTestCase { foreach ($expected as $label => $value) { if ($xpathPrefix) { $this->waitForElementPresent("xpath=//table{$tableLocator}/tbody/tr/td{$xpathPrefix}[text()='{$label}']/../following-sibling::td"); - $this->verifyText("xpath=//table{$tableLocator}/tbody/tr/td{$xpathPrefix}[text()='{$label}']/../following-sibling::td", preg_quote($value)); + $this->assertElementContainsText("xpath=//table{$tableLocator}/tbody/tr/td{$xpathPrefix}[text()='{$label}']/../following-sibling::td", $value); } else { $this->waitForElementPresent("xpath=//table{$tableLocator}/tbody/tr/td[text()='{$label}']/following-sibling::td"); - $this->verifyText("xpath=//table{$tableLocator}/tbody/tr/td[text()='{$label}']/following-sibling::td", preg_quote($value)); + $this->assertElementContainsText("xpath=//table{$tableLocator}/tbody/tr/td[text()='{$label}']/following-sibling::td", $value); } } } @@ -695,7 +695,7 @@ class CiviSeleniumTestCase extends PHPUnit_Extensions_SeleniumTestCase { } $this->type("option_label_{$oIndex}", $oValue['label']); $this->type("option_amount_{$oIndex}", $oValue['amount']); - $this->click('link=another choice'); + $this->click('link=add another choice'); } } diff --git a/tests/phpunit/WebTest/Contact/AdvancedSearchTest.php b/tests/phpunit/WebTest/Contact/AdvancedSearchTest.php index 2fbc988883..c8665c99dd 100644 --- a/tests/phpunit/WebTest/Contact/AdvancedSearchTest.php +++ b/tests/phpunit/WebTest/Contact/AdvancedSearchTest.php @@ -197,7 +197,7 @@ class WebTest_Contact_AdvancedSearchTest extends CiviSeleniumTestCase { //pagination and row count assertion $pagerCount = "Contact {$j} - {$subTotal} of {$count}"; - $this->verifyText("xpath=//div[@class='crm-search-results']/div[@class='crm-pager']/span[@class='crm-pager-nav']", preg_quote($pagerCount)); + $this->assertElementContainsText("xpath=//div[@class='crm-search-results']/div[@class='crm-pager']/span[@class='crm-pager-nav']", $pagerCount); $this->assertEquals($perPageRow, $this->getXpathCount("//div[@class='crm-search-results']/table/tbody/tr")); //go to next page @@ -209,7 +209,7 @@ class WebTest_Contact_AdvancedSearchTest extends CiviSeleniumTestCase { //pagination and row count assertion for the remaining last page if ($mod) { $pagerCount = "Contact {$lastPageSub} - {$count} of {$count}"; - $this->verifyText("xpath=//div[@class='crm-search-results']/div[@class='crm-pager']/span[@class='crm-pager-nav']", preg_quote($pagerCount)); + $this->assertElementContainsText("xpath=//div[@class='crm-search-results']/div[@class='crm-pager']/span[@class='crm-pager-nav']", $pagerCount); $this->assertEquals($mod, $this->getXpathCount("//div[@class='crm-search-results']/table/tbody/tr")); } } diff --git a/tests/phpunit/WebTest/Contact/GroupAddTest.php b/tests/phpunit/WebTest/Contact/GroupAddTest.php index 2793bf8b2c..1eb8ad4dde 100644 --- a/tests/phpunit/WebTest/Contact/GroupAddTest.php +++ b/tests/phpunit/WebTest/Contact/GroupAddTest.php @@ -73,31 +73,31 @@ class WebTest_Contact_GroupAddTest extends CiviSeleniumTestCase { $this->openCiviPage('group', 'reset=1'); $this->type('title', $params['name']); - $this->click('_qf_Search_refresh'); + $this->click('title'); $this->waitForAjaxContent(); - $this->waitForElementPresent("xpath=//table[@class='crm-group-selector no-footer dataTable']/tbody/tr/td/span[contains(text(), '{$params['name']}')]"); - $createdBy = $this->getText("xpath=//table[@class='crm-group-selector no-footer dataTable']/tbody/tr/td[3]/a"); - $this->click("xpath=//table[@class='crm-group-selector no-footer dataTable']/tbody/tr/td[7]//span/a[text()='Settings']"); + $this->waitForElementPresent("xpath=//table/tbody/tr/td/div[contains(text(), '{$params['name']}')]"); + $createdBy = $this->getText("xpath=//table/tbody/tr/td[3]/a"); + $this->click("xpath=//table/tbody/tr/td[7]//span/a[text()='Settings']"); $this->waitForElementPresent("xpath=//form[@id='Edit']/div[2]/div/table[1]/tbody/tr[2]/td[contains(text(), '{$createdBy}')]"); $this->openCiviPage('group', 'reset=1'); //search groups using created by $this->type('created_by', $createdBy); - $this->click('_qf_Search_refresh'); + $this->click('created_by'); //show maximum no. of groups on first result set page //as many groups can be created by same creator //and checking is done on first result set page - $this->waitForVisible("xpath=//table[@class='crm-group-selector no-footer dataTable']"); + $this->waitForVisible("xpath=//table[@class='crm-group-selector crm-ajax-table dataTable no-footer']"); $this->select("xpath=//div[@class='dataTables_length']/label/select", '100'); - $this->waitForVisible("xpath=//table[@class='crm-group-selector no-footer dataTable']"); + $this->waitForVisible("xpath=//table[@class='crm-group-selector crm-ajax-table dataTable no-footer']"); - $this->waitForElementPresent("xpath=//table[@class='crm-group-selector no-footer dataTable']/tbody/tr/td/span[contains(text(), '{$params['name']}')]"); - $this->click("xpath=//table[@class='crm-group-selector no-footer dataTable']/tbody/tr/td/span[contains(text(), '{$params['name']}')]/../following-sibling::td[2]/a[text()='{$createdBy}']"); - $this->waitForElementPresent("xpath=//table[@class='crm-group-selector no-footer dataTable']/tbody/tr/td/span[contains(text(), '{$params['name']}')]/../following-sibling::td[2]/a[text()='{$createdBy}']"); + $this->waitForElementPresent("xpath=//table/tbody/tr/td/div[contains(text(), '{$params['name']}')]"); + $this->click("xpath=//table/tbody/tr/td/div[contains(text(), '{$params['name']}')]/../following-sibling::td[2]/a[text()='{$createdBy}']"); + $this->waitForElementPresent("xpath=//table/tbody/tr/td/div[contains(text(), '{$params['name']}')]/../following-sibling::td[2]/a[text()='{$createdBy}']"); //check link of the contact who created the group - $this->clickLink("xpath=//table[@class='crm-group-selector no-footer dataTable']/tbody//tr/td[1]/span[contains(text(),'{$params['name']}')]/../following-sibling::td[2]/a", "css=div.crm-summary-display_name", FALSE); + $this->clickLink("xpath=//table/tbody//tr/td[1]/div[contains(text(),'{$params['name']}')]/../following-sibling::td[2]/a", "css=div.crm-summary-display_name", FALSE); $name = explode(',', $createdBy); $name1 = isset($name[1]) ? trim($name[1]) : NULL; $name0 = trim($name[0]); @@ -170,7 +170,7 @@ class WebTest_Contact_GroupAddTest extends CiviSeleniumTestCase { $this->openCiviPage('group', 'reset=1'); $this->type('title', $params['name']); - $this->click('_qf_Search_refresh'); + $this->click('title'); $this->waitForTextPresent("Adding new reserved group."); // Settings link should NOT be included in selector // after search returns with only the reserved group. @@ -254,8 +254,8 @@ class WebTest_Contact_GroupAddTest extends CiviSeleniumTestCase { $this->openCiviPage('group', 'reset=1'); $this->waitForElementPresent("xpath=//div[@id='crm-main-content-wrapper']/div[@class='crm-submit-buttons']/a/span[text()=' Add Group']"); - $this->waitForElementPresent("xpath=//table[@id='DataTables_Table_0']/tbody//tr/td[1]/span[contains(text(), '{$group}')]"); - $this->click("xpath=//table[@id='DataTables_Table_0']/tbody//tr/td[1]/span[text()='{$group}']/../../td[7]/span[1]/a[1]"); + $this->waitForElementPresent("xpath=//table[@id='DataTables_Table_0']/tbody//tr/td[1]/div[contains(text(), '{$group}')]"); + $this->click("xpath=//table[@id='DataTables_Table_0']/tbody//tr/td[1]/div[text()='{$group}']/../../td[7]/span[1]/a[1]"); $this->waitForPageToLoad($this->getTimeoutMsec()); $this->clickLink("xpath=//form[@id='Basic']/div[2]/a/span"); $this->waitForElementPresent("_qf_Basic_refresh"); diff --git a/tests/phpunit/WebTest/Contribute/AddPricesetTest.php b/tests/phpunit/WebTest/Contribute/AddPricesetTest.php index cfc1a887be..34f1d7ee0d 100644 --- a/tests/phpunit/WebTest/Contribute/AddPricesetTest.php +++ b/tests/phpunit/WebTest/Contribute/AddPricesetTest.php @@ -295,7 +295,7 @@ class WebTest_Contribute_AddPricesetTest extends CiviSeleniumTestCase { 11 => 'check #1041', ); foreach ($expected as $label => $value) { - $this->verifyText("xpath=id('ContributionView')/div[2]/table[1]/tbody/tr[$label]/td[2]", preg_quote($value)); + $this->assertElementContainsText("xpath=id('ContributionView')/div[2]/table[1]/tbody/tr[$label]/td[2]", $value); } $exp = array( @@ -305,9 +305,7 @@ class WebTest_Contribute_AddPricesetTest extends CiviSeleniumTestCase { ); foreach ($exp as $lab => $val) { - $this->verifyText("xpath=id('ContributionView')/div[2]/table[1]/tbody/tr[3]/td[2]/table/tbody/tr[$lab]/td[3]", - preg_quote($val) - ); + $this->assertElementContainsText("xpath=id('ContributionView')/div[2]/table[1]/tbody/tr[3]/td[2]/table/tbody/tr[$lab]/td[3]", $val); } } @@ -659,9 +657,7 @@ class WebTest_Contribute_AddPricesetTest extends CiviSeleniumTestCase { ); foreach ($exp as $lab => $val) { - $this->verifyText("xpath=id('ContributionView')/div[2]/table[1]/tbody/tr[3]/td[2]/table/tbody/tr[$lab]/td[3]", - preg_quote($val) - ); + $this->assertElementContainsText("xpath=id('ContributionView')/div[2]/table[1]/tbody/tr[3]/td[2]/table/tbody/tr[$lab]/td[3]", $val); } // verify if soft credit was created successfully @@ -671,7 +667,7 @@ class WebTest_Contribute_AddPricesetTest extends CiviSeleniumTestCase { ); foreach ($softCreditValues as $value) { - $this->verifyText("css=table.crm-soft-credit-listing", preg_quote($value)); + $this->assertElementContainsText("css=table.crm-soft-credit-listing", $value); } // Check for Soft contact created @@ -724,7 +720,7 @@ class WebTest_Contribute_AddPricesetTest extends CiviSeleniumTestCase { ); foreach ($softCreditValues as $value) { - $this->verifyText("css=table.crm-soft-credit-listing", preg_quote($value)); + $this->assertElementContainsText("css=table.crm-soft-credit-listing", $value); } }