Webtest fix
[civicrm-core.git] / tests / phpunit / WebTest / Mailing / MailingTest.php
index 217d420b659eb13f1b1eea35b9920e9281fa342d..fbe077547bc0a3586266408c84552bf315956282 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 /*
  +--------------------------------------------------------------------+
- | CiviCRM version 4.6                                                |
+ | CiviCRM version 4.7                                                |
  +--------------------------------------------------------------------+
  | Copyright CiviCRM LLC (c) 2004-2015                                |
  +--------------------------------------------------------------------+
@@ -81,6 +81,7 @@ class WebTest_Mailing_MailingTest extends CiviSeleniumTestCase {
     $this->openCiviPage("a/#/mailing/new");
 
     //-------select recipients----------
+    $tokens = ' {domain.address}{action.optOutUrl}';
 
     // fill mailing name
     $mailingName = substr(sha1(rand()), 0, 7);
@@ -98,15 +99,17 @@ class WebTest_Mailing_MailingTest extends CiviSeleniumTestCase {
 
     // HTML format message
     $HTMLMessage = "This is HTML formatted content for Mailing {$mailingName} Webtest.";
-    $this->fillRichTextField("crmUiId_1", $HTMLMessage);
-    $this->click("xpath=//div[@class='preview-popup']//a[text()='Preview as HTML']");
-    $this->waitForTextPresent($HTMLMessage);
-    $this->waitForAjaxContent();
-    $this->click("xpath=//button[@title='Close']");
+    $this->fillRichTextField("crmUiId_1", $HTMLMessage . $tokens);
+
+    // FIXME: Selenium can't access content in an iframe
+    //$this->click("xpath=//div[@class='preview-popup']//a[text()='Preview as HTML']");
+    //$this->waitForTextPresent($HTMLMessage);
+    //$this->waitForAjaxContent();
+    //$this->click("xpath=//button[@title='Close']");
 
     // Open Plain-text Format pane and type text format msg
-    $this->click("//div[text()='Plain Text']");
-    $this->type("xpath=//*[@name='body_text']", "This is text formatted content for Mailing {$mailingName} Webtest.");
+    $this->click("//div[starts-with(text(),'Plain Text')]");
+    $this->type("xpath=//*[@name='body_text']", "This is text formatted content for Mailing {$mailingName} Webtest.$tokens");
 
     $this->click("xpath=//div[@class='preview-popup']//a[text()='Preview as Plain Text']");
     $this->waitForTextPresent("This is text formatted content for Mailing {$mailingName} Webtest.");
@@ -114,14 +117,14 @@ class WebTest_Mailing_MailingTest extends CiviSeleniumTestCase {
     $this->click("xpath=//button[@title='Close']");
 
     // select default header and footer ( with label )
-    $this->click("xpath=//ul/li/a[text()='Header and Footer']");
+    $this->click('link=Header and Footer');
     $this->select2("s2id_crmUiId_10", "Mailing Header");
     $this->select2("s2id_crmUiId_11", "Mailing Footer");
 
     //--------track and respond----------
 
     // check for default settings options
-    $this->click("xpath=//ul/li/a[text()='Tracking']");
+    $this->click('link=Tracking');
     $this->assertChecked("url_tracking");
     $this->assertChecked("open_tracking");
 
@@ -250,7 +253,7 @@ class WebTest_Mailing_MailingTest extends CiviSeleniumTestCase {
     //------end delivery verification---------
 
     // //------ check with unsubscribe -------
-    // // FIX ME: there is an issue with DSN setting for Webtest, need to handle by seperate DSN setting for Webtests
+    // // FIX ME: there is an issue with DSN setting for Webtest, need to handle by separate DSN setting for Webtests
     // // build unsubscribe link
     // require_once 'CRM/Mailing/Event/DAO/Queue.php';
     // $eventQueue = new CRM_Mailing_Event_DAO_Queue( );
@@ -331,6 +334,7 @@ class WebTest_Mailing_MailingTest extends CiviSeleniumTestCase {
     $this->openCiviPage("a/#/mailing/new");
 
     //-------select recipients----------
+    $tokens = ' {domain.address}{action.optOutUrl}';
 
     // fill mailing name
     $mailingName = substr(sha1(rand()), 0, 7);
@@ -348,15 +352,17 @@ class WebTest_Mailing_MailingTest extends CiviSeleniumTestCase {
 
     // HTML format message
     $HTMLMessage = "This is HTML formatted content for Mailing {$mailingName} Webtest.";
-    $this->fillRichTextField("crmUiId_1", $HTMLMessage);
-    $this->click("xpath=//div[@class='preview-popup']//a[text()='Preview as HTML']");
-    $this->waitForElementPresent($HTMLMessage);
-    $this->waitForAjaxContent();
-    $this->click("xpath=//button[@title='Close']");
+    $this->fillRichTextField("crmUiId_1", $HTMLMessage . $tokens);
+
+    // FIXME: Selenium can't access content in an iframe
+    //$this->click("xpath=//div[@class='preview-popup']//a[text()='Preview as HTML']");
+    //$this->waitForElementPresent($HTMLMessage);
+    //$this->waitForAjaxContent();
+    //$this->click("xpath=//button[@title='Close']");
 
     // Open Plain-text Format pane and type text format msg
-    $this->click("//div[text()='Plain Text']");
-    $this->type("xpath=//*[@name='body_text']", "This is text formatted content for Mailing {$mailingName} Webtest.");
+    $this->click("//div[starts-with(text(),'Plain Text')]");
+    $this->type("xpath=//*[@name='body_text']", "This is text formatted content for Mailing {$mailingName} Webtest.$tokens");
 
     $this->click("xpath=//div[@class='preview-popup']//a[text()='Preview as Plain Text']");
     $this->waitForTextPresent("This is text formatted content for Mailing {$mailingName} Webtest.");
@@ -364,14 +370,14 @@ class WebTest_Mailing_MailingTest extends CiviSeleniumTestCase {
     $this->click("xpath=//button[@title='Close']");
 
     // select default header and footer ( with label )
-    $this->click("xpath=//ul/li/a[text()='Header and Footer']");
+    $this->click('link=Header and Footer');
     $this->select2("s2id_crmUiId_10", "Mailing Header");
     $this->select2("s2id_crmUiId_11", "Mailing Footer");
 
     //--------track and respond----------
 
     // check for default settings options
-    $this->click("xpath=//ul/li/a[text()='Tracking']");
+    $this->click('link=Tracking');
     $this->assertChecked("url_tracking");
     $this->assertChecked("open_tracking");