WebTestFix
authoratif-shaikh <shaikh388@gmail.com>
Wed, 7 May 2014 15:18:25 +0000 (20:48 +0530)
committeratif-shaikh <shaikh388@gmail.com>
Wed, 7 May 2014 15:18:25 +0000 (20:48 +0530)
tests/phpunit/CiviTest/CiviSeleniumTestCase.php
tests/phpunit/WebTest/Mailing/AddMessageTemplateTest.php

index 289cd936fa93f76e6fe22e16e029f37f20da7b3a..b208bd1e8d1575848e0ab7ef0fec678846044250 100644 (file)
@@ -1864,7 +1864,7 @@ class CiviSeleniumTestCase extends PHPUnit_Extensions_SeleniumTestCase {
   /**
    * function to type and select first occurance of autocomplete
    */
-  function select2($fieldName,$label, $multiple = FALSE) {
+  function select2($fieldName,$label, $multiple = FALSE, $xpath=FALSE) {
     if ($multiple) {
       $this->clickAt("//*[@id='$fieldName']/../div/ul/li[1]");
       $this->keyDown("//*[@id='$fieldName']/../div/ul/li[1]/input", " ");
@@ -1874,13 +1874,16 @@ class CiviSeleniumTestCase extends PHPUnit_Extensions_SeleniumTestCase {
       $this->clickAt("//*[@class='select2-results']/li[1]/div");
     }
     else {
-      $this->clickAt("//*[@id='$fieldName']/../div/a");
+      if ($xpath) 
+       $this->clickAt($fieldName);
+      else
+       $this->clickAt("//*[@id='$fieldName']/../div/a");
       $this->waitForElementPresent("//*[@id='select2-drop']/div/input");
       $this->keyDown("//*[@id='select2-drop']/div/input", " ");
       $this->type("//*[@id='select2-drop']/div/input", $label);
       $this->typeKeys("//*[@id='select2-drop']/div/input", $label);
       $this->waitForElementPresent("//*[@class='select2-result-label']");
-      $this->clickAt("//*[@class='select2-result-label']");
+      $this->clickAt("//*[contains(@class,'select2-result-selectable ')]/div[contains(@class, 'select2-result-label')]");
     }
   }
 
index 647d7239a5533c73df2a9741c6012dc4eaefd2d9..3c38d5d30c760fd9090c0c4841177e6103c00e83 100644 (file)
@@ -43,27 +43,12 @@ class WebTest_Mailing_AddMessageTemplateTest extends CiviSeleniumTestCase {
     $this->type("msg_title", $msgTitle);
     if ($useTokens) {
       //Add Tokens
-      $this->click("css=#msg_subject + a");
-      $this->waitForElementPresent("css=#tokenSubject + .ui-dialog-buttonpane button");
-      $this->type("filter3", "display");
-      $this->addSelection("token3", "label=Display Name");
-      $this->type("filter3", "contact");
-      $this->addSelection("token3", "label=Contact Type");
-      $this->click("css=#tokenSubject + .ui-dialog-buttonpane button");
-      $this->click("//span[@id='helptext']/a/label");
-      $this->waitForElementPresent("css=#tokenText + .ui-dialog-buttonpane button");
-      $this->type("filter1", "display");
-      $this->addSelection("token1", "label=Display Name");
-      $this->type("filter1", "contact");
-      $this->addSelection("token1", "label=Contact Type");
-      $this->click("css=#tokenText + .ui-dialog-buttonpane button");
-      $this->click("//span[@id='helphtml']/a/label");
-      $this->waitForElementPresent("css=#tokenHtml + .ui-dialog-buttonpane button");
-      $this->type("filter2", "display");
-      $this->addSelection("token2", "label=Display Name");
-      $this->type("filter2", "contact");
-      $this->addSelection("token2", "label=Contact Type");
-      $this->click("css=#tokenHtml + .ui-dialog-buttonpane button");
+      $this->select2("msg_subject", "Display Name");
+      $this->select2("msg_subject", "Contact Type");
+      $this->select2("xpath=//*[contains(@data-field,'msg_text')]/../div/a", "Display Name", FALSE, TRUE);
+      $this->select2("xpath=//*[contains(@data-field,'msg_text')]/../div/a", "Contact Type", FALSE, TRUE);
+      $this->select2("xpath=//*[contains(@data-field,'html_message')]/../div/a", "Display Name", FALSE, TRUE);
+      $this->select2("xpath=//*[contains(@data-field,'html_message')]/../div/a", "Contact Type", FALSE, TRUE);
     }
     else {
       // Fill message subject.
@@ -171,8 +156,8 @@ class WebTest_Mailing_AddMessageTemplateTest extends CiviSeleniumTestCase {
     $this->waitForPageToLoad($this->getTimeoutMsec());
 
     //check redirected page to Scheduled and Sent Mailings and  verify for mailing name
-    $this->assertElementContainsText('page-title', "Scheduled and Sent Mailings");
-    $this->assertElementContainsText("xpath=//table[@class='selector']/tbody//tr//td", "Mailing $mailingName Webtest");
+    $this->assertElementContainsText('page-title', "Find Mailings");
+    $this->isTextPresent("Mailing $mailingName Webtest");
     $this->openCiviPage('mailing/queue', 'reset=1');
 
     // verify status