From 037488314abcc45396361eda204eb8b350373a69 Mon Sep 17 00:00:00 2001 From: pratikshad Date: Mon, 23 Mar 2015 18:38:03 +0530 Subject: [PATCH] Fixed webtest for Mailing --- .../phpunit/WebTest/Campaign/MailingTest.php | 102 ++++++++---------- .../Mailing/AddMessageTemplateTest.php | 58 +++++----- 2 files changed, 68 insertions(+), 92 deletions(-) diff --git a/tests/phpunit/WebTest/Campaign/MailingTest.php b/tests/phpunit/WebTest/Campaign/MailingTest.php index 0f7cd8f146..85e3387462 100644 --- a/tests/phpunit/WebTest/Campaign/MailingTest.php +++ b/tests/phpunit/WebTest/Campaign/MailingTest.php @@ -95,9 +95,7 @@ class WebTest_Campaign_MailingTest extends CiviSeleniumTestCase { $this->waitForText('crm-notification-container', "Campaign $title"); - $this->waitForElementPresent("//div[@id='campaignList']/div[@class='dataTables_wrapper no-footer']/table/tbody/tr/td[text()='{$campaignTitle}']/../td[1]"); - $id = (int) $this->getText("//div[@id='campaignList']/div[@class='dataTables_wrapper no-footer']/table/tbody/tr/td[text()='{$campaignTitle}']/../td[1]"); - $this->mailingAddTest($groupName, $campaignTitle, $id); + $this->mailingAddTest($groupName, $campaignTitle, $title, $firstName); } /** @@ -105,7 +103,7 @@ class WebTest_Campaign_MailingTest extends CiviSeleniumTestCase { * @param $campaignTitle * @param int $id */ - public function mailingAddTest($groupName, $campaignTitle, $id) { + public function mailingAddTest($groupName, $campaignTitle, $title, $firstUserName) { //---- create mailing contact and add to mailing Group $firstName = substr(sha1(rand()), 0, 7); $this->webtestAddContact($firstName, "Mailson", "mailino$firstName@mailson.co.in"); @@ -116,65 +114,54 @@ class WebTest_Campaign_MailingTest extends CiviSeleniumTestCase { $this->select("group_id", "$groupName"); $this->click("_qf_GroupContact_next"); - $this->openCiviPage('mailing/send', 'reset=1', '_qf_Group_cancel'); - + $this->openCiviPage('a/#/mailing/new'); + $this->waitForElementPresent("xpath=//input[@name='mailingName']"); //-------select recipients---------- // fill mailing name $mailingName = substr(sha1(rand()), 0, 7); - $this->type("name", "Mailing $mailingName Webtest"); + $this->type("xpath=//input[@name='mailingName']", "Mailing $mailingName Webtest"); // select campaign - $this->click("campaign_id"); - $this->select("campaign_id", "value=$id"); + $this->select2("s2id_crmUiId_4", "Campaign_".$title); // Add the test mailing group - $this->select("includeGroups", "$groupName"); - - // click next - $this->click("_qf_Group_next"); - $this->waitForElementPresent("_qf_Settings_cancel"); - - //--------track and respond---------- - - // check for default settings options - $this->assertChecked("url_tracking"); - $this->assertChecked("open_tracking"); - - // do check count for Recipient - $this->assertElementContainsText('crm-container', "Total Recipients: 2"); - - // no need tracking for this test + $this->select2("s2id_crmUiId_8", $groupName, TRUE); - // click next with default settings - $this->click("_qf_Settings_next"); - $this->waitForElementPresent("_qf_Upload_cancel"); + $this->waitForTextPresent("~2 recipients"); //--------Mailing content------------ - // let from email address be default - // fill subject for mailing - $this->type("subject", "Test subject $mailingName for Webtest"); + $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->click("xpath=//div[@class='preview-popup']//a[text()='Preview as HTML']"); + $this->waitForTextPresent($HTMLMessage); + $this->waitForAjaxContent(); + $this->click("xpath=//button[@title='Close']"); - // check for default option enabled - $this->assertChecked("CIVICRM_QFID_1_upload_type"); + // 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."); - // fill message (presently using script for simple text area) - $this->click("//fieldset[@id='compose_id']/div[2]/div[1]"); - $this->type("text_message", "this is test content for Mailing $mailingName Webtest"); + $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']"); - // add attachment? + //--------track and respond---------- + $this->click("xpath=//ul/li/a[text()='Tracking']"); + $this->assertChecked("url_tracking"); + $this->assertChecked("open_tracking"); + // no need tracking for this test // default header and footer ( with label ) + $this->click("xpath=//ul/li/a[text()='Header and Footer']"); $this->select("header_id", "label=Mailing Header"); $this->select("footer_id", "label=Mailing Footer"); - // do check count for Recipient - $this->assertElementContainsText('crm-container', "Total Recipients: 2"); - - // click next with nominal content - $this->click("_qf_Upload_upload"); - $this->waitForElementPresent("_qf_Test_cancel"); //---------------Test------------------ @@ -193,29 +180,30 @@ class WebTest_Campaign_MailingTest extends CiviSeleniumTestCase { //////// - // do check count for Recipient - $this->assertElementContainsText('crm-container', "Total Recipients: 2"); - // click next - $this->click("_qf_Test_next"); - $this->waitForElementPresent("_qf_Schedule_cancel"); + $this->click("xpath=//div[@class='crm-wizard-buttons']/button[text()='Next']"); //----------Schedule or Send------------ - // do check for default option enabled - $this->assertChecked("now"); - - // do check count for Recipient - $this->assertElementContainsText('crm-container', "Total Recipients: 2"); + // do check for other option + $this->waitForTextPresent("Mailing $mailingName Webtest"); + $this->click("xpath=//div[@class='content']//a[text()='~2 recipients']"); + $verifyData = array( + "$firstUserName Smith"=> "$firstUserName.smith@example.org", + "$firstName Mailson"=> "mailino$firstName@mailson.co.in", + ); + $this->webtestVerifyTabularData($verifyData); + $this->waitForTextPresent("(Include: $groupName)"); + $this->assertChecked("xpath=//input[@id='schedule-send-now']"); // finally schedule the mail by clicking submit - $this->click("_qf_Schedule_next"); + $this->click("xpath=//center/a/div[text()='Submit Mailing']"); $this->waitForPageToLoad($this->getTimeoutMsec()); //----------end New Mailing------------- //check redirected page to Scheduled and Sent Mailings and verify for mailing name - $this->assertElementContainsText('page-title', "Find Mailings"); + $this->waitForTextPresent("Find Mailings"); $this->assertElementContainsText('Search', "Mailing $mailingName Webtest"); //--------- mail delivery verification--------- @@ -263,13 +251,11 @@ class WebTest_Campaign_MailingTest extends CiviSeleniumTestCase { $this->verifyText("xpath=//table//tr[td[1]/text()='Campaign']/descendant::td[2]", preg_quote("$campaignTitle")); //---- check for delivery detail-- - $this->click("link=Successful Deliveries"); $this->waitForPageToLoad($this->getTimeoutMsec()); // check for open page - $this->assertElementContainsText('page-title', "Successful Deliveries"); - + $this->waitForTextPresent("Successful Deliveries"); // verify email $this->assertElementContainsText('mailing_event', "mailino$firstName@mailson.co.in"); //------end delivery verification--------- diff --git a/tests/phpunit/WebTest/Mailing/AddMessageTemplateTest.php b/tests/phpunit/WebTest/Mailing/AddMessageTemplateTest.php index b1b3f66efd..9195c74868 100644 --- a/tests/phpunit/WebTest/Mailing/AddMessageTemplateTest.php +++ b/tests/phpunit/WebTest/Mailing/AddMessageTemplateTest.php @@ -106,64 +106,54 @@ class WebTest_Mailing_AddMessageTemplateTest extends CiviSeleniumTestCase { // configure default mail-box $this->setupDefaultMailbox(); - $this->openCiviPage("mailing/send", "reset=1", "_qf_Group_cancel"); + $this->openCiviPage("a/#/mailing/new"); + $this->waitForElementPresent("xpath=//input[@name='mailingName']"); // fill mailing name $mailingName = substr(sha1(rand()), 0, 7); - $this->type("name", "Mailing $mailingName Webtest"); + $this->type("xpath=//input[@name='mailingName']", "Mailing $mailingName Webtest"); // Add the test mailing group - $this->select("includeGroups", "$groupName"); - - // click next - $this->click("_qf_Group_next"); - $this->waitForElementPresent("_qf_Settings_cancel"); - // check for default settings options - $this->assertChecked("url_tracking"); - $this->assertChecked("open_tracking"); + $this->select2("s2id_crmUiId_8", $groupName, TRUE); // do check count for Recipient - $this->assertElementContainsText('css=.messages', "Total Recipients: 1"); - $this->click("_qf_Settings_next"); - $this->waitForElementPresent("_qf_Upload_cancel"); - - $this->click("template"); - $this->select("template", "label=$msgTitle"); + $this->waitForTextPresent("~1 recipient"); + $this->click("msg_template_id"); + $this->select("msg_template_id", "label=$msgTitle"); // Because it tends to cause problems, all uses of sleep() must be justified in comments // Sleep should never be used for wait for anything to load from the server // Justification for this instance: FIXME sleep(5); - $this->click("xpath=id('Upload')/div[2]/fieldset[@id='compose_id']/div[2]/div[1]"); + $this->click("xpath=//div[@class='preview-popup']//a[text()='Preview as Plain Text']"); $this->click('subject'); + // check for default settings options + $this->click("xpath=//ul/li/a[text()='Tracking']"); + $this->assertChecked("url_tracking"); + $this->assertChecked("open_tracking"); + // check for default header and footer ( with label ) + $this->click("xpath=//ul/li/a[text()='Header and Footer']"); $this->select('header_id', "label=Mailing Header"); $this->select('footer_id', "label=Mailing Footer"); - // do check count for Recipient - $this->assertElementContainsText('css=.messages', "Total Recipients: 1"); - - // click next with nominal content - $this->click("_qf_Upload_upload"); - $this->waitForElementPresent("_qf_Test_cancel"); - - $this->assertElementContainsText('css=.messages', "Total Recipients: 1"); // click next - $this->click("_qf_Test_next"); - $this->waitForElementPresent("_qf_Schedule_cancel"); - - $this->assertChecked("now"); + $this->click("xpath=//div[@class='crm-wizard-buttons']/button[text()='Next']"); - // do check count for Recipient - $this->assertElementContainsText('css=.messages', "Total Recipients: 1"); + $this->assertChecked("xpath=//input[@id='schedule-send-now']"); + $this->waitForTextPresent("Mailing $mailingName Webtest"); + $this->click("xpath=//div[@class='content']//a[text()='~1 recipient']"); + $this->webtestVerifyTabularData(array("$firstName Mailson"=> "mailino$firstName@mailson.co.in")); + $this->click("xpath=//button[@title='Close']"); + $this->waitForTextPresent("(Include: $groupName)"); // finally schedule the mail by clicking submit - $this->click("_qf_Schedule_next"); + $this->click("xpath=//center/a/div[text()='Submit Mailing']"); $this->waitForPageToLoad($this->getTimeoutMsec()); //check redirected page to Scheduled and Sent Mailings and verify for mailing name - $this->assertElementContainsText('page-title', "Find Mailings"); + $this->waitForTextPresent("Find Mailings"); $this->isTextPresent("Mailing $mailingName Webtest"); $this->openCiviPage('mailing/queue', 'reset=1'); @@ -173,7 +163,7 @@ class WebTest_Mailing_AddMessageTemplateTest extends CiviSeleniumTestCase { //View Activity $this->openCiviPage('activity/search', "reset=1", "_qf_Search_refresh"); $this->type("sort_name", $firstName); - $this->click("activity_type_id[19]"); + $this->select("activity_type_id","label=Bulk Email"); $this->click("_qf_Search_refresh"); $this->waitForElementPresent("xpath=//form[@id='Search']/div[3]/div/div[2]/table[@class='selector row-highlight']/tbody/tr[2]/td[9]/span/a[1][text()='View']"); $this->click("xpath=//form[@id='Search']/div[3]/div/div[2]/table[@class='selector row-highlight']/tbody/tr[2]/td[9]/span/a[1][text()='View']"); -- 2.25.1