source: devel/testlink/automation2.0/src/test/java/org/expressolivre/cte/pages/email/MailPage.java @ 4344

Revision 4344, 21.3 KB checked in by luiz-fernando, 13 years ago (diff)

Ticket #1402 - Novos casos de teste para preferencias administrativas

Line 
1package org.expressolivre.cte.pages.email;
2
3import org.apache.commons.lang.StringUtils;
4import org.expressolivre.cte.pages.common.Page;
5import org.openqa.selenium.Alert;
6import org.openqa.selenium.By;
7import org.openqa.selenium.JavascriptExecutor;
8import org.openqa.selenium.RenderedWebElement;
9import org.openqa.selenium.WebDriver;
10import org.openqa.selenium.WebElement;
11import org.openqa.selenium.support.FindBy;
12
13/**
14 * @author L.F.Estivalet (Serpro)
15 *
16 *         Created on Dec 16, 2010 at 9:43:21 AM
17 *
18 */
19public class MailPage extends Page {
20
21        /** Botao para criar novo email. */
22        @FindBy(xpath = "//table[@id='folders_tbl']/tbody/tr[1]/td/table/tbody/tr[2]/td/div/span")
23        private WebElement newEmail;
24
25        /** Campo "Para:". */
26        @FindBy(id = "to_1")
27        private WebElement to;
28
29        /** Campo "Assunto:". */
30        @FindBy(id = "subject_1")
31        private WebElement subject;
32
33        /** Botao para enviar email. */
34        @FindBy(id = "send_button_1")
35        private WebElement send;
36
37        /** Flag de importante no momento de compor um email. */
38        @FindBy(id = "important_message_1")
39        private WebElement important;
40
41        /** Flag de importante de um email aberto. */
42        @FindBy(xpath = "//div[@id='exmail_main_body']/div[2]/table/tbody/tr[1]/td/table/tbody/tr[1]/td[2]/span[3]")
43        private WebElement importantFlag;
44
45        /** Filtra emails importantes. */
46        @FindBy(id = "span_flag_FLAGGED")
47        private WebElement importantFilter;
48
49        /** Flag normal de um email aberto. */
50        @FindBy(xpath = "//div[@id='exmail_main_body']/div[2]/table/tbody/tr[1]/td/table/tbody/tr[1]/td[2]/span[3]")
51        private WebElement normalFlag;
52
53        /** Flag nao lido de um email aberto. */
54        @FindBy(xpath = "//div[@id='exmail_main_body']/div[2]/table/tbody/tr[1]/td/table/tbody/tr[1]/td[2]/span[2]")
55        private WebElement notReadFlag;
56
57        /** Checkbox de confirmacao de leitura. */
58        @FindBy(id = "return_receipt_1")
59        private WebElement returnReceipt;
60
61        /** Link para acionar exibicao do campo copia oculta Cco. */
62        @FindBy(id = "a_cco_link_1")
63        private WebElement blindCarbonCopyLink;
64
65        /** Campo copia oculta "Cco:". */
66        @FindBy(id = "cco_1")
67        private WebElement blindCarbonCopy;
68
69        /** Link para acionar exibicao do campo copia Cc. */
70        @FindBy(id = "a_cc_link_1")
71        private WebElement carbonCopyLink;
72
73        /** Campo copia "Cc:". */
74        @FindBy(id = "cc_1")
75        private WebElement carbonCopy;
76
77        /** Link para salvar email. */
78        @FindBy(id = "save_message_options_1")
79        private WebElement saveEmail;
80
81        /** Link para adicionar anexos ao email. */
82        @FindBy(linkText = "Anexos: adicionar+")
83        private WebElement attachmentLink;
84
85        /** Link para adicionar 1o anexo. */
86        @FindBy(id = "inputFile_1_1")
87        private WebElement attachment;
88
89        /** Link para adicionar 2o anexo. */
90        @FindBy(id = "inputFile_1_2")
91        private WebElement attachment2;
92
93        /** Link para remover anexo. */
94        @FindBy(id = "linkFile_1_1")
95        private WebElement removeAttachmentLink;
96
97        /** Link para apagar email quando este estiver aberto. */
98        @FindBy(xpath = "//div[@id='footer_menu']/table[@id='footer_box']/tbody/tr[@id='table_message']/td[@id='span_options']/span[1]/span")
99        private WebElement deleteEmailLink;
100
101        /** Link para pasta lixeira. */
102        @FindBy(id = "lINBOX/Trashtree_folders")
103        private WebElement trashFolder;
104
105        /** Link para limpar lixeira. */
106        @FindBy(id = "empty_trash")
107        private WebElement emptyTrashLink;
108
109        @FindBy(id = "divScrollMain_0")
110        private WebElement emailsListDiv;
111
112        /** Campo contendo total de emails de uma pasta. */
113        @FindBy(id = "tot_m")
114        private WebElement totalEmails;
115
116        @FindBy(xpath = "//div[@id='exmail_main_body']/table[1]/tbody[@id='border_tbody']/tr[1]/td[2]/table/tbody/tr/td[1]")
117        private WebElement emailTab;
118
119        /** Checkbox para selecao de todos emails de uma pasta. */
120        @FindBy(id = "chk_box_select_all_messages")
121        private WebElement selectAllEmails;
122
123        /** Link para acionar o menu Ferramentas. */
124        @FindBy(xpath = "//td[@id='link_tools']/div/span")
125        private WebElement toolsMenu;
126
127        @FindBy(xpath = "//div[@id='menu_tools']/table/tbody/tr[4]/td")
128        private WebElement editFolder;
129
130        @FindBy(xpath = "//input[@value='Nova Pasta']")
131        private WebElement createNewFolder;
132
133        @FindBy(xpath = "//input[@value='Excluir pasta']")
134        private WebElement deleteFolder;
135
136        @FindBy(xpath = "//span[@onclick='wfolders.makeWindow(\"\",\"move_to\")']")
137        /** Opcao de mover do rodape. */
138        private WebElement moveEmailLink;
139
140        @FindBy(id = "dJSWin_wfolders_bok")
141        private WebElement moveEmailButton;
142
143        /** Link para encaminhar em email aberto. */
144        @FindBy(xpath = "//div[@id='exmail_main_body']/div[2]/table/tbody/tr[1]/td/table/tbody/tr[1]/td[3]/span[3]")
145        private WebElement forwardEmail;
146
147        /** Link para responder em email aberto. */
148        @FindBy(xpath = "//div[@id='exmail_main_body']/div[2]/table/tbody/tr[1]/td/table/tbody/tr[1]/td[3]/span[5]")
149        private WebElement replyEmail;
150
151        /** Link para responder a todos em email aberto. */
152        @FindBy(xpath = "//div[@id='exmail_main_body']/div[2]/table/tbody/tr[1]/td/table/tbody/tr[2]/td/div/span[1]")
153        private WebElement replyAllEmail;
154
155        /** Link para responder sem historico em email aberto. */
156        @FindBy(xpath = "//div[@id='exmail_main_body']/div[2]/table/tbody/tr[1]/td/table/tbody/tr[2]/td/div/span[2]")
157        private WebElement replyEmailWithoutHistory;
158
159        /** Link para responder a todos sem historico em email aberto. */
160        @FindBy(xpath = "//div[@id='exmail_main_body']/div[2]/table/tbody/tr[1]/td/table/tbody/tr[2]/td/div/span[3]")
161        private WebElement replyAllEmailWithoutHistory;
162
163        /** Link para editar email na pasta de rascunhos. */
164        @FindBy(xpath = "//div[@id='exmail_main_body']/div[2]/table/tbody/tr[1]/td/table/tbody/tr/td[2]/span[2]/span[1]")
165        private WebElement editEmail;
166
167        @FindBy(xpath = "//div[@id='lertContainer']/div[@id='lertWindow']/div[@id='lertButtons']/a[1]")
168        private WebElement cancelNewEmail;
169
170        @FindBy(xpath = "//div[@id='lertContainer']/div[@id='lertWindow']/div[@id='lertButtons']/a[2]")
171        private WebElement discardNewEmail;
172
173        /**
174         * Esse botao eh no alerta ao fechar uma mensagem nao salva e nao o botao
175         * salvar para rascunhos.
176         */
177        @FindBy(xpath = "//div[@id='lertContainer']/div[@id='lertWindow']/div[@id='lertButtons']/a[3]")
178        private WebElement saveNewEmail;
179
180        /** Nome da pasta "Caixa de Entrada". */
181        public static final String INBOX_FOLDER = "lINBOXtree_folders";
182
183        /** Nome da pasta "Enviados". */
184        public static final String SENT_FOLDER = "lINBOX/Senttree_folders";
185
186        /**
187         * @param driver
188         */
189        public MailPage(WebDriver driver) {
190                super(driver);
191        }
192
193        /**
194         * Cria um novo email.
195         */
196        public void createNewEmail() {
197                this.newEmail.click();
198                waitForElement(By.id("to_1"));
199        }
200
201        /**
202         * Cancela criacao de novo email.
203         */
204        public void cancelNewEmail() {
205                this.cancelNewEmail.click();
206        }
207
208        /**
209         * Descarta criacao de novo email.
210         */
211        public void discardNewEmail() {
212                this.discardNewEmail.click();
213        }
214
215        /**
216         * Salva email na pasta rascunhos.
217         */
218        public void saveNewEmail() {
219                this.saveNewEmail.click();
220        }
221
222        /**
223         * Preenche campo assunto.
224         *
225         * @param subject
226         *            Assunto a ser preenchido.
227         */
228        public void setSubject(String subject) {
229                this.subject.sendKeys(subject != null ? subject : "");
230        }
231
232        /**
233         * Preenche corpo (texto) do email.
234         *
235         * @param body
236         *            Texto a ser preenchido.
237         */
238        public void setBody(String body) {
239                // Foi o unico jeito que consegui pegar o richtexteditor...
240                if (body != null) {
241                        // Troca CR&|LF por <br>
242                        body = body.replaceAll("(\r\n|\r|\n|\n\r)", "<br>");
243                        ((JavascriptExecutor) driver)
244                                        .executeScript("document.getElementById('body_1').contentWindow.document.body.innerHTML='"
245                                                        + body + "';");
246                }
247        }
248
249        /**
250         * @param to
251         * @param subject
252         * @param body
253         */
254        public void composeEmail(String to, String subject, String body) {
255                this.createNewEmail();
256                this.to.sendKeys(to);
257                this.setSubject(subject);
258                this.setBody(body);
259        }
260
261        public String readEmail(String subject) {
262                // waitForElementByXpath("//div[@id='exmail_main_body']/table[1]/tbody[@id='border_tbody']/tr[1]/td[2]/table/tbody/tr/td[1]");
263                String id = findEmailIdBySubject(subject);
264                id = id.substring(id.lastIndexOf("_") + 1);
265                clickElement(By.id("td_who_" + id));
266                super.waitForElement(By.id("div_message_scroll_" + id + "_r"));
267                return id;
268        }
269
270        public void editEmail() {
271                super.waitForElement(By
272                                .xpath("//div[@id='exmail_main_body']/div[2]/table/tbody/tr[1]/td/table/tbody/tr/td[2]/span[2]/span[1]"));
273                // div[@id='exmail_main_body']/div[@id='content_id_9_r']/table/tbody/tr[1]/td/table/tbody/tr/td[2]/span[1]
274                this.editEmail.click();
275        }
276
277        public void editEmail(String id) {
278                super.waitForElement(By
279                                .xpath("//div[@id='exmail_main_body']/div[2]/table/tbody/tr[1]/td/table/tbody/tr/td[2]/span[2]/span[1]"));
280                // div[@id='exmail_main_body']/div[@id='content_id_9_r']/table/tbody/tr[1]/td/table/tbody/tr/td[2]/span[1]
281                this.editEmail.click();
282                waitForElement(By.id("content_id_" + id));
283        }
284
285        /**
286         * Encaminha uma mensagem.
287         *
288         * @param id
289         *            Id da mensagem a ser encaminhada
290         * @param to
291         *            Destinatario
292         */
293        public void forwardEmail(String id, String to) {
294                super.waitForElement(By
295                                .xpath("//div[@id='exmail_main_body']/div[2]/table/tbody/tr[1]/td/table/tbody/tr[1]/td[3]/span[3]"));
296                this.forwardEmail.click();
297                super.waitForElement(By.id("to_" + id));
298                driver.findElement(By.id("to_" + id)).sendKeys(to);
299                driver.findElement(By.id("send_button_" + id)).click();
300        }
301
302        private void reply(String id) {
303                super.waitForElement(By.id("to_" + id));
304                driver.findElement(By.id("send_button_" + id)).click();
305        }
306
307        /**
308         * Responde uma mensagem.
309         *
310         * @param id
311         *            Id da mensagem a ser respondida
312         */
313        public void replyEmail(String id) {
314                super.waitForElement(By
315                                .xpath("//div[@id='exmail_main_body']/div[2]/table/tbody/tr[1]/td/table/tbody/tr[1]/td[3]/span[5]"));
316                this.replyEmail.click();
317                this.reply(id);
318        }
319
320        /**
321         * Responde uma mensagem.
322         *
323         * @param id
324         *            Id da mensagem a ser respondida
325         */
326        public void replyAllEmailWithoutHistory(String id) {
327                super.findAndClickElement("msg_opt_reply_options_" + id + "_r");
328                super.waitForElement(By
329                                .xpath("//div[@id='exmail_main_body']/div[2]/table/tbody/tr[1]/td/table/tbody/tr[2]/td/div/span[3]"));
330                this.replyAllEmailWithoutHistory.click();
331                this.reply(id);
332        }
333
334        /**
335         * Responde uma mensagem.
336         *
337         * @param id
338         *            Id da mensagem a ser respondida
339         */
340        public void replyEmailWithoutHistory(String id) {
341                super.findAndClickElement("msg_opt_reply_options_" + id + "_r");
342                super.waitForElement(By
343                                .xpath("//div[@id='exmail_main_body']/div[2]/table/tbody/tr[1]/td/table/tbody/tr[2]/td/div/span[2]"));
344                this.replyEmailWithoutHistory.click();
345                this.reply(id);
346        }
347
348        /**
349         * Responde uma mensagem.
350         *
351         * @param id
352         *            Id da mensagem a ser respondida
353         */
354        public void replyAllEmail(String id) {
355                super.findAndClickElement("msg_opt_reply_options_" + id + "_r");
356                super.waitForElement(By
357                                .xpath("//div[@id='exmail_main_body']/div[2]/table/tbody/tr[1]/td/table/tbody/tr[2]/td/div/span[1]"));
358                this.replyAllEmail.click();
359                this.reply(id);
360        }
361
362        /**
363         * Abre uma pasta de email especifica.
364         *
365         * @param folder
366         *            Pasta de email a ser aberta.
367         */
368        public void openFolder(String folder) {
369                clickElement(By.id(folder));
370                // Espera pelo "Carregando..." aparecer.
371                waitForElement(By.id("divProgressBar"));
372                waitForElement(By.id("divScrollMain_0"));
373                // Espera pelo "Carregando..." desaparecer.
374                isNotDisplayed(this
375                                .waitFindElement(By.id("divProgressBar"), 5000, 1000));
376                waitForElement(By
377                                .xpath("//div[@id='divScrollMain_0']/table[@id='table_box']/tbody[@id='tbody_box']/tr[1]/td[1]/input[1]"));
378        }
379
380        /**
381         * Abre uma pasta de email especifica.
382         *
383         * @param folder
384         *            Pasta de email a ser aberta.
385         */
386        public void openFolder(WebElement folder) {
387                folder.click();
388                waitForElement(By.id("divScrollMain_0"));
389        }
390
391        /**
392         * Filtra somente as mensagens importantes.
393         */
394        public void setImportantFilter() {
395                this.importantFilter.click();
396        }
397
398        /**
399         * Limpa a lixeira.
400         */
401        public void cleanupTrash() {
402                this.openFolder(this.trashFolder);
403                this.emptyTrashLink.click();
404        }
405
406        /**
407         * @return Numero de emails na pasta selecionada.
408         */
409        public int getTotalEmails() {
410                return Integer.valueOf(this.totalEmails.getText());
411        }
412
413        /**
414         * Move email para um pasta no servidor.
415         *
416         * @param folderName
417         *            Nome da pasta pre-existente no servidor.
418         */
419        public void moveEmail(String folderName) {
420                this.moveEmailLink.click();
421                super.findAndClickElement("lINBOX/" + folderName + "wfolders_tree");
422                this.moveEmailButton.click();
423        }
424
425        /**
426         * Edita nome de pasta.
427         */
428        public void editFolder() {
429                this.toolsMenu.click();
430                this.waitForElement(By
431                                .xpath("//div[@id='menu_tools']/table/tbody/tr[4]/td"));
432                this.editFolder.click();
433        }
434
435        /**
436         * Cria nova pasta.
437         *
438         * @param folderName
439         *            Nome da pasta a ser criada.
440         */
441        public void createNewFolder(String folderName) {
442                this.editFolder();
443                this.createNewFolder.click();
444                Alert newFolder = driver.switchTo().alert();
445                assert "Insira o nome da nova pasta: ".equals(newFolder.getText());
446                newFolder.sendKeys(folderName);
447                newFolder.accept();
448        }
449
450        /**
451         * Exclui pasta.
452         *
453         * @param folderName
454         *            Nome da pasta a ser excluida.
455         */
456        public void deleteFolder(String folderName) {
457                this.editFolder();
458                this.driver.findElement(By.id("lINBOX/" + folderName + "folders_tree"))
459                                .click();
460                this.deleteFolder.click();
461                Alert confirm = driver.switchTo().alert();
462                assert ("Você gostaria de excluir a pasta: " + folderName + "?")
463                                .equals(confirm.getText());
464                confirm.accept();
465        }
466
467        /**
468         * Marca email sendo composto como importante.
469         */
470        public void checkImportantFlag() {
471                this.important.click();
472        }
473
474        /**
475         * Marca email como importante apos ler.
476         */
477        public void setImportantFlag() {
478                this.waitForElement(By
479                                .xpath("//div[@id='exmail_main_body']/div[2]/table/tbody/tr[1]/td/table/tbody/tr[1]/td[2]/span[3]"));
480                this.importantFlag.click();
481        }
482
483        /**
484         * Marca email como normal apos ler.
485         */
486        public void setNormalFlag() {
487                this.waitForElement(By
488                                .xpath("//div[@id='exmail_main_body']/div[2]/table/tbody/tr[1]/td/table/tbody/tr[1]/td[2]/span[3]"));
489                this.normalFlag.click();
490        }
491
492        /**
493         * Marca email como nao lido apos ler.
494         */
495        public void setNotReadFlag() {
496                this.waitForElement(By
497                                .xpath("//div[@id='exmail_main_body']/div[2]/table/tbody/tr[1]/td/table/tbody/tr[1]/td[2]/span[2]"));
498                this.notReadFlag.click();
499        }
500
501        /**
502         * Marca solicitacao de confirmacao de leitura do email sendo composto.
503         */
504        public void checkReturnReceipt() {
505                this.returnReceipt.click();
506        }
507
508        /**
509         * Salva email sendo composto (devera ir para a pasta de Rascunhos).
510         *
511         * TODO adicionar teste para verificar se o email realmente esta presente na
512         * pasta Rascunhos??
513         */
514        public void saveEmail() {
515                this.saveEmail.click();
516        }
517
518        /**
519         * Apaga email previamente selecionado.
520         */
521        public void deleteEmail() {
522                this.deleteEmailLink.click();
523        }
524
525        /**
526         * Seleciona todos emails da pasta corrente.
527         */
528        public void selectAllEmails() {
529                this.selectAllEmails.click();
530        }
531
532        /**
533         * Adiciona email no campo de copia oculta.
534         *
535         * @param email
536         *            Email a ser adicionado.
537         */
538        public void setBlindCarbonCopy(String email) {
539                this.blindCarbonCopyLink.click();
540                this.blindCarbonCopy.sendKeys(email);
541        }
542
543        /**
544         * Adiciona email no campo de copia.
545         *
546         * @param email
547         *            Email a ser adicionado.
548         */
549        public void setCarbonCopy(String email) {
550                this.carbonCopyLink.click();
551                this.carbonCopy.sendKeys(email);
552        }
553
554        /**
555         * Anexo um arquivo no email sendo composto.
556         *
557         * @param attachment
558         *            Caminho para o arquivo a ser anexado.
559         */
560        public void addAttachment(String attachment) {
561                this.attachmentLink.click();
562                this.attachment.sendKeys(attachment);
563        }
564
565        /**
566         * Remove anexo do email sendo composto.
567         */
568        public void removeAttachment() {
569                this.removeAttachmentLink.click();
570        }
571
572        public void addAttachment2(String attachment) {
573                this.attachmentLink.click();
574                this.attachment2.sendKeys(attachment);
575        }
576
577        /**
578         * Envia email sendo composto.
579         */
580        public void sendMail() {
581                this.send.click();
582        }
583
584        /**
585         * Fecha aba do email sendo composto e confirma que email nao esta salvo.
586         */
587        public void closeMail() {
588                this.closeMail(true);
589        }
590
591        /**
592         * @param discardEmail
593         */
594        public void closeMail(boolean discardEmail) {
595
596                // Na versao Serpro:
597                // td[@id='border_id_1']/table/tbody/tr/td[2]/img
598
599                // Na versao Comunidade:
600                // td[@id='border_id_1']/div/div[2]/img
601
602                // Resolvi usando o xpath abaixo:
603                super.clickElement(By.xpath("//td[@id='border_id_1']//img"));
604
605                // if (checkAlert) {
606                // Alert closeAlert = driver.switchTo().alert();
607                // closeAlert.accept();
608                // }
609
610                // Clica em descartar.
611                if (discardEmail) {
612                        super.clickElement(By
613                                        .xpath("//div[@id='lertWindow']/div[@id='lertButtons']/a[2]"));
614                }
615        }
616
617        public void closeMail(String id, boolean discardEmail) {
618                super.clickElement(By.xpath("//td[@id='border_id_" + id + "']//img"));
619                // Clica em cancelar
620                if (discardEmail) {
621                        super.clickElement(By
622                                        .xpath("//div[@id='lertWindow']/div[@id='lertButtons']/a[2]"));
623                }
624        }
625
626        /**
627         * Envia email.
628         *
629         * @param id
630         *            Id do email a ser enviado.
631         */
632        public void sendMail(String id) {
633                super.findAndClickElement("send_button_" + id);
634        }
635
636        /**
637         * @param to
638         * @param subject
639         */
640        public void composeEmail(String to, String subject) {
641                composeEmail(to, subject, null);
642        }
643
644        /**
645         * @param to
646         */
647        public void composeEmail(String to) {
648                composeEmail(to, null, null);
649        }
650
651        /**
652         * Procura um email pelo assunto.
653         *
654         * @param subject
655         *            Assunto a ser procurado.
656         * @param select
657         *            Se email encontrado, deseja seleciona-lo?
658         * @return "id" do email se encontrar, <code>null</code> se nao encontrar.
659         */
660        public String findEmailIdBySuject(String subject, boolean select) {
661                System.out.println("searching for --------->" + subject);
662                String html = driver.getPageSource();
663                // System.out.println(html.indexOf(subject));
664                // System.out.println(html);
665                if (html.indexOf(subject) >= 0) {
666                        String part1 = StringUtils.substringBefore(html, subject);
667                        int start = StringUtils.lastIndexOf(part1, "id=\"") + 4;
668                        int last = StringUtils.indexOf(part1, "\"", start);
669                        String id = StringUtils.substring(part1, start, last);
670                        System.out.println("******************");
671                        System.out.println("******************");
672                        System.out.println("******************");
673                        System.out.println("******************");
674                        System.out.println("******************");
675                        System.out.println("******************");
676                        System.out.println(id);
677                        if (select) {
678                                // Marca checkbox correspondente ao id da mensagem.
679                                clickElement(By.id("check_box" + id.substring(1)));
680                        }
681                        return id;
682                }
683                return null;
684        }
685
686        /**
687         * @return Ids de todos os emails da pasta selecionada.
688         */
689        public String[] getEmailIds() {
690                String[] ids = new String[this.getTotalEmails()];
691                for (int i = 1; i <= this.getTotalEmails(); i++) {
692                        String id = driver
693                                        .findElement(
694                                                        By.xpath("//div[@id='divScrollMain_0']/table[@id='table_box']/tbody[@id='tbody_box']/tr["
695                                                                        + i + "]/td[1]/input[1]")).getAttribute(
696                                                        "id");
697                        ids[i - 1] = id.substring(id.lastIndexOf("_") + 1);
698                }
699                return ids;
700        }
701
702        /**
703         * @param emailId
704         *            Id do email.
705         * @return <code>true</code> se email importante, <code>false</code> caso
706         *         contrario.
707         */
708        public boolean isImportant(String emailId) {
709                return super
710                                .isDisplayed((RenderedWebElement) driver.findElement(By
711                                                .xpath("//div[@id='exmail_main_body']/div[@id='content_id_0']/div[@id='divScrollMain_0']/table[@id='table_box']/tbody[@id='tbody_box']/tr[@id='"
712                                                                + emailId + "']/td[5]/img")));
713        }
714
715        /**
716         * Procura email baseado no assunto na pasta corrente.
717         *
718         * @param subject
719         *            Assunto a ser pesquisado.
720         * @return Id do email encontrado.
721         */
722        public String findEmailIdBySubject(String subject) {
723                return findEmailIdBySuject(subject, false);
724        }
725
726        /**
727         * Procura email baseado no assunto em uma pasta especifica.
728         *
729         * @param folder
730         *            Pasta de pesquisa.
731         * @param subject
732         *            Assunto a ser pesquisado.
733         * @return Id do email encontrado.
734         */
735        public String findEmailIdBySubject(String folder, String subject) {
736                this.openFolder(folder);
737                return findEmailIdBySuject(subject, false);
738        }
739
740        /**
741         * Verifica se mensagem informada corresponde ao exibido pelo Expresso na
742         * div onde sao exibidas mensagens ao usuario.
743         *
744         * @param message
745         *            Mensagem a ser validada.
746         */
747        public void assertMessage(String message) {
748                assert message.equals(getDisplayedElementContent("em_div_write_msg"));
749        }
750
751        /**
752         * @return the to
753         */
754        public WebElement getTo(String id) {
755                waitForElement(By.id("to_" + id));
756                // findAndClickElement("to_" + id);
757                // return getDisplayedElementContent(id);
758                return driver.findElement(By.id("to_" + id));
759        }
760
761        /**
762         * @return the subject
763         */
764        public WebElement getSubject(String id) {
765                waitForElement(By.id("subject_" + id));
766                return driver.findElement(By.id("subject_" + id));
767        }
768
769        /**
770         * @return the blindCarbonCopy
771         */
772        public WebElement getBlindCarbonCopy(String id) {
773                waitForElement(By.id("cco_" + id));
774                return driver.findElement(By.id("cco_" + id));
775        }
776
777        /**
778         * @return the carbonCopy
779         */
780        public WebElement getCarbonCopy(String id) {
781                waitForElement(By.id("cc_" + id));
782                return driver.findElement(By.id("cc_" + id));
783        }
784
785        /**
786         * @param id
787         *            Id do email.
788         * @return Texto do email.
789         */
790        public Object getBody(String id) {
791                waitForElement(By.id("body_" + id));
792                return ((JavascriptExecutor) driver)
793                                .executeScript("return document.getElementById('body_" + id
794                                                + "').contentWindow.document.body.innerHTML;");
795        }
796
797}
Note: See TracBrowser for help on using the repository browser.