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