Merge pull request #11337 from WeMoveEU/CRM-21460
[civicrm-core.git] / tests / phpunit / WebTest / Mailing / ABMailingTest.php
1 <?php
2 /*
3 +--------------------------------------------------------------------+
4 | CiviCRM version 5 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2018 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
9 | |
10 | CiviCRM is free software; you can copy, modify, and distribute it |
11 | under the terms of the GNU Affero General Public License |
12 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
13 | |
14 | CiviCRM is distributed in the hope that it will be useful, but |
15 | WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
17 | See the GNU Affero General Public License for more details. |
18 | |
19 | You should have received a copy of the GNU Affero General Public |
20 | License along with this program; if not, contact CiviCRM LLC |
21 | at info[AT]civicrm[DOT]org. If you have questions about the |
22 | GNU Affero General Public License or the licensing of CiviCRM, |
23 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
24 +--------------------------------------------------------------------+
25 */
26
27 require_once 'CiviTest/CiviSeleniumTestCase.php';
28
29 /**
30 * Class WebTest_Mailing_ABMailingTest
31 */
32 class WebTest_Mailing_ABMailingTest extends CiviSeleniumTestCase {
33
34 protected function setUp() {
35 parent::setUp();
36 }
37
38 public function testWithDifferentSubject() {
39 $this->markTestSkipped('Skipping for now as it works fine locally.');
40 $this->webtestLogin();
41
42 //----do create test mailing group
43 $this->openCiviPage("group/add", "reset=1", "_qf_Edit_upload");
44
45 // make group name
46 $groupName = 'group_' . substr(sha1(rand()), 0, 7);
47
48 // fill group name
49 $this->type("title", $groupName);
50
51 // fill description
52 $this->type("description", "New mailing group for Webtest");
53
54 // enable Mailing List
55 $this->click("group_type[2]");
56
57 // select Visibility as Public Pages
58 $this->select("visibility", "value=Public Pages");
59
60 // Clicking save.
61 $this->clickLink("_qf_Edit_upload");
62
63 // Is status message correct?
64 $this->waitForText('crm-notification-container', "The Group '$groupName' has been saved.");
65
66 // no. of user to add into group
67 $totalUser = 10;
68
69 //---- create mailing contact and add to mailing Group
70 for ($i = 1; $i <= $totalUser; $i++) {
71 $firstName = substr(sha1(rand()), 0, 7);
72 $this->webtestAddContact($firstName, "Mailson", "mailino$firstName@mailson.co.in");
73
74 // Get contact id from url.
75 $contactId = $this->urlArg('cid');
76
77 // go to group tab and add to mailing group
78 $this->click("css=li#tab_group a");
79 $this->waitForElementPresent("_qf_GroupContact_next");
80 $this->select("group_id", "$groupName");
81 $this->clickLink("_qf_GroupContact_next", "_qf_GroupContact_next", FALSE);
82 }
83 // configure default mail-box
84 $this->setupDefaultMailbox();
85
86 $this->openCiviPage("a/#/abtest/new", NULL, "xpath=//div[@class='crm-wizard-buttons']");
87 $this->waitForElementPresent("xpath=//input[@name='abName']");
88
89 $ABTestName = substr(sha1(rand()), 0, 7) . "ABTestName";
90 $this->type("xpath=//input[@name='abName']", "$ABTestName");
91
92 $this->click("xpath=//input[@value='subject']");
93
94 //click on next
95 $this->click("//button[@ng-click='crmUiWizardCtrl.next()']");
96
97 // Add the test mailing group
98 $this->select2("s2id_crmUiId_13", $groupName, TRUE);
99
100 //$this->fireEvent('xpath=//div[@class="ui-slider-range"]', 'drag');
101
102 //click on next
103 $this->click("//button[@ng-click='crmUiWizardCtrl.next()']");
104 $this->waitForElementPresent("xpath=//input[@name='subjectA']");
105
106 //-------Compose Mail----------
107 $tokens = ' {domain.address}{action.optOutUrl}';
108
109 // fill subject for mailing
110 $MailingSubject = substr(sha1(rand()), 0, 7);
111 $this->type("xpath=//input[@name='subjectA']", "Test subject {$MailingSubject} for A");
112 $this->type("xpath=//input[@name='subjectB']", "Test subject {$MailingSubject} for B");
113
114 // HTML format message
115 $HTMLMessage = "This is HTML formatted content for Mailing {$MailingSubject} Webtest.";
116 $this->fillRichTextField("crmUiId_1", $HTMLMessage . $tokens);
117
118 // FIXME: Selenium can't access content in an iframe
119 //$this->click("xpath=//div[@class='preview-popup']//a[text()='Preview as HTML']");
120 //$this->waitForTextPresent($HTMLMessage);
121 //$this->waitForAjaxContent();
122 //$this->click("xpath=//button[@title='Close']");
123
124 // Open Plain-text Format pane and type text format msg
125 $this->click("//div[starts-with(text(),'Plain Text')]");
126 $this->type("xpath=//*[@name='body_text']", "This is text formatted content for Mailing {$MailingSubject} Webtest.$tokens");
127
128 $this->click("xpath=//div[@class='preview-popup']//a[text()='Preview as Plain Text']");
129 $this->waitForTextPresent("This is text formatted content for Mailing {$MailingSubject} Webtest.");
130 $this->waitForAjaxContent();
131 $this->click("xpath=//button[@title='Close']");
132
133 // click next with default settings
134 $this->click("xpath=//div[@class='crm-wizard-buttons']/button[text()='Next']");
135
136 // click next with nominal content
137 $this->click("xpath=//center/a/div[text()='Submit Mailing']");
138
139 $this->waitForElementPresent("xpath=//button[text()='Select as Final']");
140 $this->click("xpath=//button[text()='Select as Final']");
141 $this->waitForElementPresent("xpath=//div[@class='ui-dialog-buttonset']/button/span[text()='Submit final mailing']");
142 $this->click("xpath=//div[@class='ui-dialog-buttonset']/button/span[text()='Submit final mailing']");
143
144 //----------end New Mailing-------------
145
146 $this->waitForAjaxContent();
147
148 //check redirected page to Scheduled and Sent Mailings and verify for mailing name
149 $this->openCiviPage("mailing/browse/scheduled", "reset=1&scheduled=true");
150 $this->waitForTextPresent("Find Mailings");
151
152 //--------- mail delivery verification---------
153
154 // click report link of created mailing
155 $this->clickLink("xpath=//form[@id='Search']/table/tbody//tr/td[@class='crm-mailing-name'][text()='Final ($ABTestName)']/..//td/span/a[text()='Report']");
156
157 // directly send schedule mailing -- not working right now
158 $this->openCiviPage("mailing/queue", "reset=1");
159
160 //click report link of created mailing
161 $this->clickLink("xpath=//form[@id='Search']/table/tbody//tr/td[@class='crm-mailing-name'][text()='Final ($ABTestName)']/..//td/span/a[text()='Report']");
162
163 //get actual number of user for mailing
164 $mailedUser = round($totalUser * ($totalUser / 100));
165
166 //---- check for delivery detail--
167
168 $this->waitForElementPresent("xpath=//table[@class='crm-mailing-ab-table']/tbody/tr//td//a[text()=" . $mailedUser . "]");
169 $this->assertElementContainsText("xpath=//table[@class='crm-mailing-ab-table']/tbody/tr//td//a[2]", "$mailedUser");
170 $this->assertElementContainsText("xpath=//table[@class='crm-mailing-ab-table']//tbody//tr//td/span", 'Complete');
171
172 //check value for Mailing A
173 $this->assertElementContainsText("xpath=//table[@class='crm-mailing-ab-table']/tbody[3]//tr/td[2]", 'Test A (' . $ABTestName . ')');
174 $this->assertElementContainsText("xpath=//table[@class='crm-mailing-ab-table']/tbody[3]/tr[3]//td[2]", 'Test subject ' . $MailingSubject . ' for A');
175 $this->assertElementContainsText("xpath=//table[@class='crm-mailing-ab-table']//tbody//tr[@ng-controller='ViewRecipCtrl']//td/div", "Include: " . $groupName);
176
177 ////check value for Mailing B
178 $this->assertElementContainsText("xpath=//table[@class='crm-mailing-ab-table']/tbody[3]//tr//td[3]", 'Test B (' . $ABTestName . ')');
179 $this->assertElementContainsText("xpath=//table[@class='crm-mailing-ab-table']/tbody[3]/tr[3]//td[3]", 'Test subject ' . $MailingSubject . ' for B');
180
181 //check value for Mailing Final
182 $this->assertElementContainsText("xpath=//table[@class='crm-mailing-ab-table']/tbody[3]//tr//td[4]", 'Final (' . $ABTestName . ')');
183 $this->assertElementContainsText("xpath=//table[@class='crm-mailing-ab-table']/tbody[3]/tr[3]//td[4]", 'Test subject ' . $MailingSubject . ' for A');
184 $this->assertElementContainsText("xpath=//table[@class='crm-mailing-ab-table']//tbody//tr[@ng-controller='ViewRecipCtrl']//td/div", "Include: " . $groupName);
185 }
186
187 public function testWithDifferentFrom() {
188 $this->markTestSkipped('Skipping for now as it works fine locally.');
189 $this->webtestLogin();
190
191 //----do create test mailing group
192 $this->openCiviPage("group/add", "reset=1", "_qf_Edit_upload");
193
194 // make group name
195 $groupName = 'group_' . substr(sha1(rand()), 0, 7);
196
197 // fill group name
198 $this->type("title", $groupName);
199
200 // fill description
201 $this->type("description", "New mailing group for Webtest");
202
203 // enable Mailing List
204 $this->click("group_type[2]");
205
206 // select Visibility as Public Pages
207 $this->select("visibility", "value=Public Pages");
208
209 // Clicking save.
210 $this->clickLink("_qf_Edit_upload");
211
212 // Is status message correct?
213 $this->waitForText('crm-notification-container', "The Group '$groupName' has been saved.");
214
215 // no. of user to add into group
216 $totalUser = 10;
217
218 //---- create mailing contact and add to mailing Group
219 for ($i = 1; $i <= $totalUser; $i++) {
220 $firstName = substr(sha1(rand()), 0, 7);
221 $this->webtestAddContact($firstName, "Mailson", "mailino$firstName@mailson.co.in");
222
223 // Get contact id from url.
224 $contactId = $this->urlArg('cid');
225
226 // go to group tab and add to mailing group
227 $this->click("css=li#tab_group a");
228 $this->waitForElementPresent("_qf_GroupContact_next");
229 $this->select("group_id", "$groupName");
230 $this->clickLink("_qf_GroupContact_next", "_qf_GroupContact_next", FALSE);
231 }
232 // configure default mail-box
233 $this->setupDefaultMailbox();
234
235 // configure new Form
236 $this->openCiviPage("admin/options/from_email_address", "reset=1");
237 $this->waitForElementPresent("xpath=//div[@class='action-link']/a/span[contains(text(), 'Add From Email Address')]");
238 $this->click("xpath=//div[@class='action-link']/a/span[contains(text(), 'Add From Email Address')]");
239 $this->waitForAjaxContent();
240
241 // make Form Email address
242 $formEmailAddressA = 'ABMailing_' . substr(sha1(rand()), 0, 7);
243 $aEmailID = '"' . $formEmailAddressA . '" <' . $formEmailAddressA . '@abtest.org>';
244 $this->type("xpath=//input[@name='label']", "$aEmailID");
245 $this->click("xpath=//button/span[text()='Save']");
246
247 // make Form Email address
248 $this->click("xpath=//div[@class='action-link']/a/span[contains(text(), 'Add From Email Address')]");
249 $this->waitForAjaxContent();
250 $formEmailAddressB = 'ABMailing_' . substr(sha1(rand()), 0, 7);
251 $bEmailID = '"' . $formEmailAddressB . '" <' . $formEmailAddressB . '@abtest.org>';
252 $this->type("xpath=//input[@name='label']", "$bEmailID");
253 $this->click("xpath=//button/span[text()='Save']");
254
255 $this->openCiviPage("a/#/abtest/new", NULL, "xpath=//div[@class='crm-wizard-buttons']");
256 $this->waitForElementPresent("xpath=//input[@name='abName']");
257
258 $ABTestName = substr(sha1(rand()), 0, 7) . "ABTestName";
259 $this->type("xpath=//input[@name='abName']", "$ABTestName");
260
261 $this->click("xpath=//input[@value='from']");
262
263 //click on next
264 $this->click("//button[@ng-click='crmUiWizardCtrl.next()']");
265
266 // Add the test mailing group
267 $this->select2("s2id_crmUiId_13", $groupName, TRUE);
268
269 //click on next
270 $this->click("//button[@ng-click='crmUiWizardCtrl.next()']");
271 $this->waitForElementPresent("xpath=//input[@name='subject']");
272
273 //-------Compose Mail----------
274 $tokens = ' {domain.address}{action.optOutUrl}';
275
276 // fill subject for mailing
277 $MailingSubject = substr(sha1(rand()), 0, 7);
278 $this->type("xpath=//input[@name='subject']", "Test subject {$MailingSubject} for webtest");
279 $this->waitForElementPresent("xpath=//div[@id='s2id_crmUiId_20']");
280
281 // choose form email address for A
282 $this->select("crmUiId_20", "value=$aEmailID");
283
284 // choose form email address for B
285 $this->select("crmUiId_21", "value=$bEmailID");
286
287 // HTML format message
288 $HTMLMessage = "This is HTML formatted content for Mailing {$MailingSubject} Webtest.";
289 $this->fillRichTextField("crmUiId_1", $HTMLMessage . $tokens);
290
291 // FIXME: Selenium can't access content in an iframe
292 //$this->click("xpath=//div[@class='preview-popup']//a[text()='Preview as HTML']");
293 //$this->waitForTextPresent($HTMLMessage);
294 //$this->waitForAjaxContent();
295 //$this->click("xpath=//button[@title='Close']");
296
297 // Open Plain-text Format pane and type text format msg
298 $this->click("//div[starts-with(text(),'Plain Text')]");
299 $this->type("xpath=//*[@name='body_text']", "This is text formatted content for Mailing {$MailingSubject} Webtest.$tokens");
300
301 $this->click("xpath=//div[@class='preview-popup']//a[text()='Preview as Plain Text']");
302 $this->waitForTextPresent("This is text formatted content for Mailing {$MailingSubject} Webtest.");
303 $this->waitForAjaxContent();
304 $this->click("xpath=//button[@title='Close']");
305
306 // click next with default settings
307 $this->click("xpath=//div[@class='crm-wizard-buttons']/button[text()='Next']");
308
309 // click next with nominal content
310 $this->click("xpath=//center/a/div[text()='Submit Mailing']");
311
312 $this->waitForElementPresent("xpath=//button[text()='Select as Final']");
313 $this->click("xpath=//button[text()='Select as Final']");
314 $this->waitForElementPresent("xpath=//div[@class='ui-dialog-buttonset']/button/span[text()='Submit final mailing']");
315 $this->click("xpath=//div[@class='ui-dialog-buttonset']/button/span[text()='Submit final mailing']");
316
317 //----------end New Mailing-------------
318
319 $this->waitForAjaxContent();
320
321 //check redirected page to Scheduled and Sent Mailings and verify for mailing name
322 $this->openCiviPage("mailing/browse/scheduled", "reset=1&scheduled=true");
323 $this->waitForTextPresent("Find Mailings");
324
325 //--------- mail delivery verification---------
326
327 // click report link of created mailing
328 $this->clickLink("xpath=//form[@id='Search']/table/tbody//tr/td[@class='crm-mailing-name'][text()='Final ($ABTestName)']/..//td/span/a[text()='Report']");
329
330 // directly send schedule mailing -- not working right now
331 $this->openCiviPage("mailing/queue", "reset=1");
332
333 //click report link of created mailing
334 $this->clickLink("xpath=//form[@id='Search']/table/tbody//tr/td[@class='crm-mailing-name'][text()='Final ($ABTestName)']/..//td/span/a[text()='Report']");
335
336 //get actual number of user for mailing
337 $mailedUser = round($totalUser * ($totalUser / 100));
338
339 //---- check for delivery detail--
340 $this->waitForElementPresent("xpath=//table[@class='crm-mailing-ab-table']/tbody/tr//td//a[text()=" . $mailedUser . "]");
341 $this->assertElementContainsText("xpath=//table[@class='crm-mailing-ab-table']/tbody/tr//td//a[2]", "$mailedUser");
342 $this->assertElementContainsText("xpath=//table[@class='crm-mailing-ab-table']//tbody//tr//td/span", 'Complete');
343
344 //check value for Mailing A
345 $this->assertElementContainsText("xpath=//table[@class='crm-mailing-ab-table']/tbody[3]//tr/td[2]", 'Test A (' . $ABTestName . ')');
346 $this->assertElementContainsText("xpath=//table[@class='crm-mailing-ab-table']/tbody[3]/tr[2]/td[2]", "$aEmailID");
347 $this->assertElementContainsText("xpath=//table[@class='crm-mailing-ab-table']/tbody[3]/tr[3]//td[2]", 'Test subject ' . $MailingSubject . ' for webtest');
348 $this->assertElementContainsText("xpath=//table[@class='crm-mailing-ab-table']//tbody//tr[@ng-controller='ViewRecipCtrl']//td/div", "Include: " . $groupName);
349
350 //check value for Mailing B
351 $this->assertElementContainsText("xpath=//table[@class='crm-mailing-ab-table']/tbody[3]//tr//td[3]", 'Test B (' . $ABTestName . ')');
352 $this->assertElementContainsText("xpath=//table[@class='crm-mailing-ab-table']/tbody[3]/tr[2]/td[3]", "$bEmailID");
353 $this->assertElementContainsText("xpath=//table[@class='crm-mailing-ab-table']/tbody[3]/tr[3]//td[3]", 'Test subject ' . $MailingSubject . ' for webtest');
354
355 //check value for Mailing Final
356 $this->assertElementContainsText("xpath=//table[@class='crm-mailing-ab-table']/tbody[3]//tr//td[4]", 'Final (' . $ABTestName . ')');
357 $this->assertElementContainsText("xpath=//table[@class='crm-mailing-ab-table']/tbody[3]/tr[2]/td[4]", "$aEmailID");
358 $this->assertElementContainsText("xpath=//table[@class='crm-mailing-ab-table']/tbody[3]/tr[3]//td[4]", 'Test subject ' . $MailingSubject . ' for webtest');
359 $this->assertElementContainsText("xpath=//table[@class='crm-mailing-ab-table']//tbody//tr[@ng-controller='ViewRecipCtrl']//td/div", "Include: " . $groupName);
360 }
361
362 public function testWithDifferentABMailing() {
363 $this->markTestSkipped('Skipping for now as it works fine locally.');
364 $this->webtestLogin();
365
366 //----do create test mailing group
367 $this->openCiviPage("group/add", "reset=1", "_qf_Edit_upload");
368
369 // make group name
370 $groupName = 'group_' . substr(sha1(rand()), 0, 7);
371
372 // fill group name
373 $this->type("title", $groupName);
374
375 // fill description
376 $this->type("description", "New mailing group for Webtest");
377
378 // enable Mailing List
379 $this->click("group_type[2]");
380
381 // select Visibility as Public Pages
382 $this->select("visibility", "value=Public Pages");
383
384 // Clicking save.
385 $this->clickLink("_qf_Edit_upload");
386
387 // Is status message correct?
388 $this->waitForText('crm-notification-container', "The Group '$groupName' has been saved.");
389
390 // no. of user to add into group
391 $totalUser = 10;
392
393 //---- create mailing contact and add to mailing Group
394 for ($i = 1; $i <= $totalUser; $i++) {
395 $firstName = substr(sha1(rand()), 0, 7);
396 $this->webtestAddContact($firstName, "Mailson", "mailino$firstName@mailson.co.in");
397
398 // Get contact id from url.
399 $contactId = $this->urlArg('cid');
400
401 // go to group tab and add to mailing group
402 $this->click("css=li#tab_group a");
403 $this->waitForElementPresent("_qf_GroupContact_next");
404 $this->select("group_id", "$groupName");
405 $this->clickLink("_qf_GroupContact_next", "_qf_GroupContact_next", FALSE);
406 }
407 // configure default mail-box
408 $this->setupDefaultMailbox();
409
410 $this->openCiviPage("a/#/abtest/new", NULL, "xpath=//div[@class='crm-wizard-buttons']");
411 $this->waitForElementPresent("xpath=//input[@name='abName']");
412
413 $ABTestName = substr(sha1(rand()), 0, 7) . "ABTestName";
414 $this->type("xpath=//input[@name='abName']", "$ABTestName");
415
416 $this->click("xpath=//input[@value='full_email']");
417
418 //click on next
419 $this->click("//button[@ng-click='crmUiWizardCtrl.next()']");
420
421 // Add the test mailing group
422 $this->select2("s2id_crmUiId_13", $groupName, TRUE);
423
424 //click on next
425 $this->click("//button[@ng-click='crmUiWizardCtrl.next()']");
426 $this->waitForElementPresent("xpath=//input[@name='subjectA']");
427
428 //-------Compose A----------
429 $tokens = ' {domain.address}{action.optOutUrl}';
430
431 // fill subject for mailing
432 $AMailingSubject = substr(sha1(rand()), 0, 7);
433 $this->type("xpath=//input[@name='subjectA']", "Test subject {$AMailingSubject} for Webtest");
434
435 // HTML format message
436 $AHTMLMessage = "This is HTML formatted content for Mailing {$AMailingSubject} Webtest.";
437 $this->fillRichTextField("crmUiId_19", $AHTMLMessage . $tokens);
438
439 // FIXME: Selenium can't access content in an iframe
440 //$this->click("xpath=//div[@class='preview-popup']//a[text()='Preview as HTML']");
441 //$this->waitForTextPresent($AHTMLMessage);
442 //$this->waitForAjaxContent();
443 //$this->click("xpath=//button[@title='Close']");
444
445 // Open Plain-text Format pane and type text format msg
446 $this->click("//div[starts-with(text(),'Plain Text')]");
447 $this->type("xpath=//*[@name='body_text']", "This is text formatted content for Mailing {$AMailingSubject} Webtest.$tokens");
448
449 $this->click("xpath=//div[@class='preview-popup']//a[text()='Preview as Plain Text']");
450 $this->waitForTextPresent("This is text formatted content for Mailing {$AMailingSubject} Webtest.");
451 $this->waitForAjaxContent();
452 $this->click("xpath=//button[@title='Close']");
453
454 // click next with default settings
455 $this->click("xpath=//div[@class='crm-wizard-buttons']/button[text()='Next']");
456 $this->waitForElementPresent("xpath=//input[@name='subjectB']");
457
458 //-------Compose B----------
459
460 // fill subject for mailing
461 $BMailingSubject = substr(sha1(rand()), 0, 7);
462 $this->type("xpath=//input[@name='subjectB']", "Test subject {$BMailingSubject} for Webtest");
463
464 // HTML format message
465 $BHTMLMessage = "This is HTML formatted content for Mailing {$BMailingSubject} Webtest.";
466 $this->fillRichTextField("crmUiId_28", $BHTMLMessage . $tokens);
467
468 // FIXME: Selenium can't access content in an iframe
469 //$this->click("xpath=//div[@class='preview-popup']//a[text()='Preview as HTML']");
470 //$this->waitForTextPresent($BHTMLMessage);
471 //$this->waitForAjaxContent();
472 //$this->click("xpath=//button[@title='Close']");
473
474 // Open Plain-text Format pane and type text format msg
475 $this->waitForElementPresent("xpath=//div[@id='tab-mailingB']//div[contains(text(), 'Plain Text')]");
476 $this->click("xpath=//div[@id='tab-mailingB']//div[contains(text(), 'Plain Text')]");
477 $this->type("xpath=//div[@id='tab-mailingB']//*[@name='body_text']", "This is text formatted content for Mailing {$BMailingSubject} Webtest.$tokens");
478
479 $this->click("xpath=//div[@crm-mailing='abtest.mailings.b']//div[@class='preview-popup']//a[text()='Preview as Plain Text']");
480 $this->waitForTextPresent("This is text formatted content for Mailing {$BMailingSubject} Webtest.");
481 $this->waitForAjaxContent();
482 $this->click("xpath=//button[@title='Close']");
483
484 // click next with default settings
485 $this->click("xpath=//div[@class='crm-wizard-buttons']/button[text()='Next']");
486
487 // click next with nominal content
488 $this->click("xpath=//center/a/div[text()='Submit Mailing']");
489
490 $this->waitForElementPresent("xpath=//button[text()='Select as Final']");
491 $this->click("xpath=//button[text()='Select as Final']");
492 $this->waitForElementPresent("xpath=//div[@class='ui-dialog-buttonset']/button/span[text()='Submit final mailing']");
493 $this->click("xpath=//div[@class='ui-dialog-buttonset']/button/span[text()='Submit final mailing']");
494
495 //----------end New Mailing-------------
496
497 $this->waitForAjaxContent();
498
499 //check redirected page to Scheduled and Sent Mailings and verify for mailing name
500 $this->openCiviPage("mailing/browse/scheduled", "reset=1&scheduled=true");
501 $this->waitForTextPresent("Find Mailings");
502
503 //--------- mail delivery verification---------
504
505 // click report link of created mailing
506 $this->clickLink("xpath=//form[@id='Search']/table/tbody//tr/td[@class='crm-mailing-name'][text()='Final ($ABTestName)']/..//td/span/a[text()='Report']");
507
508 // directly send schedule mailing -- not working right now
509 $this->openCiviPage("mailing/queue", "reset=1");
510
511 //click report link of created mailing
512 $this->clickLink("xpath=//form[@id='Search']/table/tbody//tr/td[@class='crm-mailing-name'][text()='Final ($ABTestName)']/..//td/span/a[text()='Report']");
513
514 //get actual number of user for mailing
515 $mailedUser = round($totalUser * ($totalUser / 100));
516
517 //---- check for delivery detail--
518 $this->waitForElementPresent("xpath=//table[@class='crm-mailing-ab-table']/tbody/tr//td//a[text()=" . $mailedUser . "]");
519 $this->assertElementContainsText("xpath=//table[@class='crm-mailing-ab-table']/tbody/tr//td//a[2]", "$mailedUser");
520 $this->assertElementContainsText("xpath=//table[@class='crm-mailing-ab-table']//tbody//tr//td/span", 'Complete');
521
522 //check value for Mailing A
523 $this->assertElementContainsText("xpath=//table[@class='crm-mailing-ab-table']/tbody[3]//tr/td[2]", 'Test A (' . $ABTestName . ')');
524 $this->assertElementContainsText("xpath=//table[@class='crm-mailing-ab-table']/tbody[3]/tr[3]//td[2]", 'Test subject ' . $AMailingSubject . ' for Webtest');
525 $this->assertElementContainsText("xpath=//table[@class='crm-mailing-ab-table']//tbody//tr[@ng-controller='ViewRecipCtrl']//td/div", "Include: " . $groupName);
526
527 //check value for Mailing B
528 $this->assertElementContainsText("xpath=//table[@class='crm-mailing-ab-table']/tbody[3]//tr//td[3]", 'Test B (' . $ABTestName . ')');
529 $this->assertElementContainsText("xpath=//table[@class='crm-mailing-ab-table']/tbody[3]/tr[3]//td[3]", 'Test subject ' . $BMailingSubject . ' for Webtest');
530
531 //check value for Mailing Final
532 $this->assertElementContainsText("xpath=//table[@class='crm-mailing-ab-table']/tbody[3]//tr//td[4]", 'Final (' . $ABTestName . ')');
533 $this->assertElementContainsText("xpath=//table[@class='crm-mailing-ab-table']/tbody[3]/tr[3]//td[4]", 'Test subject ' . $AMailingSubject . ' for Webtest');
534 $this->assertElementContainsText("xpath=//table[@class='crm-mailing-ab-table']//tbody//tr[@ng-controller='ViewRecipCtrl']//td/div", "Include: " . $groupName);
535 }
536
537 }