From: jitendrapurohit Date: Thu, 2 Apr 2015 11:07:38 +0000 (+0530) Subject: webtest fixes 46 X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=06dfe3b5bb235a820cf33510a24163e6cf6a27ed;p=civicrm-core.git webtest fixes 46 --- diff --git a/tests/phpunit/CiviTest/CiviSeleniumTestCase.php b/tests/phpunit/CiviTest/CiviSeleniumTestCase.php index c2379df5af..03d4f8322a 100644 --- a/tests/phpunit/CiviTest/CiviSeleniumTestCase.php +++ b/tests/phpunit/CiviTest/CiviSeleniumTestCase.php @@ -2295,15 +2295,31 @@ class CiviSeleniumTestCase extends PHPUnit_Extensions_SeleniumTestCase { * Select multiple options. * @param $fieldid * @param $params + * @param $isDate if multiple date is to be selected from datepicker */ - public function multiselect2($fieldid, $params) { + public function multiselect2($fieldid, $params, $isDate = FALSE) { // In the case of chainSelect, wait for options to load $this->waitForElementNotPresent('css=select.loading'); foreach ($params as $value) { - $this->clickAt("xpath=//*[@id='$fieldid']/../div/ul//li/input"); - $this->waitForElementPresent("xpath=//ul[@class='select2-results']"); - $this->clickAt("xpath=//ul[@class='select2-results']//li/div[text()='$value']"); - $this->assertElementContainsText("xpath=//*[@id='$fieldid']/preceding-sibling::div[1]/", $value); + if ($isDate) { + $timeStamp = strtotime($value ? $value : '+1 month'); + $year = date('Y', $timeStamp); + // -1 ensures month number is inline with calender widget's month + $mon = date('n', $timeStamp) - 1; + $day = date('j', $timeStamp); + + $this->clickAt("xpath=//*[@id='$fieldid']/../div/ul//li/input"); + $this->waitForElementPresent("css=div#ui-datepicker-div.ui-datepicker div.ui-datepicker-header div.ui-datepicker-title select.ui-datepicker-month"); + $this->select("css=div#ui-datepicker-div.ui-datepicker div.ui-datepicker-header div.ui-datepicker-title select.ui-datepicker-month", "value=$mon"); + $this->select("css=div#ui-datepicker-div div.ui-datepicker-header div.ui-datepicker-title select.ui-datepicker-year", "value=$year"); + $this->click("link=$day"); + } + else { + $this->clickAt("xpath=//*[@id='$fieldid']/../div/ul//li/input"); + $this->waitForElementPresent("xpath=//ul[@class='select2-results']"); + $this->clickAt("xpath=//ul[@class='select2-results']//li/div[text()='$value']"); + $this->assertElementContainsText("xpath=//*[@id='$fieldid']/preceding-sibling::div[1]/", $value); + } } // Wait a sec for select2 to update the original element sleep(1); diff --git a/tests/phpunit/WebTest/Contact/AdvancedSearchTest.php b/tests/phpunit/WebTest/Contact/AdvancedSearchTest.php index c232d65730..a50faab969 100644 --- a/tests/phpunit/WebTest/Contact/AdvancedSearchTest.php +++ b/tests/phpunit/WebTest/Contact/AdvancedSearchTest.php @@ -201,7 +201,7 @@ class WebTest_Contact_AdvancedSearchTest extends CiviSeleniumTestCase { //go to next page $this->click("xpath=//div[@class='crm-search-results']/div[@class='crm-pager']/span[@class='crm-pager-nav']/a[@title='next page']"); - $this->waitForElementPresent("task"); + $this->waitForElementPresent("xpath=//a[@title='first page']"); $j = $j + $subTotal; } diff --git a/tests/phpunit/WebTest/Event/AddRecurringEventTest.php b/tests/phpunit/WebTest/Event/AddRecurringEventTest.php index 633419f3de..1e05fa8763 100644 --- a/tests/phpunit/WebTest/Event/AddRecurringEventTest.php +++ b/tests/phpunit/WebTest/Event/AddRecurringEventTest.php @@ -59,20 +59,17 @@ class WebTest_Event_AddRecurringEventTest extends CiviSeleniumTestCase { if (!$occurrences) { $occurrences = 3; } - $this->type('start_action_offset', $occurrences); - $this->webtestFillDate("exclude_date", "11/05/2015"); - $this->click('add_to_exclude_list'); - $this->webtestFillDate("exclude_date", "12/05/2015"); - $this->click('add_to_exclude_list'); + $this->select('start_action_offset', $occurrences); + $this->multiselect2('exclude_date_list', array('05/11/2015', '05/12/2015'), TRUE); $this->click('_qf_Repeat_submit-bottom'); - $this->waitForTextPresent('Based on your repeat configuration, here is the list of dates. Do you wish to create a recurring set with these dates?'); - $this->click("xpath=//div[@class='ui-dialog-buttonset']/button/span[text()='Ok']"); + $this->waitForTextPresent('A recurring set will be created with the following dates.'); + $this->click("xpath=//button//span[text()='Continue']"); $this->waitForAjaxContent(); $this->checkCRMAlert('Repeat Configuration has been saved'); //Check if assertions are correct - $count = $this->getXpathCount("xpath=//div[@id='event_status_id']/div[@class='crm-accordion-body']/div/table/tbody/tr"); - $count = $count - 1; + $this->waitForElementPresent("xpath=//div[@id='recurring-entity-block']/following-sibling::div//div[@class='crm-accordion-body']/div/table/tbody/tr"); + $count = $this->getXpathCount("xpath=//div[@id='recurring-entity-block']/following-sibling::div//div[@class='crm-accordion-body']/div/table/tbody/tr"); $this->assertEquals($occurrences, $count); //Lets go to find participant page and see our repetitive events there @@ -91,7 +88,8 @@ class WebTest_Event_AddRecurringEventTest extends CiviSeleniumTestCase { $this->type('title', 'CiviCon'); $this->click('_qf_EventInfo_upload_done-top'); $this->waitForElementPresent("xpath=//div[@class='ui-dialog-buttonset']/button/span[text()='Cancel']"); - $this->click("xpath=//div[@id='recurring-dialog']/div[@class='show-block']/div[@class='recurring-dialog-inner-wrapper']/div[@class='recurring-dialog-inner-left']/button[text()='All the entities']"); + $this->click("recur-all-entity"); + $this->click("xpath=//button//span[text()='Continue']"); $this->waitForAjaxContent(); $this->openCiviPage("event/manage", "reset=1"); $newEventTitle = "CiviCon";