1 | package org.expressolivre.cte.pages.email; |
---|
2 | |
---|
3 | import org.apache.commons.lang.StringUtils; |
---|
4 | import org.expressolivre.cte.pages.common.Page; |
---|
5 | import org.openqa.selenium.Alert; |
---|
6 | import org.openqa.selenium.By; |
---|
7 | import org.openqa.selenium.JavascriptExecutor; |
---|
8 | import org.openqa.selenium.RenderedWebElement; |
---|
9 | import org.openqa.selenium.WebDriver; |
---|
10 | import org.openqa.selenium.WebElement; |
---|
11 | import 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 | */ |
---|
19 | public 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 | /** Filtra emails lidos. */ |
---|
50 | @FindBy(id = "span_flag_SEEN") |
---|
51 | private WebElement readFilter; |
---|
52 | |
---|
53 | @FindBy(id = "span_flag_UNSEEN") |
---|
54 | private WebElement notReadFilter; |
---|
55 | |
---|
56 | @FindBy(id = "span_flag_ANSWERED") |
---|
57 | private WebElement answeredFilter; |
---|
58 | |
---|
59 | /** Flag normal de um email aberto. */ |
---|
60 | @FindBy(xpath = "//div[@id='exmail_main_body']/div[2]/table/tbody/tr[1]/td/table/tbody/tr[1]/td[2]/span[3]") |
---|
61 | private WebElement normalFlag; |
---|
62 | |
---|
63 | /** Flag nao lido de um email aberto. */ |
---|
64 | @FindBy(xpath = "//div[@id='exmail_main_body']/div[2]/table/tbody/tr[1]/td/table/tbody/tr[1]/td[2]/span[2]") |
---|
65 | private WebElement notReadFlag; |
---|
66 | |
---|
67 | /** Checkbox de confirmacao de leitura. */ |
---|
68 | @FindBy(id = "return_receipt_1") |
---|
69 | private WebElement returnReceipt; |
---|
70 | |
---|
71 | /** Link para acionar exibicao do campo copia oculta Cco. */ |
---|
72 | @FindBy(id = "a_cco_link_1") |
---|
73 | private WebElement blindCarbonCopyLink; |
---|
74 | |
---|
75 | /** Campo copia oculta "Cco:". */ |
---|
76 | @FindBy(id = "cco_1") |
---|
77 | private WebElement blindCarbonCopy; |
---|
78 | |
---|
79 | /** Link para acionar exibicao do campo copia Cc. */ |
---|
80 | @FindBy(id = "a_cc_link_1") |
---|
81 | private WebElement carbonCopyLink; |
---|
82 | |
---|
83 | /** Campo copia "Cc:". */ |
---|
84 | @FindBy(id = "cc_1") |
---|
85 | private WebElement carbonCopy; |
---|
86 | |
---|
87 | /** Link para salvar email. */ |
---|
88 | @FindBy(id = "save_message_options_1") |
---|
89 | private WebElement saveEmail; |
---|
90 | |
---|
91 | /** Link para adicionar anexos ao email. */ |
---|
92 | @FindBy(linkText = "Anexos: adicionar+") |
---|
93 | private WebElement attachmentLink; |
---|
94 | |
---|
95 | /** Link para adicionar 1o anexo. */ |
---|
96 | @FindBy(id = "inputFile_1_1") |
---|
97 | private WebElement attachment; |
---|
98 | |
---|
99 | /** Link para adicionar 2o anexo. */ |
---|
100 | @FindBy(id = "inputFile_1_2") |
---|
101 | private WebElement attachment2; |
---|
102 | |
---|
103 | /** Link para remover anexo. */ |
---|
104 | @FindBy(id = "linkFile_1_1") |
---|
105 | private WebElement removeAttachmentLink; |
---|
106 | |
---|
107 | /** Link para apagar email quando este estiver aberto. */ |
---|
108 | @FindBy(xpath = "//div[@id='footer_menu']/table[@id='footer_box']/tbody/tr[@id='table_message']/td[@id='span_options']/span[1]/span") |
---|
109 | private WebElement deleteEmailLink; |
---|
110 | |
---|
111 | @FindBy(xpath = "//div[@id='footer_menu']/table[@id='footer_box']/tbody/tr[@id='table_message']/td[@id='span_options']/span[4]/span") |
---|
112 | private WebElement exportEmailLink; |
---|
113 | |
---|
114 | /** Link para pasta lixeira. */ |
---|
115 | @FindBy(id = "lINBOX/Trashtree_folders") |
---|
116 | private WebElement trashFolder; |
---|
117 | |
---|
118 | /** Link para limpar lixeira. */ |
---|
119 | @FindBy(id = "empty_trash") |
---|
120 | private WebElement emptyTrashLink; |
---|
121 | |
---|
122 | @FindBy(id = "divScrollMain_0") |
---|
123 | private WebElement emailsListDiv; |
---|
124 | |
---|
125 | /** Campo contendo total de emails de uma pasta. */ |
---|
126 | @FindBy(id = "tot_m") |
---|
127 | private WebElement totalEmails; |
---|
128 | |
---|
129 | @FindBy(xpath = "//div[@id='exmail_main_body']/table[1]/tbody[@id='border_tbody']/tr[1]/td[2]/table/tbody/tr/td[1]") |
---|
130 | private WebElement emailTab; |
---|
131 | |
---|
132 | /** Checkbox para selecao de todos emails de uma pasta. */ |
---|
133 | @FindBy(id = "chk_box_select_all_messages") |
---|
134 | private WebElement selectAllEmails; |
---|
135 | |
---|
136 | /** Link para acionar o menu Ferramentas. */ |
---|
137 | @FindBy(xpath = "//td[@id='link_tools']/div/span") |
---|
138 | private WebElement toolsMenu; |
---|
139 | |
---|
140 | @FindBy(xpath = "//div[@id='menu_tools']/table/tbody/tr[4]/td") |
---|
141 | private WebElement editFolder; |
---|
142 | |
---|
143 | @FindBy(xpath = "//div[@id='menu_tools']/table/tbody/tr[3]/td") |
---|
144 | private WebElement editFilter; |
---|
145 | |
---|
146 | @FindBy(xpath = "//div[@id='window_ffilter_ccform']/div[@id='form_body']/a[1]") |
---|
147 | private WebElement filterNewRule; |
---|
148 | |
---|
149 | @FindBy(xpath = "//div[@id='window_ffilter_ccform']/div[@id='form_body']/span[2]/input") |
---|
150 | private WebElement filterSaveRules; |
---|
151 | |
---|
152 | @FindBy(id = "field1") |
---|
153 | private WebElement filterRecepient; |
---|
154 | |
---|
155 | @FindBy(id = "field2") |
---|
156 | private WebElement filterTo; |
---|
157 | |
---|
158 | @FindBy(id = "field3") |
---|
159 | private WebElement filterSubject; |
---|
160 | |
---|
161 | @FindBy(id = "radio1") |
---|
162 | private WebElement filterArchieveIn; |
---|
163 | |
---|
164 | @FindBy(id = "select_mailboxes") |
---|
165 | private WebElement filterMailBoxes; |
---|
166 | |
---|
167 | @FindBy(id = "radio2") |
---|
168 | private WebElement filterForwardMessage; |
---|
169 | |
---|
170 | @FindBy(id = "radio3") |
---|
171 | private WebElement filterRejectMessage; |
---|
172 | |
---|
173 | @FindBy(id = "radio4") |
---|
174 | private WebElement filterDeleteMessage; |
---|
175 | |
---|
176 | @FindBy(id = "radio5") |
---|
177 | private WebElement filterApplyImportantFilter; |
---|
178 | |
---|
179 | @FindBy(xpath = "//input[@value='Nova Pasta']") |
---|
180 | private WebElement createNewFolder; |
---|
181 | |
---|
182 | @FindBy(xpath = "//input[@value='Excluir pasta']") |
---|
183 | private WebElement deleteFolder; |
---|
184 | |
---|
185 | @FindBy(xpath = "//input[@value='Renomear pasta']") |
---|
186 | private WebElement renameFolder; |
---|
187 | |
---|
188 | @FindBy(xpath = "//span[@onclick='wfolders.makeWindow(\"\",\"move_to\")']") |
---|
189 | /** Opcao de mover do rodape. */ |
---|
190 | private WebElement moveEmailLink; |
---|
191 | |
---|
192 | @FindBy(id = "dJSWin_wfolders_bok") |
---|
193 | private WebElement moveEmailButton; |
---|
194 | |
---|
195 | /** Link para encaminhar em email aberto. */ |
---|
196 | @FindBy(xpath = "//div[@id='exmail_main_body']/div[2]/table/tbody/tr[1]/td/table/tbody/tr[1]/td[3]/span[3]") |
---|
197 | private WebElement forwardEmail; |
---|
198 | |
---|
199 | /** Link para responder em email aberto. */ |
---|
200 | @FindBy(xpath = "//div[@id='exmail_main_body']/div[2]/table/tbody/tr[1]/td/table/tbody/tr[1]/td[3]/span[5]") |
---|
201 | private WebElement replyEmail; |
---|
202 | |
---|
203 | /** Link para responder a todos em email aberto. */ |
---|
204 | @FindBy(xpath = "//div[@id='exmail_main_body']/div[2]/table/tbody/tr[1]/td/table/tbody/tr[2]/td/div/span[1]") |
---|
205 | private WebElement replyAllEmail; |
---|
206 | |
---|
207 | /** Link para responder sem historico em email aberto. */ |
---|
208 | @FindBy(xpath = "//div[@id='exmail_main_body']/div[2]/table/tbody/tr[1]/td/table/tbody/tr[2]/td/div/span[2]") |
---|
209 | private WebElement replyEmailWithoutHistory; |
---|
210 | |
---|
211 | /** Link para responder a todos sem historico em email aberto. */ |
---|
212 | @FindBy(xpath = "//div[@id='exmail_main_body']/div[2]/table/tbody/tr[1]/td/table/tbody/tr[2]/td/div/span[3]") |
---|
213 | private WebElement replyAllEmailWithoutHistory; |
---|
214 | |
---|
215 | /** Link para editar email na pasta de rascunhos. */ |
---|
216 | @FindBy(xpath = "//div[@id='exmail_main_body']/div[2]/table/tbody/tr[1]/td/table/tbody/tr/td[2]/span[2]/span[1]") |
---|
217 | private WebElement editEmail; |
---|
218 | |
---|
219 | @FindBy(xpath = "//div[@id='lertContainer']/div[@id='lertWindow']/div[@id='lertButtons']/a[1]") |
---|
220 | private WebElement cancelNewEmail; |
---|
221 | |
---|
222 | @FindBy(xpath = "//div[@id='lertContainer']/div[@id='lertWindow']/div[@id='lertButtons']/a[2]") |
---|
223 | private WebElement discardNewEmail; |
---|
224 | |
---|
225 | /** |
---|
226 | * Esse botao eh no alerta ao fechar uma mensagem nao salva e nao o botao |
---|
227 | * salvar para rascunhos. |
---|
228 | */ |
---|
229 | @FindBy(xpath = "//div[@id='lertContainer']/div[@id='lertWindow']/div[@id='lertButtons']/a[3]") |
---|
230 | private WebElement saveNewEmail; |
---|
231 | |
---|
232 | @FindBy(xpath = "//table[@id='folders_tbl']/tbody/tr[1]/td/table/tbody/tr[1]/td/a[1]") |
---|
233 | private WebElement searchMessages; |
---|
234 | |
---|
235 | @FindBy(id = "txt_de") |
---|
236 | private WebElement searchRemetente; |
---|
237 | |
---|
238 | @FindBy(id = "txt_para") |
---|
239 | private WebElement searchTo; |
---|
240 | @FindBy(id = "txt_cc") |
---|
241 | private WebElement searchCopy; |
---|
242 | @FindBy(id = "txt_ass") |
---|
243 | private WebElement searchSubject; |
---|
244 | @FindBy(id = "txt_body") |
---|
245 | private WebElement searchBody; |
---|
246 | @FindBy(id = "since_date") |
---|
247 | private WebElement searchSinceDate; |
---|
248 | @FindBy(id = "before_date") |
---|
249 | private WebElement searchBeforeDate; |
---|
250 | @FindBy(id = "on_date") |
---|
251 | private WebElement searchOnDate; |
---|
252 | @FindBy(id = "flagged") |
---|
253 | private WebElement searchImportantFilter; |
---|
254 | @FindBy(id = "seen") |
---|
255 | private WebElement searchSeenFilter; |
---|
256 | @FindBy(id = "answered") |
---|
257 | private WebElement searchAnsweredFilter; |
---|
258 | @FindBy(id = "recent") |
---|
259 | private WebElement searchRecentFilter; |
---|
260 | |
---|
261 | @FindBy(id = "incluir") |
---|
262 | private WebElement includeFolderForSearch; |
---|
263 | |
---|
264 | @FindBy(xpath = "//div[@id='window_search']/div[@id='div_button_search']/table/tbody/tr/td[1]/input") |
---|
265 | private WebElement searchButton; |
---|
266 | |
---|
267 | @FindBy(xpath = "//div[@id='window_search']/div[@id='div_button_search']/table/tbody/tr/td[3]/input") |
---|
268 | private WebElement closeSearchButton; |
---|
269 | |
---|
270 | /** Nome da pasta "Caixa de Entrada". */ |
---|
271 | public static final String INBOX_FOLDER = "lINBOXtree_folders"; |
---|
272 | |
---|
273 | /** Nome da pasta "Enviados". */ |
---|
274 | public static final String SENT_FOLDER = "lINBOX/Senttree_folders"; |
---|
275 | |
---|
276 | /** |
---|
277 | * @param driver |
---|
278 | */ |
---|
279 | public MailPage(WebDriver driver) { |
---|
280 | super(driver); |
---|
281 | } |
---|
282 | |
---|
283 | /** |
---|
284 | * Cria um novo email. |
---|
285 | */ |
---|
286 | public void createNewEmail() { |
---|
287 | this.newEmail.click(); |
---|
288 | waitForElement(By.id("to_1")); |
---|
289 | } |
---|
290 | |
---|
291 | /** |
---|
292 | * Cancela criacao de novo email. |
---|
293 | */ |
---|
294 | public void cancelNewEmail() { |
---|
295 | this.cancelNewEmail.click(); |
---|
296 | } |
---|
297 | |
---|
298 | public void setSearchRemetente(String searchRemetente) { |
---|
299 | this.searchRemetente.sendKeys(searchRemetente); |
---|
300 | } |
---|
301 | |
---|
302 | public void setSearchTo(String searchTo) { |
---|
303 | this.searchTo.sendKeys(searchTo); |
---|
304 | } |
---|
305 | |
---|
306 | public void setSearchCopy(String searchCopy) { |
---|
307 | this.searchCopy.sendKeys(searchCopy); |
---|
308 | } |
---|
309 | |
---|
310 | public void setSearchSubject(String searchSubject) { |
---|
311 | this.searchSubject.sendKeys(searchSubject); |
---|
312 | } |
---|
313 | |
---|
314 | public void setSearchBody(String searchBody) { |
---|
315 | this.searchBody.sendKeys(searchBody); |
---|
316 | } |
---|
317 | |
---|
318 | public void setSearchSinceDate(String searchSinceDate) { |
---|
319 | this.searchSinceDate.sendKeys(searchSinceDate); |
---|
320 | } |
---|
321 | |
---|
322 | public void setSearchBeforeDate(String searchBeforeDate) { |
---|
323 | this.searchBeforeDate.sendKeys(searchBeforeDate); |
---|
324 | } |
---|
325 | |
---|
326 | public void setSearchOnDate(String searchOnDate) { |
---|
327 | this.searchOnDate.sendKeys(searchOnDate); |
---|
328 | } |
---|
329 | |
---|
330 | public void setSearchSeenFilter(String searchSeenFilter) { |
---|
331 | super.setComboValue(this.searchSeenFilter, searchSeenFilter); |
---|
332 | } |
---|
333 | |
---|
334 | public void setSearchAnsweredFilter(String searchAnsweredFilter) { |
---|
335 | super.setComboValue(this.searchAnsweredFilter, searchAnsweredFilter); |
---|
336 | } |
---|
337 | |
---|
338 | public void setSearchRecentFilter(String searchRecentFilter) { |
---|
339 | super.setComboValue(this.searchRecentFilter, searchRecentFilter); |
---|
340 | } |
---|
341 | |
---|
342 | public void openSearchMessageWindow() { |
---|
343 | this.searchMessages.click(); |
---|
344 | super.waitForElement(By.id("flagged")); |
---|
345 | } |
---|
346 | |
---|
347 | /** |
---|
348 | * Pesquisa apenas mensagens importantes. |
---|
349 | * |
---|
350 | * @param flag |
---|
351 | */ |
---|
352 | public void searchImportantMessage(String flag) { |
---|
353 | super.setComboValue(searchImportantFilter, flag); |
---|
354 | } |
---|
355 | |
---|
356 | /** |
---|
357 | * Pesquisa apenas mensagens lidas. |
---|
358 | * |
---|
359 | * @param flag |
---|
360 | */ |
---|
361 | public void searchSeenMessage(String flag) { |
---|
362 | super.setComboValue(searchSeenFilter, flag); |
---|
363 | } |
---|
364 | |
---|
365 | /** |
---|
366 | * Escolhe pastas a serem pesquisadas. |
---|
367 | * |
---|
368 | * @param folder |
---|
369 | */ |
---|
370 | public void setSearchFolders(String folder) { |
---|
371 | super.clickElement(By.id(folder)); |
---|
372 | includeFolderForSearch.click(); |
---|
373 | } |
---|
374 | |
---|
375 | public void doSearch() { |
---|
376 | searchButton.click(); |
---|
377 | } |
---|
378 | |
---|
379 | public void closeSearchWindow() { |
---|
380 | closeSearchButton.click(); |
---|
381 | } |
---|
382 | |
---|
383 | /** |
---|
384 | * Descarta criacao de novo email. |
---|
385 | */ |
---|
386 | public void discardNewEmail() { |
---|
387 | this.discardNewEmail.click(); |
---|
388 | } |
---|
389 | |
---|
390 | /** |
---|
391 | * Salva email na pasta rascunhos. |
---|
392 | */ |
---|
393 | public void saveNewEmail() { |
---|
394 | this.saveNewEmail.click(); |
---|
395 | } |
---|
396 | |
---|
397 | /** |
---|
398 | * Preenche campo assunto. |
---|
399 | * |
---|
400 | * @param subject |
---|
401 | * Assunto a ser preenchido. |
---|
402 | */ |
---|
403 | public void setSubject(String subject) { |
---|
404 | this.subject.sendKeys(subject != null ? subject : ""); |
---|
405 | } |
---|
406 | |
---|
407 | /** |
---|
408 | * Preenche corpo (texto) do email. |
---|
409 | * |
---|
410 | * @param body |
---|
411 | * Texto a ser preenchido. |
---|
412 | */ |
---|
413 | public void setBody(String body) { |
---|
414 | // Foi o unico jeito que consegui pegar o richtexteditor... |
---|
415 | if (body != null) { |
---|
416 | // Troca CR&|LF por <br> |
---|
417 | body = body.replaceAll("(\r\n|\r|\n|\n\r)", "<br>"); |
---|
418 | ((JavascriptExecutor) driver) |
---|
419 | .executeScript("document.getElementById('body_1').contentWindow.document.body.innerHTML='" |
---|
420 | + body + "';"); |
---|
421 | } |
---|
422 | } |
---|
423 | |
---|
424 | /** |
---|
425 | * @param to |
---|
426 | * @param subject |
---|
427 | * @param body |
---|
428 | */ |
---|
429 | public void composeEmail(String to, String subject, String body) { |
---|
430 | this.createNewEmail(); |
---|
431 | this.to.sendKeys(to); |
---|
432 | this.setSubject(subject); |
---|
433 | this.setBody(body); |
---|
434 | } |
---|
435 | |
---|
436 | public String readEmail(String subject) { |
---|
437 | // waitForElementByXpath("//div[@id='exmail_main_body']/table[1]/tbody[@id='border_tbody']/tr[1]/td[2]/table/tbody/tr/td[1]"); |
---|
438 | String id = findEmailIdBySubject(subject); |
---|
439 | id = id.substring(id.lastIndexOf("_") + 1); |
---|
440 | clickElement(By.id("td_who_" + id)); |
---|
441 | super.waitForElement(By.id("div_message_scroll_" + id + "_r")); |
---|
442 | return id; |
---|
443 | } |
---|
444 | |
---|
445 | public void editEmail() { |
---|
446 | super.waitForElement(By |
---|
447 | .xpath("//div[@id='exmail_main_body']/div[2]/table/tbody/tr[1]/td/table/tbody/tr/td[2]/span[2]/span[1]")); |
---|
448 | // div[@id='exmail_main_body']/div[@id='content_id_9_r']/table/tbody/tr[1]/td/table/tbody/tr/td[2]/span[1] |
---|
449 | this.editEmail.click(); |
---|
450 | } |
---|
451 | |
---|
452 | public void editEmail(String id) { |
---|
453 | super.waitForElement(By |
---|
454 | .xpath("//div[@id='exmail_main_body']/div[2]/table/tbody/tr[1]/td/table/tbody/tr/td[2]/span[2]/span[1]")); |
---|
455 | // div[@id='exmail_main_body']/div[@id='content_id_9_r']/table/tbody/tr[1]/td/table/tbody/tr/td[2]/span[1] |
---|
456 | this.editEmail.click(); |
---|
457 | waitForElement(By.id("content_id_" + id)); |
---|
458 | } |
---|
459 | |
---|
460 | /** |
---|
461 | * Encaminha uma mensagem. |
---|
462 | * |
---|
463 | * @param id |
---|
464 | * Id da mensagem a ser encaminhada |
---|
465 | * @param to |
---|
466 | * Destinatario |
---|
467 | */ |
---|
468 | public void forwardEmail(String id, String to) { |
---|
469 | super.waitForElement(By |
---|
470 | .xpath("//div[@id='exmail_main_body']/div[2]/table/tbody/tr[1]/td/table/tbody/tr[1]/td[3]/span[3]")); |
---|
471 | this.forwardEmail.click(); |
---|
472 | super.waitForElement(By.id("to_" + id)); |
---|
473 | driver.findElement(By.id("to_" + id)).sendKeys(to); |
---|
474 | driver.findElement(By.id("send_button_" + id)).click(); |
---|
475 | } |
---|
476 | |
---|
477 | /** |
---|
478 | * Mostra detalhes (cabecalho do email sendo lido). |
---|
479 | * |
---|
480 | * @param id |
---|
481 | */ |
---|
482 | public void showDetails(String id) { |
---|
483 | driver.findElement(By.id("option_hide_more_" + id + "_r")).click(); |
---|
484 | } |
---|
485 | |
---|
486 | /** |
---|
487 | * Remove anexos do email sendo lido. |
---|
488 | */ |
---|
489 | public void removeAllAttachments() { |
---|
490 | driver.findElement( |
---|
491 | By.xpath("//div[@id='exmail_main_body']/div[2]/table/tbody/tr[2]/td/div[1]/table[1]/tbody/tr[5]/td[2]/a[1]")) |
---|
492 | .click(); |
---|
493 | Alert alert = driver.switchTo().alert(); |
---|
494 | assert ("ATENÃÃO: Após a confirmação dessa mensagem, TODOS os anexos da mesma serão apagados. Tenha certeza de que possui uma cópia dos arquivos importantes. Deseja confirmar a operação?" |
---|
495 | .equals(alert.getText())); |
---|
496 | alert.accept(); |
---|
497 | } |
---|
498 | |
---|
499 | public void blockRecipient(String message) { |
---|
500 | driver.findElement( |
---|
501 | By.xpath("//div[@id='exmail_main_body']/div[2]/table/tbody/tr[2]/td/div[1]/table[1]/tbody/tr[1]/td[1]/span[@id='tt_d']/img")) |
---|
502 | .click(); |
---|
503 | // Espera pelo "Carregando..." aparecer. |
---|
504 | waitForElement(By.id("divProgressBar")); |
---|
505 | waitForElement(By.id("divScrollMain_0")); |
---|
506 | // Espera pelo "Carregando..." desaparecer. |
---|
507 | isNotDisplayed(this |
---|
508 | .waitFindElement(By.id("divProgressBar"), 5000, 1000)); |
---|
509 | Alert alert = driver.switchTo().alert(); |
---|
510 | assert (message.equals(alert.getText())); |
---|
511 | alert.accept(); |
---|
512 | } |
---|
513 | |
---|
514 | private void reply(String id) { |
---|
515 | super.waitForElement(By.id("to_" + id)); |
---|
516 | driver.findElement(By.id("send_button_" + id)).click(); |
---|
517 | } |
---|
518 | |
---|
519 | /** |
---|
520 | * Responde uma mensagem. |
---|
521 | * |
---|
522 | * @param id |
---|
523 | * Id da mensagem a ser respondida |
---|
524 | */ |
---|
525 | public void replyEmail(String id) { |
---|
526 | super.waitForElement(By |
---|
527 | .xpath("//div[@id='exmail_main_body']/div[2]/table/tbody/tr[1]/td/table/tbody/tr[1]/td[3]/span[5]")); |
---|
528 | this.replyEmail.click(); |
---|
529 | this.reply(id); |
---|
530 | } |
---|
531 | |
---|
532 | /** |
---|
533 | * Responde uma mensagem. |
---|
534 | * |
---|
535 | * @param id |
---|
536 | * Id da mensagem a ser respondida |
---|
537 | */ |
---|
538 | public void replyAllEmailWithoutHistory(String id) { |
---|
539 | super.findAndClickElement("msg_opt_reply_options_" + id + "_r"); |
---|
540 | super.waitForElement(By |
---|
541 | .xpath("//div[@id='exmail_main_body']/div[2]/table/tbody/tr[1]/td/table/tbody/tr[2]/td/div/span[3]")); |
---|
542 | this.replyAllEmailWithoutHistory.click(); |
---|
543 | this.reply(id); |
---|
544 | } |
---|
545 | |
---|
546 | /** |
---|
547 | * Responde uma mensagem. |
---|
548 | * |
---|
549 | * @param id |
---|
550 | * Id da mensagem a ser respondida |
---|
551 | */ |
---|
552 | public void replyEmailWithoutHistory(String id) { |
---|
553 | super.findAndClickElement("msg_opt_reply_options_" + id + "_r"); |
---|
554 | super.waitForElement(By |
---|
555 | .xpath("//div[@id='exmail_main_body']/div[2]/table/tbody/tr[1]/td/table/tbody/tr[2]/td/div/span[2]")); |
---|
556 | this.replyEmailWithoutHistory.click(); |
---|
557 | this.reply(id); |
---|
558 | } |
---|
559 | |
---|
560 | /** |
---|
561 | * Responde uma mensagem. |
---|
562 | * |
---|
563 | * @param id |
---|
564 | * Id da mensagem a ser respondida |
---|
565 | */ |
---|
566 | public void replyAllEmail(String id) { |
---|
567 | super.findAndClickElement("msg_opt_reply_options_" + id + "_r"); |
---|
568 | super.waitForElement(By |
---|
569 | .xpath("//div[@id='exmail_main_body']/div[2]/table/tbody/tr[1]/td/table/tbody/tr[2]/td/div/span[1]")); |
---|
570 | this.replyAllEmail.click(); |
---|
571 | this.reply(id); |
---|
572 | } |
---|
573 | |
---|
574 | /** |
---|
575 | * Abre uma pasta de email especifica. |
---|
576 | * |
---|
577 | * @param folder |
---|
578 | * Pasta de email a ser aberta. |
---|
579 | */ |
---|
580 | public void openFolder(String folder, boolean waitEmail) { |
---|
581 | waitForElement(By.id(folder)); |
---|
582 | clickElement(By.id(folder)); |
---|
583 | // Espera pelo "Carregando..." aparecer. |
---|
584 | waitForElement(By.id("divProgressBar")); |
---|
585 | waitForElement(By.id("divScrollMain_0")); |
---|
586 | // Espera pelo "Carregando..." desaparecer. |
---|
587 | isNotDisplayed(this |
---|
588 | .waitFindElement(By.id("divProgressBar"), 5000, 1000)); |
---|
589 | if (waitEmail) { |
---|
590 | waitForElement(By |
---|
591 | .xpath("//div[@id='divScrollMain_0']/table[@id='table_box']/tbody[@id='tbody_box']/tr[1]/td[1]/input[1]")); |
---|
592 | } |
---|
593 | } |
---|
594 | |
---|
595 | public void openFolder(String folder) { |
---|
596 | openFolder(folder, true); |
---|
597 | } |
---|
598 | |
---|
599 | /** |
---|
600 | * Abre uma pasta de email especifica. |
---|
601 | * |
---|
602 | * @param folder |
---|
603 | * Pasta de email a ser aberta. |
---|
604 | */ |
---|
605 | public void openFolder(WebElement folder) { |
---|
606 | folder.click(); |
---|
607 | waitForElement(By.id("divScrollMain_0")); |
---|
608 | } |
---|
609 | |
---|
610 | /** |
---|
611 | * Filtra somente as mensagens importantes. |
---|
612 | */ |
---|
613 | public void setImportantFilter() { |
---|
614 | this.importantFilter.click(); |
---|
615 | } |
---|
616 | |
---|
617 | /** |
---|
618 | * Filtra somente as mensagens lidas. |
---|
619 | */ |
---|
620 | public void setReadFilter() { |
---|
621 | this.readFilter.click(); |
---|
622 | } |
---|
623 | |
---|
624 | /** |
---|
625 | * Filtra somente as mensagens nao lidas. |
---|
626 | */ |
---|
627 | public void setNotReadFilter() { |
---|
628 | this.notReadFilter.click(); |
---|
629 | } |
---|
630 | |
---|
631 | /** |
---|
632 | * Filtra somente as mensagens respondidas. |
---|
633 | */ |
---|
634 | public void setAnsweredFilter() { |
---|
635 | this.answeredFilter.click(); |
---|
636 | } |
---|
637 | |
---|
638 | /** |
---|
639 | * Limpa a lixeira. |
---|
640 | */ |
---|
641 | public void cleanupTrash() { |
---|
642 | this.openFolder(this.trashFolder); |
---|
643 | this.emptyTrashLink.click(); |
---|
644 | } |
---|
645 | |
---|
646 | /** |
---|
647 | * @return Numero de emails na pasta selecionada. |
---|
648 | */ |
---|
649 | public int getTotalEmails() { |
---|
650 | return Integer.valueOf(this.totalEmails.getText()); |
---|
651 | } |
---|
652 | |
---|
653 | /** |
---|
654 | * Move email para um pasta no servidor. |
---|
655 | * |
---|
656 | * @param folderName |
---|
657 | * Nome da pasta pre-existente no servidor. |
---|
658 | */ |
---|
659 | public void moveEmail(String folderName) { |
---|
660 | this.moveEmailLink.click(); |
---|
661 | super.findAndClickElement("lINBOX/" + folderName + "wfolders_tree"); |
---|
662 | this.moveEmailButton.click(); |
---|
663 | } |
---|
664 | |
---|
665 | /** |
---|
666 | * Edita nome de pasta. |
---|
667 | */ |
---|
668 | public void editFolder() { |
---|
669 | this.toolsMenu.click(); |
---|
670 | this.waitForElement(By |
---|
671 | .xpath("//div[@id='menu_tools']/table/tbody/tr[4]/td")); |
---|
672 | this.editFolder.click(); |
---|
673 | } |
---|
674 | |
---|
675 | public void newFilterRule() { |
---|
676 | this.filterNewRule.click(); |
---|
677 | } |
---|
678 | |
---|
679 | public void setFilterRecepient(String value) { |
---|
680 | this.filterRecepient.sendKeys(value); |
---|
681 | } |
---|
682 | |
---|
683 | public void setFilterTo(String value) { |
---|
684 | this.filterTo.sendKeys(value); |
---|
685 | } |
---|
686 | |
---|
687 | public void setFilterSubject(String value) { |
---|
688 | this.filterSubject.sendKeys(value); |
---|
689 | } |
---|
690 | |
---|
691 | public void setFilterArchieveIn() { |
---|
692 | this.filterArchieveIn.click(); |
---|
693 | } |
---|
694 | |
---|
695 | public void setFilterMailBox(String mailBox) { |
---|
696 | super.setComboValue(this.filterMailBoxes, mailBox); |
---|
697 | } |
---|
698 | |
---|
699 | public void saveFilterRules() { |
---|
700 | this.filterSaveRules.click(); |
---|
701 | } |
---|
702 | |
---|
703 | /** |
---|
704 | * Edita filtros. |
---|
705 | */ |
---|
706 | public void editFilter() { |
---|
707 | this.toolsMenu.click(); |
---|
708 | this.waitForElement(By |
---|
709 | .xpath("//div[@id='menu_tools']/table/tbody/tr[3]/td")); |
---|
710 | this.editFilter.click(); |
---|
711 | this.waitForElement(By.id("set_rules_img")); |
---|
712 | } |
---|
713 | |
---|
714 | /** |
---|
715 | * Apaga uma regra do filtro. |
---|
716 | * |
---|
717 | * @param id |
---|
718 | */ |
---|
719 | public void deleteRule(int id) { |
---|
720 | this.waitForElement(By.id("rule_" + id)); |
---|
721 | driver.findElement(By.id("rule_" + id)).click(); |
---|
722 | driver.findElement(By.xpath("//div[@id='form_buttons']/input[3]")) |
---|
723 | .click(); |
---|
724 | driver.findElement(By.xpath("//div[@id='form_buttons']/input[4]")) |
---|
725 | .click(); |
---|
726 | } |
---|
727 | |
---|
728 | /** |
---|
729 | * Cria nova pasta. |
---|
730 | * |
---|
731 | * @param folderName |
---|
732 | * Nome da pasta a ser criada. |
---|
733 | */ |
---|
734 | public void createNewFolder(String folderName) { |
---|
735 | this.editFolder(); |
---|
736 | this.createFolder(folderName); |
---|
737 | } |
---|
738 | |
---|
739 | private void createFolder(String folderName) { |
---|
740 | this.createNewFolder.click(); |
---|
741 | Alert newFolder = driver.switchTo().alert(); |
---|
742 | assert "Insira o nome da nova pasta: ".equals(newFolder.getText()); |
---|
743 | newFolder.sendKeys(folderName); |
---|
744 | newFolder.accept(); |
---|
745 | } |
---|
746 | |
---|
747 | /** |
---|
748 | * Cria sub pasta. |
---|
749 | * |
---|
750 | * @param rootFolderName |
---|
751 | * Pasta pai. |
---|
752 | * @param subFolderName |
---|
753 | * Nome da sub pasta a ser criada. |
---|
754 | */ |
---|
755 | public void createSubFolder(String rootFolderName, String subFolderName) { |
---|
756 | this.editFolder(); |
---|
757 | this.driver.findElement( |
---|
758 | By.id("lINBOX/" + rootFolderName + "folders_tree")).click(); |
---|
759 | this.createFolder(subFolderName); |
---|
760 | } |
---|
761 | |
---|
762 | /** |
---|
763 | * Renomeia pasta. |
---|
764 | * |
---|
765 | * @param folderName |
---|
766 | * Nome da pasta a ser renomeada. |
---|
767 | * @param newName |
---|
768 | * Novo nome da pasta. |
---|
769 | */ |
---|
770 | public void renameFolder(String folderName, String newName) { |
---|
771 | this.editFolder(); |
---|
772 | this.driver.findElement(By.id("lINBOX/" + folderName + "folders_tree")) |
---|
773 | .click(); |
---|
774 | this.renameFolder.click(); |
---|
775 | Alert newFolder = driver.switchTo().alert(); |
---|
776 | assert "Entre com um nome para a pasta:".equals(newFolder.getText()); |
---|
777 | newFolder.sendKeys(newName); |
---|
778 | newFolder.accept(); |
---|
779 | } |
---|
780 | |
---|
781 | /** |
---|
782 | * @param folderName |
---|
783 | */ |
---|
784 | public void renameFolderInUse(String folderName) { |
---|
785 | this.editFolder(); |
---|
786 | this.driver.findElement(By.id("lINBOX/" + folderName + "folders_tree")) |
---|
787 | .click(); |
---|
788 | this.renameFolder.click(); |
---|
789 | Alert newFolder = driver.switchTo().alert(); |
---|
790 | assert "Não é possÃvel renomear esta pasta, pois está em uso no momento!" |
---|
791 | .equals(newFolder.getText()); |
---|
792 | newFolder.accept(); |
---|
793 | } |
---|
794 | |
---|
795 | /** |
---|
796 | * Exclui pasta. |
---|
797 | * |
---|
798 | * @param folderName |
---|
799 | * Nome da pasta a ser excluida. |
---|
800 | */ |
---|
801 | public void deleteFolder(String folderName) { |
---|
802 | this.editFolder(); |
---|
803 | this.driver.findElement(By.id("lINBOX/" + folderName + "folders_tree")) |
---|
804 | .click(); |
---|
805 | this.deleteFolder.click(); |
---|
806 | } |
---|
807 | |
---|
808 | /** |
---|
809 | * Exclui pasta. |
---|
810 | * |
---|
811 | * @param folderName |
---|
812 | * Nome da pasta a ser excluida. |
---|
813 | */ |
---|
814 | public void deleteFolder(String folderName, boolean inUse) { |
---|
815 | this.editFolder(); |
---|
816 | this.driver.findElement(By.id("lINBOX/" + folderName + "folders_tree")) |
---|
817 | .click(); |
---|
818 | this.deleteFolder.click(); |
---|
819 | Alert confirm = driver.switchTo().alert(); |
---|
820 | if (!inUse) { |
---|
821 | assert ("Você gostaria de excluir a pasta: " + folderName + "?") |
---|
822 | .equals(confirm.getText()); |
---|
823 | } else { |
---|
824 | assert ("Não é possÃvel remover esta pasta, pois está em uso no momento!") |
---|
825 | .equals(confirm.getText()); |
---|
826 | } |
---|
827 | confirm.accept(); |
---|
828 | } |
---|
829 | |
---|
830 | /** |
---|
831 | * Exclui pasta. |
---|
832 | * |
---|
833 | * @param folderName |
---|
834 | * Nome da pasta a ser excluida. |
---|
835 | */ |
---|
836 | public void deleteSubFolder(String rootFolderName, String subFolderName) { |
---|
837 | this.editFolder(); |
---|
838 | this.driver.findElement( |
---|
839 | By.id("pINBOX/" + rootFolderName + "folders_tree")).click(); |
---|
840 | this.driver.findElement( |
---|
841 | By.id("lINBOX/" + rootFolderName + "/" + subFolderName |
---|
842 | + "folders_tree")).click(); |
---|
843 | this.deleteFolder.click(); |
---|
844 | Alert confirm = driver.switchTo().alert(); |
---|
845 | assert ("Você gostaria de excluir a pasta: " + subFolderName + "?") |
---|
846 | .equals(confirm.getText()); |
---|
847 | confirm.accept(); |
---|
848 | } |
---|
849 | |
---|
850 | /** |
---|
851 | * Marca email sendo composto como importante. |
---|
852 | */ |
---|
853 | public void checkImportantFlag() { |
---|
854 | this.important.click(); |
---|
855 | } |
---|
856 | |
---|
857 | /** |
---|
858 | * Marca email como importante apos ler. |
---|
859 | */ |
---|
860 | public void setImportantFlag() { |
---|
861 | this.waitForElement(By |
---|
862 | .xpath("//div[@id='exmail_main_body']/div[2]/table/tbody/tr[1]/td/table/tbody/tr[1]/td[2]/span[3]")); |
---|
863 | this.importantFlag.click(); |
---|
864 | } |
---|
865 | |
---|
866 | /** |
---|
867 | * Marca email como normal apos ler. |
---|
868 | */ |
---|
869 | public void setNormalFlag() { |
---|
870 | this.waitForElement(By |
---|
871 | .xpath("//div[@id='exmail_main_body']/div[2]/table/tbody/tr[1]/td/table/tbody/tr[1]/td[2]/span[3]")); |
---|
872 | this.normalFlag.click(); |
---|
873 | } |
---|
874 | |
---|
875 | /** |
---|
876 | * Marca email como nao lido apos ler. |
---|
877 | */ |
---|
878 | public void setNotReadFlag() { |
---|
879 | this.waitForElement(By |
---|
880 | .xpath("//div[@id='exmail_main_body']/div[2]/table/tbody/tr[1]/td/table/tbody/tr[1]/td[2]/span[2]")); |
---|
881 | this.notReadFlag.click(); |
---|
882 | } |
---|
883 | |
---|
884 | /** |
---|
885 | * Marca solicitacao de confirmacao de leitura do email sendo composto. |
---|
886 | */ |
---|
887 | public void checkReturnReceipt() { |
---|
888 | this.returnReceipt.click(); |
---|
889 | } |
---|
890 | |
---|
891 | /** |
---|
892 | * Salva email sendo composto (devera ir para a pasta de Rascunhos). |
---|
893 | * |
---|
894 | * TODO adicionar teste para verificar se o email realmente esta presente na |
---|
895 | * pasta Rascunhos?? |
---|
896 | */ |
---|
897 | public void saveEmail() { |
---|
898 | this.saveEmail.click(); |
---|
899 | } |
---|
900 | |
---|
901 | /** |
---|
902 | * Apaga email previamente selecionado. |
---|
903 | */ |
---|
904 | public void deleteEmail() { |
---|
905 | this.deleteEmailLink.click(); |
---|
906 | } |
---|
907 | |
---|
908 | /** |
---|
909 | * Exporta email previamente selecionado. |
---|
910 | */ |
---|
911 | public void exportEmail() { |
---|
912 | this.exportEmailLink.click(); |
---|
913 | } |
---|
914 | |
---|
915 | /** |
---|
916 | * Seleciona todos emails da pasta corrente. |
---|
917 | */ |
---|
918 | public void selectAllEmails() { |
---|
919 | this.selectAllEmails.click(); |
---|
920 | } |
---|
921 | |
---|
922 | /** |
---|
923 | * Adiciona email no campo de copia oculta. |
---|
924 | * |
---|
925 | * @param email |
---|
926 | * Email a ser adicionado. |
---|
927 | */ |
---|
928 | public void setBlindCarbonCopy(String email) { |
---|
929 | this.blindCarbonCopyLink.click(); |
---|
930 | this.blindCarbonCopy.sendKeys(email); |
---|
931 | } |
---|
932 | |
---|
933 | /** |
---|
934 | * Adiciona email no campo de copia. |
---|
935 | * |
---|
936 | * @param email |
---|
937 | * Email a ser adicionado. |
---|
938 | */ |
---|
939 | public void setCarbonCopy(String email) { |
---|
940 | this.carbonCopyLink.click(); |
---|
941 | this.carbonCopy.sendKeys(email); |
---|
942 | } |
---|
943 | |
---|
944 | /** |
---|
945 | * Anexo um arquivo no email sendo composto. |
---|
946 | * |
---|
947 | * @param attachment |
---|
948 | * Caminho para o arquivo a ser anexado. |
---|
949 | */ |
---|
950 | public void addAttachment(String attachment) { |
---|
951 | this.attachmentLink.click(); |
---|
952 | this.attachment.sendKeys(attachment); |
---|
953 | } |
---|
954 | |
---|
955 | /** |
---|
956 | * Remove anexo do email sendo composto. |
---|
957 | */ |
---|
958 | public void removeAttachment() { |
---|
959 | this.removeAttachmentLink.click(); |
---|
960 | } |
---|
961 | |
---|
962 | public void addAttachment2(String attachment) { |
---|
963 | this.attachmentLink.click(); |
---|
964 | this.attachment2.sendKeys(attachment); |
---|
965 | } |
---|
966 | |
---|
967 | /** |
---|
968 | * Envia email sendo composto. |
---|
969 | */ |
---|
970 | public void sendMail() { |
---|
971 | this.send.click(); |
---|
972 | } |
---|
973 | |
---|
974 | /** |
---|
975 | * Fecha aba do email sendo composto e confirma que email nao esta salvo. |
---|
976 | */ |
---|
977 | public void closeMail() { |
---|
978 | this.closeMail(true); |
---|
979 | } |
---|
980 | |
---|
981 | /** |
---|
982 | * @param discardEmail |
---|
983 | */ |
---|
984 | public void closeMail(boolean discardEmail) { |
---|
985 | |
---|
986 | // Na versao Serpro: |
---|
987 | // td[@id='border_id_1']/table/tbody/tr/td[2]/img |
---|
988 | |
---|
989 | // Na versao Comunidade: |
---|
990 | // td[@id='border_id_1']/div/div[2]/img |
---|
991 | |
---|
992 | // Resolvi usando o xpath abaixo: |
---|
993 | super.clickElement(By.xpath("//td[@id='border_id_1']//img")); |
---|
994 | |
---|
995 | // if (checkAlert) { |
---|
996 | // Alert closeAlert = driver.switchTo().alert(); |
---|
997 | // closeAlert.accept(); |
---|
998 | // } |
---|
999 | |
---|
1000 | // Clica em descartar. |
---|
1001 | if (discardEmail) { |
---|
1002 | super.clickElement(By |
---|
1003 | .xpath("//div[@id='lertWindow']/div[@id='lertButtons']/a[2]")); |
---|
1004 | } |
---|
1005 | } |
---|
1006 | |
---|
1007 | public void closeMail(String id, boolean discardEmail) { |
---|
1008 | super.clickElement(By.xpath("//td[@id='border_id_" + id + "']//img")); |
---|
1009 | // Clica em cancelar |
---|
1010 | if (discardEmail) { |
---|
1011 | super.clickElement(By |
---|
1012 | .xpath("//div[@id='lertWindow']/div[@id='lertButtons']/a[2]")); |
---|
1013 | } |
---|
1014 | } |
---|
1015 | |
---|
1016 | /** |
---|
1017 | * Envia email. |
---|
1018 | * |
---|
1019 | * @param id |
---|
1020 | * Id do email a ser enviado. |
---|
1021 | */ |
---|
1022 | public void sendMail(String id) { |
---|
1023 | super.findAndClickElement("send_button_" + id); |
---|
1024 | } |
---|
1025 | |
---|
1026 | /** |
---|
1027 | * @param to |
---|
1028 | * @param subject |
---|
1029 | */ |
---|
1030 | public void composeEmail(String to, String subject) { |
---|
1031 | composeEmail(to, subject, null); |
---|
1032 | } |
---|
1033 | |
---|
1034 | /** |
---|
1035 | * @param to |
---|
1036 | */ |
---|
1037 | public void composeEmail(String to) { |
---|
1038 | composeEmail(to, null, null); |
---|
1039 | } |
---|
1040 | |
---|
1041 | /** |
---|
1042 | * Procura um email pelo assunto. |
---|
1043 | * |
---|
1044 | * @param subject |
---|
1045 | * Assunto a ser procurado. |
---|
1046 | * @param select |
---|
1047 | * Se email encontrado, deseja seleciona-lo? |
---|
1048 | * @return "id" do email se encontrar, <code>null</code> se nao encontrar. |
---|
1049 | */ |
---|
1050 | public String findEmailIdBySuject(String subject, boolean select) { |
---|
1051 | // System.out.println("searching for --------->" + subject); |
---|
1052 | String html = driver.getPageSource(); |
---|
1053 | // System.out.println(html.indexOf(subject)); |
---|
1054 | // System.out.println(html); |
---|
1055 | if (html.indexOf(subject) >= 0) { |
---|
1056 | String part1 = StringUtils.substringBefore(html, subject); |
---|
1057 | int start = StringUtils.lastIndexOf(part1, "id=\"") + 4; |
---|
1058 | int last = StringUtils.indexOf(part1, "\"", start); |
---|
1059 | String id = StringUtils.substring(part1, start, last); |
---|
1060 | // System.out.println(id); |
---|
1061 | if (select) { |
---|
1062 | // Marca checkbox correspondente ao id da mensagem. |
---|
1063 | clickElement(By.id("check_box" + id.substring(1))); |
---|
1064 | } |
---|
1065 | return id; |
---|
1066 | } |
---|
1067 | System.out.println("email not found"); |
---|
1068 | return null; |
---|
1069 | } |
---|
1070 | |
---|
1071 | /** |
---|
1072 | * @return Ids de todos os emails da pasta selecionada. |
---|
1073 | */ |
---|
1074 | public String[] getEmailIds() { |
---|
1075 | String[] ids = new String[this.getTotalEmails()]; |
---|
1076 | for (int i = 1; i <= this.getTotalEmails(); i++) { |
---|
1077 | String id = driver |
---|
1078 | .findElement( |
---|
1079 | By.xpath("//div[@id='divScrollMain_0']/table[@id='table_box']/tbody[@id='tbody_box']/tr[" |
---|
1080 | + i + "]/td[1]/input[1]")).getAttribute( |
---|
1081 | "id"); |
---|
1082 | ids[i - 1] = id.substring(id.lastIndexOf("_") + 1); |
---|
1083 | } |
---|
1084 | return ids; |
---|
1085 | } |
---|
1086 | |
---|
1087 | /** |
---|
1088 | * @param emailId |
---|
1089 | * Id do email. |
---|
1090 | * @return <code>true</code> se email importante, <code>false</code> caso |
---|
1091 | * contrario. |
---|
1092 | */ |
---|
1093 | public boolean isImportant(String emailId) { |
---|
1094 | return super |
---|
1095 | .isDisplayed((RenderedWebElement) driver.findElement(By |
---|
1096 | .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='" |
---|
1097 | + emailId + "']/td[5]/img"))); |
---|
1098 | } |
---|
1099 | |
---|
1100 | /** |
---|
1101 | * @param emailId |
---|
1102 | * Id do email. |
---|
1103 | * @return <code>true</code> se email lido, <code>false</code> caso |
---|
1104 | * contrario. |
---|
1105 | */ |
---|
1106 | public boolean isRead(String emailId) { |
---|
1107 | return super |
---|
1108 | .isDisplayed((RenderedWebElement) driver.findElement(By |
---|
1109 | .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='" |
---|
1110 | + emailId |
---|
1111 | + "']/td[@id='td_message_unseen_" |
---|
1112 | + emailId + "']/img"))); |
---|
1113 | } |
---|
1114 | |
---|
1115 | /** |
---|
1116 | * @param emailId |
---|
1117 | * Id do email. |
---|
1118 | * @return <code>true</code> se email nao lido, <code>false</code> caso |
---|
1119 | * contrario. |
---|
1120 | */ |
---|
1121 | public boolean isNotRead(String emailId) { |
---|
1122 | return super |
---|
1123 | .isDisplayed((RenderedWebElement) driver.findElement(By |
---|
1124 | .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='" |
---|
1125 | + emailId |
---|
1126 | + "']/td[@id='td_message_unseen_" |
---|
1127 | + emailId + "']/img"))); |
---|
1128 | } |
---|
1129 | |
---|
1130 | /** |
---|
1131 | * @param emailId |
---|
1132 | * Id do email. |
---|
1133 | * @return <code>true</code> se email respondido, <code>false</code> caso |
---|
1134 | * contrario. |
---|
1135 | */ |
---|
1136 | public boolean isAnswered(String emailId) { |
---|
1137 | return super |
---|
1138 | .isDisplayed((RenderedWebElement) driver.findElement(By |
---|
1139 | .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='" |
---|
1140 | + emailId |
---|
1141 | + "']/td[@id='td_message_answered_" |
---|
1142 | + emailId + "']/img"))); |
---|
1143 | } |
---|
1144 | |
---|
1145 | /** |
---|
1146 | * Procura email baseado no assunto na pasta corrente. |
---|
1147 | * |
---|
1148 | * @param subject |
---|
1149 | * Assunto a ser pesquisado. |
---|
1150 | * @return Id do email encontrado. |
---|
1151 | */ |
---|
1152 | public String findEmailIdBySubject(String subject) { |
---|
1153 | return findEmailIdBySuject(subject, false); |
---|
1154 | } |
---|
1155 | |
---|
1156 | /** |
---|
1157 | * Procura email baseado no assunto em uma pasta especifica. |
---|
1158 | * |
---|
1159 | * @param folder |
---|
1160 | * Pasta de pesquisa. |
---|
1161 | * @param subject |
---|
1162 | * Assunto a ser pesquisado. |
---|
1163 | * @return Id do email encontrado. |
---|
1164 | */ |
---|
1165 | public String findEmailIdBySubject(String folder, String subject) { |
---|
1166 | this.openFolder(folder); |
---|
1167 | return findEmailIdBySuject(subject, false); |
---|
1168 | } |
---|
1169 | |
---|
1170 | /** |
---|
1171 | * Verifica se mensagem informada corresponde ao exibido pelo Expresso na |
---|
1172 | * div onde sao exibidas mensagens ao usuario. |
---|
1173 | * |
---|
1174 | * @param message |
---|
1175 | * Mensagem a ser validada. |
---|
1176 | */ |
---|
1177 | public void assertMessage(String message) { |
---|
1178 | assert message.equals(getDisplayedElementContent("em_div_write_msg")); |
---|
1179 | } |
---|
1180 | |
---|
1181 | /** |
---|
1182 | * @return the to |
---|
1183 | */ |
---|
1184 | public WebElement getTo(String id) { |
---|
1185 | waitForElement(By.id("to_" + id)); |
---|
1186 | // findAndClickElement("to_" + id); |
---|
1187 | // return getDisplayedElementContent(id); |
---|
1188 | return driver.findElement(By.id("to_" + id)); |
---|
1189 | } |
---|
1190 | |
---|
1191 | /** |
---|
1192 | * @return the subject |
---|
1193 | */ |
---|
1194 | public WebElement getSubject(String id) { |
---|
1195 | waitForElement(By.id("subject_" + id)); |
---|
1196 | return driver.findElement(By.id("subject_" + id)); |
---|
1197 | } |
---|
1198 | |
---|
1199 | /** |
---|
1200 | * @return the blindCarbonCopy |
---|
1201 | */ |
---|
1202 | public WebElement getBlindCarbonCopy(String id) { |
---|
1203 | waitForElement(By.id("cco_" + id)); |
---|
1204 | return driver.findElement(By.id("cco_" + id)); |
---|
1205 | } |
---|
1206 | |
---|
1207 | /** |
---|
1208 | * @return the carbonCopy |
---|
1209 | */ |
---|
1210 | public WebElement getCarbonCopy(String id) { |
---|
1211 | waitForElement(By.id("cc_" + id)); |
---|
1212 | return driver.findElement(By.id("cc_" + id)); |
---|
1213 | } |
---|
1214 | |
---|
1215 | /** |
---|
1216 | * @param id |
---|
1217 | * Id do email. |
---|
1218 | * @return Texto do email. |
---|
1219 | */ |
---|
1220 | public Object getBody(String id) { |
---|
1221 | waitForElement(By.id("body_" + id)); |
---|
1222 | return ((JavascriptExecutor) driver) |
---|
1223 | .executeScript("return document.getElementById('body_" + id |
---|
1224 | + "').contentWindow.document.body.innerHTML;"); |
---|
1225 | } |
---|
1226 | |
---|
1227 | } |
---|