webtest fixes 46
authorjitendrapurohit <jitendra.purohit@webaccessglobal.com>
Thu, 2 Apr 2015 11:07:38 +0000 (16:37 +0530)
committerjitendrapurohit <jitendra.purohit@webaccessglobal.com>
Thu, 2 Apr 2015 11:07:38 +0000 (16:37 +0530)
tests/phpunit/CiviTest/CiviSeleniumTestCase.php
tests/phpunit/WebTest/Contact/AdvancedSearchTest.php
tests/phpunit/WebTest/Event/AddRecurringEventTest.php

index c2379df5af91468831d442f6c3cbbb7ffe0571b4..03d4f8322a04e2b1a71571e6eee7c44e3786315c 100644 (file)
@@ -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);
index c232d657309f7f7814c5197c1f826ce0255ae5fe..a50faab969590329ce8379a92ff27b29744e8f04 100644 (file)
@@ -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;
       }
 
index 633419f3de594fc79c8ddcccd7403b417dbfe4e3..1e05fa876352b6db84d5affa300537237fa32a12 100644 (file)
@@ -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";