From c79c8ec84c596910ba93000ae219ed772b4726ed Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Wed, 1 Apr 2015 21:49:32 -0400 Subject: [PATCH] Mailing webtest fixes --- .../phpunit/WebTest/Campaign/MailingTest.php | 17 ++--- .../phpunit/WebTest/Mailing/ABMailingTest.php | 65 ++++++++++--------- tests/phpunit/WebTest/Mailing/MailingTest.php | 34 ++++++---- 3 files changed, 65 insertions(+), 51 deletions(-) diff --git a/tests/phpunit/WebTest/Campaign/MailingTest.php b/tests/phpunit/WebTest/Campaign/MailingTest.php index ebfc87c2dc..f0f02140ed 100644 --- a/tests/phpunit/WebTest/Campaign/MailingTest.php +++ b/tests/phpunit/WebTest/Campaign/MailingTest.php @@ -131,24 +131,25 @@ class WebTest_Campaign_MailingTest extends CiviSeleniumTestCase { $this->waitForTextPresent("~2 recipients"); //--------Mailing content------------ + $tokens = ' {domain.address}{action.optOutUrl}'; // fill subject for mailing $this->type("xpath=//input[@name='subject']", "Test subject {$mailingName} for Webtest"); // HTML format message $HTMLMessage = "This is HTML formatted content for Mailing {$mailingName} Webtest."; - $this->fillRichTextField("crmUiId_1", $HTMLMessage); + $this->fillRichTextField("crmUiId_1", $HTMLMessage . $tokens); - $this->click("xpath=//div[@class='preview-popup']//a[text()='Preview as HTML']"); - $this->waitForTextPresent($HTMLMessage); - $this->waitForAjaxContent(); - $this->click("xpath=//button[@title='Close']"); + // 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."); - $this->waitForAjaxContent(); $this->click("xpath=//button[@title='Close']"); //--------track and respond---------- diff --git a/tests/phpunit/WebTest/Mailing/ABMailingTest.php b/tests/phpunit/WebTest/Mailing/ABMailingTest.php index 586423632c..b9274ca126 100644 --- a/tests/phpunit/WebTest/Mailing/ABMailingTest.php +++ b/tests/phpunit/WebTest/Mailing/ABMailingTest.php @@ -103,6 +103,7 @@ class WebTest_Mailing_ABMailingTest extends CiviSeleniumTestCase { $this->waitForElementPresent("xpath=//input[@name='subjectA']"); //-------Compose Mail---------- + $tokens = ' {domain.address}{action.optOutUrl}'; // fill subject for mailing $MailingSubject = substr(sha1(rand()), 0, 7); @@ -111,19 +112,20 @@ class WebTest_Mailing_ABMailingTest extends CiviSeleniumTestCase { // HTML format message $HTMLMessage = "This is HTML formatted content for Mailing {$MailingSubject} Webtest."; - $this->fillRichTextField("crmUiId_1", $HTMLMessage); + $this->fillRichTextField("crmUiId_1", $HTMLMessage . $tokens); - $this->click("xpath=//div[@class='preview-popup']//a[text()='Preview as HTML']"); - $this->waitForTextPresent($HTMLMessage); - $this->waitForAjaxContent(); - $this->click("xpath=//button[@title='Close']"); + // 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 {$MailingSubject} Webtest."); + $this->click("//div[starts-with(text(),'Plain Text')]"); + $this->type("xpath=//*[@name='body_text']", "This is text formatted content for Mailing {$MailingSubject} Webtest.$tokens"); $this->click("xpath=//div[@class='preview-popup']//a[text()='Preview as Plain Text']"); - $this->waitForTextPresent("This is text formatted content for Mailing {$MailingSubject} Webtest."); + $this->waitForTextPresent("This is text formatted content for Mailing {$MailingSubject} Webtest.$tokens"); $this->waitForAjaxContent(); $this->click("xpath=//button[@title='Close']"); @@ -267,6 +269,7 @@ class WebTest_Mailing_ABMailingTest extends CiviSeleniumTestCase { $this->waitForElementPresent("xpath=//input[@name='subject']"); //-------Compose Mail---------- + $tokens = ' {domain.address}{action.optOutUrl}'; // fill subject for mailing $MailingSubject = substr(sha1(rand()), 0, 7); @@ -281,19 +284,20 @@ class WebTest_Mailing_ABMailingTest extends CiviSeleniumTestCase { // HTML format message $HTMLMessage = "This is HTML formatted content for Mailing {$MailingSubject} Webtest."; - $this->fillRichTextField("crmUiId_1", $HTMLMessage); + $this->fillRichTextField("crmUiId_1", $HTMLMessage . $tokens); - $this->click("xpath=//div[@class='preview-popup']//a[text()='Preview as HTML']"); - $this->waitForTextPresent($HTMLMessage); - $this->waitForAjaxContent(); - $this->click("xpath=//button[@title='Close']"); + // 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 {$MailingSubject} Webtest."); + $this->click("//div[starts-with(text(),'Plain Text')]"); + $this->type("xpath=//*[@name='body_text']", "This is text formatted content for Mailing {$MailingSubject} Webtest.$tokens"); $this->click("xpath=//div[@class='preview-popup']//a[text()='Preview as Plain Text']"); - $this->waitForTextPresent("This is text formatted content for Mailing {$MailingSubject} Webtest."); + $this->waitForTextPresent("This is text formatted content for Mailing {$MailingSubject} Webtest.$tokens"); $this->waitForAjaxContent(); $this->click("xpath=//button[@title='Close']"); @@ -419,6 +423,7 @@ class WebTest_Mailing_ABMailingTest extends CiviSeleniumTestCase { $this->waitForElementPresent("xpath=//input[@name='subjectA']"); //-------Compose A---------- + $tokens = ' {domain.address}{action.optOutUrl}'; // fill subject for mailing $AMailingSubject = substr(sha1(rand()), 0, 7); @@ -426,16 +431,17 @@ class WebTest_Mailing_ABMailingTest extends CiviSeleniumTestCase { // HTML format message $AHTMLMessage = "This is HTML formatted content for Mailing {$AMailingSubject} Webtest."; - $this->fillRichTextField("crmUiId_19", $AHTMLMessage); + $this->fillRichTextField("crmUiId_19", $AHTMLMessage . $tokens); - $this->click("xpath=//div[@class='preview-popup']//a[text()='Preview as HTML']"); - $this->waitForTextPresent($AHTMLMessage); - $this->waitForAjaxContent(); - $this->click("xpath=//button[@title='Close']"); + // FIXME: Selenium can't access content in an iframe + //$this->click("xpath=//div[@class='preview-popup']//a[text()='Preview as HTML']"); + //$this->waitForTextPresent($AHTMLMessage); + //$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 {$AMailingSubject} Webtest."); + $this->click("//div[starts-with(text(),'Plain Text')]"); + $this->type("xpath=//*[@name='body_text']", "This is text formatted content for Mailing {$AMailingSubject} Webtest.$tokens"); $this->click("xpath=//div[@class='preview-popup']//a[text()='Preview as Plain Text']"); $this->waitForTextPresent("This is text formatted content for Mailing {$AMailingSubject} Webtest."); @@ -455,16 +461,17 @@ class WebTest_Mailing_ABMailingTest extends CiviSeleniumTestCase { // HTML format message $BHTMLMessage = "This is HTML formatted content for Mailing {$BMailingSubject} Webtest."; - $this->fillRichTextField("crmUiId_28", $BHTMLMessage); + $this->fillRichTextField("crmUiId_28", $BHTMLMessage . $tokens); - $this->click("xpath=//div[@class='preview-popup']//a[text()='Preview as HTML']"); - $this->waitForTextPresent($BHTMLMessage); - $this->waitForAjaxContent(); - $this->click("xpath=//button[@title='Close']"); + // FIXME: Selenium can't access content in an iframe + //$this->click("xpath=//div[@class='preview-popup']//a[text()='Preview as HTML']"); + //$this->waitForTextPresent($BHTMLMessage); + //$this->waitForAjaxContent(); + //$this->click("xpath=//button[@title='Close']"); // Open Plain-text Format pane and type text format msg $this->click("xpath=//div[@id='tab-mailingB']//div[text()='Plain Text']"); - $this->type("xpath=//div[@id='tab-mailingB']//*[@name='body_text']", "This is text formatted content for Mailing {$BMailingSubject} Webtest."); + $this->type("xpath=//div[@id='tab-mailingB']//*[@name='body_text']", "This is text formatted content for Mailing {$BMailingSubject} Webtest.$tokens"); $this->click("xpath=//div[@crm-mailing='abtest.mailings.b']//div[@class='preview-popup']//a[text()='Preview as Plain Text']"); $this->waitForTextPresent("This is text formatted content for Mailing {$BMailingSubject} Webtest."); diff --git a/tests/phpunit/WebTest/Mailing/MailingTest.php b/tests/phpunit/WebTest/Mailing/MailingTest.php index 217d420b65..6df6957c28 100644 --- a/tests/phpunit/WebTest/Mailing/MailingTest.php +++ b/tests/phpunit/WebTest/Mailing/MailingTest.php @@ -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."); @@ -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."); -- 2.25.1