From cd71816ecf7d06f8f506543b209f6c943e1e042a Mon Sep 17 00:00:00 2001 From: jitendrapurohit Date: Mon, 6 Apr 2015 11:21:32 +0530 Subject: [PATCH] optimised use of selecting date from multiselect box --- tests/phpunit/CiviTest/CiviSeleniumTestCase.php | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/tests/phpunit/CiviTest/CiviSeleniumTestCase.php b/tests/phpunit/CiviTest/CiviSeleniumTestCase.php index 03d4f8322a..eb040e5448 100644 --- a/tests/phpunit/CiviTest/CiviSeleniumTestCase.php +++ b/tests/phpunit/CiviTest/CiviSeleniumTestCase.php @@ -555,7 +555,7 @@ class CiviSeleniumTestCase extends PHPUnit_Extensions_SeleniumTestCase { * @param $dateElement * @param null $strToTimeArgs */ - public function webtestFillDate($dateElement, $strToTimeArgs = NULL) { + public function webtestFillDate($dateElement, $strToTimeArgs = NULL, $multiselect = FALSE) { $timeStamp = strtotime($strToTimeArgs ? $strToTimeArgs : '+1 month'); $year = date('Y', $timeStamp); @@ -563,7 +563,9 @@ class CiviSeleniumTestCase extends PHPUnit_Extensions_SeleniumTestCase { $mon = date('n', $timeStamp) - 1; $day = date('j', $timeStamp); - $this->click("xpath=//input[starts-with(@id, '{$dateElement}_display_')]"); + if (!$multiselect) { + $this->click("xpath=//input[starts-with(@id, '{$dateElement}_display_')]"); + } $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"); @@ -2302,17 +2304,8 @@ class CiviSeleniumTestCase extends PHPUnit_Extensions_SeleniumTestCase { $this->waitForElementNotPresent('css=select.loading'); foreach ($params as $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"); + $this->webtestFillDate($fieldid, $value, TRUE); } else { $this->clickAt("xpath=//*[@id='$fieldid']/../div/ul//li/input"); -- 2.25.1