[3782] | 1 | package org.expressolivre.cte.pages.email; |
---|
[3663] | 2 | |
---|
| 3 | import org.apache.commons.lang.StringUtils; |
---|
[4962] | 4 | import org.expressolivre.cte.pages.calendar.AppointmentEmailPage; |
---|
[3782] | 5 | import org.expressolivre.cte.pages.common.Page; |
---|
[3708] | 6 | import org.openqa.selenium.Alert; |
---|
| 7 | import org.openqa.selenium.By; |
---|
[3663] | 8 | import org.openqa.selenium.JavascriptExecutor; |
---|
[3708] | 9 | import org.openqa.selenium.RenderedWebElement; |
---|
[3663] | 10 | import org.openqa.selenium.WebDriver; |
---|
| 11 | import org.openqa.selenium.WebElement; |
---|
| 12 | import org.openqa.selenium.support.FindBy; |
---|
[4620] | 13 | import org.openqa.selenium.support.PageFactory; |
---|
[4627] | 14 | import org.testng.Assert; |
---|
[3663] | 15 | |
---|
| 16 | /** |
---|
| 17 | * @author L.F.Estivalet (Serpro) |
---|
| 18 | * |
---|
| 19 | * Created on Dec 16, 2010 at 9:43:21 AM |
---|
| 20 | * |
---|
| 21 | */ |
---|
| 22 | public class MailPage extends Page { |
---|
| 23 | |
---|
[4344] | 24 | /** Botao para criar novo email. */ |
---|
[3663] | 25 | @FindBy(xpath = "//table[@id='folders_tbl']/tbody/tr[1]/td/table/tbody/tr[2]/td/div/span") |
---|
| 26 | private WebElement newEmail; |
---|
| 27 | |
---|
[4344] | 28 | /** Campo "Assunto:". */ |
---|
[3663] | 29 | @FindBy(id = "subject_1") |
---|
| 30 | private WebElement subject; |
---|
| 31 | |
---|
[4344] | 32 | /** Flag de importante no momento de compor um email. */ |
---|
[3663] | 33 | @FindBy(id = "important_message_1") |
---|
| 34 | private WebElement important; |
---|
| 35 | |
---|
[4344] | 36 | /** Flag de importante de um email aberto. */ |
---|
[3708] | 37 | @FindBy(xpath = "//div[@id='exmail_main_body']/div[2]/table/tbody/tr[1]/td/table/tbody/tr[1]/td[2]/span[3]") |
---|
| 38 | private WebElement importantFlag; |
---|
| 39 | |
---|
[4344] | 40 | /** Filtra emails importantes. */ |
---|
[3708] | 41 | @FindBy(id = "span_flag_FLAGGED") |
---|
| 42 | private WebElement importantFilter; |
---|
| 43 | |
---|
[4527] | 44 | /** Filtra emails lidos. */ |
---|
| 45 | @FindBy(id = "span_flag_SEEN") |
---|
| 46 | private WebElement readFilter; |
---|
| 47 | |
---|
| 48 | @FindBy(id = "span_flag_UNSEEN") |
---|
| 49 | private WebElement notReadFilter; |
---|
| 50 | |
---|
| 51 | @FindBy(id = "span_flag_ANSWERED") |
---|
| 52 | private WebElement answeredFilter; |
---|
| 53 | |
---|
[4344] | 54 | /** Flag normal de um email aberto. */ |
---|
[3708] | 55 | @FindBy(xpath = "//div[@id='exmail_main_body']/div[2]/table/tbody/tr[1]/td/table/tbody/tr[1]/td[2]/span[3]") |
---|
| 56 | private WebElement normalFlag; |
---|
| 57 | |
---|
[4344] | 58 | /** Flag nao lido de um email aberto. */ |
---|
[3708] | 59 | @FindBy(xpath = "//div[@id='exmail_main_body']/div[2]/table/tbody/tr[1]/td/table/tbody/tr[1]/td[2]/span[2]") |
---|
| 60 | private WebElement notReadFlag; |
---|
| 61 | |
---|
[4344] | 62 | /** Checkbox de confirmacao de leitura. */ |
---|
[3663] | 63 | @FindBy(id = "return_receipt_1") |
---|
| 64 | private WebElement returnReceipt; |
---|
| 65 | |
---|
[4344] | 66 | /** Link para acionar exibicao do campo copia oculta Cco. */ |
---|
[3663] | 67 | @FindBy(id = "a_cco_link_1") |
---|
| 68 | private WebElement blindCarbonCopyLink; |
---|
| 69 | |
---|
[4344] | 70 | /** Campo copia oculta "Cco:". */ |
---|
[3663] | 71 | @FindBy(id = "cco_1") |
---|
| 72 | private WebElement blindCarbonCopy; |
---|
| 73 | |
---|
[4344] | 74 | /** Link para acionar exibicao do campo copia Cc. */ |
---|
[3663] | 75 | @FindBy(id = "a_cc_link_1") |
---|
| 76 | private WebElement carbonCopyLink; |
---|
| 77 | |
---|
[4344] | 78 | /** Campo copia "Cc:". */ |
---|
[3663] | 79 | @FindBy(id = "cc_1") |
---|
| 80 | private WebElement carbonCopy; |
---|
| 81 | |
---|
[4344] | 82 | /** Link para salvar email. */ |
---|
[3663] | 83 | @FindBy(id = "save_message_options_1") |
---|
| 84 | private WebElement saveEmail; |
---|
| 85 | |
---|
[4344] | 86 | /** Link para adicionar anexos ao email. */ |
---|
[3708] | 87 | @FindBy(linkText = "Anexos: adicionar+") |
---|
[3663] | 88 | private WebElement attachmentLink; |
---|
| 89 | |
---|
[4344] | 90 | /** Link para adicionar 1o anexo. */ |
---|
[3663] | 91 | @FindBy(id = "inputFile_1_1") |
---|
| 92 | private WebElement attachment; |
---|
| 93 | |
---|
[4344] | 94 | /** Link para adicionar 2o anexo. */ |
---|
[3708] | 95 | @FindBy(id = "inputFile_1_2") |
---|
| 96 | private WebElement attachment2; |
---|
| 97 | |
---|
[4344] | 98 | /** Link para remover anexo. */ |
---|
| 99 | @FindBy(id = "linkFile_1_1") |
---|
| 100 | private WebElement removeAttachmentLink; |
---|
| 101 | |
---|
| 102 | /** Link para apagar email quando este estiver aberto. */ |
---|
[3663] | 103 | @FindBy(xpath = "//div[@id='footer_menu']/table[@id='footer_box']/tbody/tr[@id='table_message']/td[@id='span_options']/span[1]/span") |
---|
| 104 | private WebElement deleteEmailLink; |
---|
| 105 | |
---|
[4527] | 106 | @FindBy(xpath = "//div[@id='footer_menu']/table[@id='footer_box']/tbody/tr[@id='table_message']/td[@id='span_options']/span[4]/span") |
---|
| 107 | private WebElement exportEmailLink; |
---|
| 108 | |
---|
[4780] | 109 | @FindBy(xpath = "//div[@id='footer_menu']/table[@id='footer_box']/tbody/tr[@id='table_message']/td[@id='span_options']/span[5]/span") |
---|
| 110 | private WebElement importEmailLink; |
---|
| 111 | |
---|
| 112 | @FindBy(xpath = "//div[@id='win_import_window']/div[@id='win_import_window_clientArea']/div[@id='import_window']/div[@id='form_upload']/form/input[2]") |
---|
| 113 | private WebElement importSelectFolderButton; |
---|
| 114 | |
---|
[4344] | 115 | /** Link para pasta lixeira. */ |
---|
[3663] | 116 | @FindBy(id = "lINBOX/Trashtree_folders") |
---|
| 117 | private WebElement trashFolder; |
---|
| 118 | |
---|
[4344] | 119 | /** Link para limpar lixeira. */ |
---|
[3663] | 120 | @FindBy(id = "empty_trash") |
---|
| 121 | private WebElement emptyTrashLink; |
---|
| 122 | |
---|
[4344] | 123 | /** Campo contendo total de emails de uma pasta. */ |
---|
[3663] | 124 | @FindBy(id = "tot_m") |
---|
| 125 | private WebElement totalEmails; |
---|
| 126 | |
---|
[4344] | 127 | /** Checkbox para selecao de todos emails de uma pasta. */ |
---|
[3708] | 128 | @FindBy(id = "chk_box_select_all_messages") |
---|
| 129 | private WebElement selectAllEmails; |
---|
| 130 | |
---|
[4344] | 131 | /** Link para acionar o menu Ferramentas. */ |
---|
[3708] | 132 | @FindBy(xpath = "//td[@id='link_tools']/div/span") |
---|
| 133 | private WebElement toolsMenu; |
---|
| 134 | |
---|
| 135 | @FindBy(xpath = "//div[@id='menu_tools']/table/tbody/tr[4]/td") |
---|
| 136 | private WebElement editFolder; |
---|
| 137 | |
---|
[4527] | 138 | @FindBy(xpath = "//div[@id='menu_tools']/table/tbody/tr[3]/td") |
---|
| 139 | private WebElement editFilter; |
---|
| 140 | |
---|
[3708] | 141 | @FindBy(xpath = "//span[@onclick='wfolders.makeWindow(\"\",\"move_to\")']") |
---|
| 142 | /** Opcao de mover do rodape. */ |
---|
| 143 | private WebElement moveEmailLink; |
---|
| 144 | |
---|
| 145 | @FindBy(id = "dJSWin_wfolders_bok") |
---|
| 146 | private WebElement moveEmailButton; |
---|
| 147 | |
---|
[4344] | 148 | /** Link para encaminhar em email aberto. */ |
---|
[3708] | 149 | @FindBy(xpath = "//div[@id='exmail_main_body']/div[2]/table/tbody/tr[1]/td/table/tbody/tr[1]/td[3]/span[3]") |
---|
| 150 | private WebElement forwardEmail; |
---|
| 151 | |
---|
[4344] | 152 | /** Link para responder em email aberto. */ |
---|
[3745] | 153 | @FindBy(xpath = "//div[@id='exmail_main_body']/div[2]/table/tbody/tr[1]/td/table/tbody/tr[1]/td[3]/span[5]") |
---|
| 154 | private WebElement replyEmail; |
---|
| 155 | |
---|
[4344] | 156 | /** Link para responder a todos em email aberto. */ |
---|
[3745] | 157 | @FindBy(xpath = "//div[@id='exmail_main_body']/div[2]/table/tbody/tr[1]/td/table/tbody/tr[2]/td/div/span[1]") |
---|
| 158 | private WebElement replyAllEmail; |
---|
| 159 | |
---|
[4344] | 160 | /** Link para responder sem historico em email aberto. */ |
---|
[3745] | 161 | @FindBy(xpath = "//div[@id='exmail_main_body']/div[2]/table/tbody/tr[1]/td/table/tbody/tr[2]/td/div/span[2]") |
---|
| 162 | private WebElement replyEmailWithoutHistory; |
---|
| 163 | |
---|
[4344] | 164 | /** Link para responder a todos sem historico em email aberto. */ |
---|
[3745] | 165 | @FindBy(xpath = "//div[@id='exmail_main_body']/div[2]/table/tbody/tr[1]/td/table/tbody/tr[2]/td/div/span[3]") |
---|
| 166 | private WebElement replyAllEmailWithoutHistory; |
---|
| 167 | |
---|
[4344] | 168 | /** Link para editar email na pasta de rascunhos. */ |
---|
[3745] | 169 | @FindBy(xpath = "//div[@id='exmail_main_body']/div[2]/table/tbody/tr[1]/td/table/tbody/tr/td[2]/span[2]/span[1]") |
---|
| 170 | private WebElement editEmail; |
---|
| 171 | |
---|
[3853] | 172 | @FindBy(xpath = "//div[@id='lertContainer']/div[@id='lertWindow']/div[@id='lertButtons']/a[1]") |
---|
| 173 | private WebElement cancelNewEmail; |
---|
| 174 | |
---|
| 175 | @FindBy(xpath = "//div[@id='lertContainer']/div[@id='lertWindow']/div[@id='lertButtons']/a[2]") |
---|
| 176 | private WebElement discardNewEmail; |
---|
| 177 | |
---|
[4344] | 178 | /** |
---|
| 179 | * Esse botao eh no alerta ao fechar uma mensagem nao salva e nao o botao |
---|
| 180 | * salvar para rascunhos. |
---|
| 181 | */ |
---|
[3853] | 182 | @FindBy(xpath = "//div[@id='lertContainer']/div[@id='lertWindow']/div[@id='lertButtons']/a[3]") |
---|
| 183 | private WebElement saveNewEmail; |
---|
| 184 | |
---|
[4527] | 185 | @FindBy(xpath = "//table[@id='folders_tbl']/tbody/tr[1]/td/table/tbody/tr[1]/td/a[1]") |
---|
| 186 | private WebElement searchMessages; |
---|
| 187 | |
---|
[4627] | 188 | @FindBy(id = "em_message_search") |
---|
| 189 | private WebElement searchBox; |
---|
| 190 | |
---|
| 191 | @FindBy(xpath = "//table[@id='folders_tbl']/tbody/tr[1]/td/table/tbody/tr[1]/td/a[1]") |
---|
| 192 | private WebElement searchStart; |
---|
| 193 | |
---|
[4344] | 194 | /** Nome da pasta "Caixa de Entrada". */ |
---|
| 195 | public static final String INBOX_FOLDER = "lINBOXtree_folders"; |
---|
| 196 | |
---|
| 197 | /** Nome da pasta "Enviados". */ |
---|
| 198 | public static final String SENT_FOLDER = "lINBOX/Senttree_folders"; |
---|
| 199 | |
---|
[3663] | 200 | /** |
---|
| 201 | * @param driver |
---|
| 202 | */ |
---|
| 203 | public MailPage(WebDriver driver) { |
---|
| 204 | super(driver); |
---|
| 205 | } |
---|
| 206 | |
---|
[4344] | 207 | /** |
---|
| 208 | * Cria um novo email. |
---|
| 209 | */ |
---|
[3708] | 210 | public void createNewEmail() { |
---|
[3663] | 211 | this.newEmail.click(); |
---|
[3766] | 212 | waitForElement(By.id("to_1")); |
---|
[3708] | 213 | } |
---|
| 214 | |
---|
[4344] | 215 | /** |
---|
| 216 | * Cancela criacao de novo email. |
---|
| 217 | */ |
---|
[3853] | 218 | public void cancelNewEmail() { |
---|
| 219 | this.cancelNewEmail.click(); |
---|
| 220 | } |
---|
| 221 | |
---|
[4620] | 222 | public MailSearchPage openSearchMessageWindow() { |
---|
[4527] | 223 | this.searchMessages.click(); |
---|
| 224 | super.waitForElement(By.id("flagged")); |
---|
| 225 | |
---|
[4620] | 226 | return PageFactory.initElements(driver, MailSearchPage.class); |
---|
[4527] | 227 | |
---|
| 228 | } |
---|
| 229 | |
---|
[4627] | 230 | public void setSearchBox(String text) { |
---|
| 231 | this.searchBox.sendKeys(text); |
---|
| 232 | } |
---|
| 233 | |
---|
| 234 | public void searchStart() { |
---|
| 235 | this.searchStart.click(); |
---|
| 236 | } |
---|
| 237 | |
---|
[4527] | 238 | /** |
---|
[4344] | 239 | * Descarta criacao de novo email. |
---|
| 240 | */ |
---|
[3853] | 241 | public void discardNewEmail() { |
---|
| 242 | this.discardNewEmail.click(); |
---|
| 243 | } |
---|
| 244 | |
---|
[4344] | 245 | /** |
---|
| 246 | * Salva email na pasta rascunhos. |
---|
| 247 | */ |
---|
[3853] | 248 | public void saveNewEmail() { |
---|
| 249 | this.saveNewEmail.click(); |
---|
| 250 | } |
---|
| 251 | |
---|
[4344] | 252 | /** |
---|
| 253 | * Preenche campo assunto. |
---|
| 254 | * |
---|
| 255 | * @param subject |
---|
| 256 | * Assunto a ser preenchido. |
---|
| 257 | */ |
---|
[3708] | 258 | public void setSubject(String subject) { |
---|
[3663] | 259 | this.subject.sendKeys(subject != null ? subject : ""); |
---|
[3708] | 260 | } |
---|
[3663] | 261 | |
---|
[4344] | 262 | /** |
---|
| 263 | * Preenche corpo (texto) do email. |
---|
| 264 | * |
---|
| 265 | * @param body |
---|
| 266 | * Texto a ser preenchido. |
---|
| 267 | */ |
---|
[3708] | 268 | public void setBody(String body) { |
---|
[4780] | 269 | this.setBody(1, body); |
---|
| 270 | } |
---|
| 271 | |
---|
| 272 | public void setBody(Integer id, String body) { |
---|
[3663] | 273 | // Foi o unico jeito que consegui pegar o richtexteditor... |
---|
| 274 | if (body != null) { |
---|
[4344] | 275 | // Troca CR&|LF por <br> |
---|
| 276 | body = body.replaceAll("(\r\n|\r|\n|\n\r)", "<br>"); |
---|
[3663] | 277 | ((JavascriptExecutor) driver) |
---|
[4780] | 278 | .executeScript("document.getElementById('body_" + id |
---|
| 279 | + "').contentWindow.document.body.innerHTML='" |
---|
[3663] | 280 | + body + "';"); |
---|
| 281 | } |
---|
| 282 | } |
---|
| 283 | |
---|
| 284 | /** |
---|
[3708] | 285 | * @param to |
---|
| 286 | * @param subject |
---|
| 287 | * @param body |
---|
| 288 | */ |
---|
| 289 | public void composeEmail(String to, String subject, String body) { |
---|
[4780] | 290 | this.composeEmail(1, to, subject, body); |
---|
| 291 | } |
---|
| 292 | |
---|
| 293 | /** |
---|
| 294 | * @param id |
---|
| 295 | * Corresponde ao id da aba de nova mensagem. |
---|
| 296 | * @param to |
---|
| 297 | * @param subject |
---|
| 298 | * @param body |
---|
| 299 | */ |
---|
| 300 | public void composeEmail(Integer id, String to, String subject, String body) { |
---|
[3708] | 301 | this.createNewEmail(); |
---|
[4780] | 302 | driver.findElement(By.id("to_" + id)).sendKeys(to); |
---|
| 303 | driver.findElement(By.id("subject_" + id)).sendKeys(subject); |
---|
| 304 | this.setBody(id, body); |
---|
[3708] | 305 | } |
---|
| 306 | |
---|
[4780] | 307 | public void quickContactSearch() { |
---|
| 308 | driver.findElement( |
---|
| 309 | By.xpath("//div[@id='exmail_main_body']/div[@id='content_id_1']/div[@id='div_message_scroll_1']/form/table/tbody/tr[4]/td[3]/img")) |
---|
| 310 | .click(); |
---|
| 311 | } |
---|
| 312 | |
---|
[3708] | 313 | public String readEmail(String subject) { |
---|
[4344] | 314 | String id = findEmailIdBySubject(subject); |
---|
[3766] | 315 | id = id.substring(id.lastIndexOf("_") + 1); |
---|
| 316 | clickElement(By.id("td_who_" + id)); |
---|
| 317 | super.waitForElement(By.id("div_message_scroll_" + id + "_r")); |
---|
| 318 | return id; |
---|
[3708] | 319 | } |
---|
| 320 | |
---|
[4962] | 321 | /** |
---|
| 322 | * @param subject |
---|
| 323 | * Procura o email pelo assunto. |
---|
| 324 | * @return Id do email. |
---|
| 325 | */ |
---|
| 326 | public String getEmailId(String subject) { |
---|
| 327 | String id = findEmailIdBySubject(subject); |
---|
| 328 | return id.substring(id.lastIndexOf("_") + 1); |
---|
| 329 | } |
---|
| 330 | |
---|
| 331 | /** |
---|
| 332 | * Le um email gerado a partir de um agendamento. |
---|
| 333 | * |
---|
| 334 | * @param subject |
---|
| 335 | * @return |
---|
| 336 | */ |
---|
| 337 | public AppointmentEmailPage readAppointmentEmail(String subject) { |
---|
| 338 | String id = findEmailIdBySubject(subject); |
---|
| 339 | id = id.substring(id.lastIndexOf("_") + 1); |
---|
| 340 | clickElement(By.id("td_who_" + id)); |
---|
| 341 | super.waitForElement(By.id("div_message_scroll_" + id + "_r")); |
---|
| 342 | return PageFactory.initElements(driver, AppointmentEmailPage.class); |
---|
| 343 | } |
---|
| 344 | |
---|
[3745] | 345 | public void editEmail() { |
---|
[3766] | 346 | super.waitForElement(By |
---|
| 347 | .xpath("//div[@id='exmail_main_body']/div[2]/table/tbody/tr[1]/td/table/tbody/tr/td[2]/span[2]/span[1]")); |
---|
[3799] | 348 | // div[@id='exmail_main_body']/div[@id='content_id_9_r']/table/tbody/tr[1]/td/table/tbody/tr/td[2]/span[1] |
---|
[3745] | 349 | this.editEmail.click(); |
---|
| 350 | } |
---|
| 351 | |
---|
[3799] | 352 | public void editEmail(String id) { |
---|
| 353 | super.waitForElement(By |
---|
| 354 | .xpath("//div[@id='exmail_main_body']/div[2]/table/tbody/tr[1]/td/table/tbody/tr/td[2]/span[2]/span[1]")); |
---|
| 355 | // div[@id='exmail_main_body']/div[@id='content_id_9_r']/table/tbody/tr[1]/td/table/tbody/tr/td[2]/span[1] |
---|
| 356 | this.editEmail.click(); |
---|
| 357 | waitForElement(By.id("content_id_" + id)); |
---|
| 358 | } |
---|
| 359 | |
---|
[3708] | 360 | /** |
---|
| 361 | * Encaminha uma mensagem. |
---|
| 362 | * |
---|
| 363 | * @param id |
---|
| 364 | * Id da mensagem a ser encaminhada |
---|
| 365 | * @param to |
---|
| 366 | * Destinatario |
---|
| 367 | */ |
---|
| 368 | public void forwardEmail(String id, String to) { |
---|
[3766] | 369 | super.waitForElement(By |
---|
| 370 | .xpath("//div[@id='exmail_main_body']/div[2]/table/tbody/tr[1]/td/table/tbody/tr[1]/td[3]/span[3]")); |
---|
[3708] | 371 | this.forwardEmail.click(); |
---|
[3766] | 372 | super.waitForElement(By.id("to_" + id)); |
---|
[3708] | 373 | driver.findElement(By.id("to_" + id)).sendKeys(to); |
---|
| 374 | driver.findElement(By.id("send_button_" + id)).click(); |
---|
| 375 | } |
---|
| 376 | |
---|
[4527] | 377 | /** |
---|
| 378 | * Mostra detalhes (cabecalho do email sendo lido). |
---|
| 379 | * |
---|
| 380 | * @param id |
---|
| 381 | */ |
---|
| 382 | public void showDetails(String id) { |
---|
| 383 | driver.findElement(By.id("option_hide_more_" + id + "_r")).click(); |
---|
| 384 | } |
---|
| 385 | |
---|
| 386 | /** |
---|
| 387 | * Remove anexos do email sendo lido. |
---|
| 388 | */ |
---|
| 389 | public void removeAllAttachments() { |
---|
| 390 | driver.findElement( |
---|
| 391 | 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]")) |
---|
| 392 | .click(); |
---|
| 393 | Alert alert = driver.switchTo().alert(); |
---|
| 394 | 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?" |
---|
| 395 | .equals(alert.getText())); |
---|
| 396 | alert.accept(); |
---|
| 397 | } |
---|
| 398 | |
---|
| 399 | public void blockRecipient(String message) { |
---|
| 400 | driver.findElement( |
---|
| 401 | 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")) |
---|
| 402 | .click(); |
---|
[4627] | 403 | this.waitLoading(); |
---|
| 404 | Alert alert = driver.switchTo().alert(); |
---|
| 405 | assert (message.equals(alert.getText())); |
---|
| 406 | alert.accept(); |
---|
| 407 | } |
---|
| 408 | |
---|
[4780] | 409 | public void waitLoading() { |
---|
[4527] | 410 | // Espera pelo "Carregando..." aparecer. |
---|
| 411 | waitForElement(By.id("divProgressBar")); |
---|
| 412 | waitForElement(By.id("divScrollMain_0")); |
---|
| 413 | // Espera pelo "Carregando..." desaparecer. |
---|
| 414 | isNotDisplayed(this |
---|
| 415 | .waitFindElement(By.id("divProgressBar"), 5000, 1000)); |
---|
| 416 | } |
---|
| 417 | |
---|
[3745] | 418 | private void reply(String id) { |
---|
[3766] | 419 | super.waitForElement(By.id("to_" + id)); |
---|
[3745] | 420 | driver.findElement(By.id("send_button_" + id)).click(); |
---|
| 421 | } |
---|
| 422 | |
---|
[3708] | 423 | /** |
---|
[3745] | 424 | * Responde uma mensagem. |
---|
| 425 | * |
---|
| 426 | * @param id |
---|
| 427 | * Id da mensagem a ser respondida |
---|
| 428 | */ |
---|
| 429 | public void replyEmail(String id) { |
---|
[3766] | 430 | super.waitForElement(By |
---|
| 431 | .xpath("//div[@id='exmail_main_body']/div[2]/table/tbody/tr[1]/td/table/tbody/tr[1]/td[3]/span[5]")); |
---|
[3745] | 432 | this.replyEmail.click(); |
---|
| 433 | this.reply(id); |
---|
| 434 | } |
---|
| 435 | |
---|
| 436 | /** |
---|
| 437 | * Responde uma mensagem. |
---|
| 438 | * |
---|
| 439 | * @param id |
---|
| 440 | * Id da mensagem a ser respondida |
---|
| 441 | */ |
---|
| 442 | public void replyAllEmailWithoutHistory(String id) { |
---|
[4902] | 443 | super.findAndClickElement(By.id("msg_opt_reply_options_" + id + "_r")); |
---|
[3766] | 444 | super.waitForElement(By |
---|
| 445 | .xpath("//div[@id='exmail_main_body']/div[2]/table/tbody/tr[1]/td/table/tbody/tr[2]/td/div/span[3]")); |
---|
[3745] | 446 | this.replyAllEmailWithoutHistory.click(); |
---|
| 447 | this.reply(id); |
---|
| 448 | } |
---|
| 449 | |
---|
| 450 | /** |
---|
| 451 | * Responde uma mensagem. |
---|
| 452 | * |
---|
| 453 | * @param id |
---|
| 454 | * Id da mensagem a ser respondida |
---|
| 455 | */ |
---|
| 456 | public void replyEmailWithoutHistory(String id) { |
---|
[4902] | 457 | super.findAndClickElement(By.id("msg_opt_reply_options_" + id + "_r")); |
---|
[3766] | 458 | super.waitForElement(By |
---|
| 459 | .xpath("//div[@id='exmail_main_body']/div[2]/table/tbody/tr[1]/td/table/tbody/tr[2]/td/div/span[2]")); |
---|
[3745] | 460 | this.replyEmailWithoutHistory.click(); |
---|
| 461 | this.reply(id); |
---|
| 462 | } |
---|
| 463 | |
---|
| 464 | /** |
---|
| 465 | * Responde uma mensagem. |
---|
| 466 | * |
---|
| 467 | * @param id |
---|
| 468 | * Id da mensagem a ser respondida |
---|
| 469 | */ |
---|
| 470 | public void replyAllEmail(String id) { |
---|
[4902] | 471 | super.findAndClickElement(By.id("msg_opt_reply_options_" + id + "_r")); |
---|
[3766] | 472 | super.waitForElement(By |
---|
| 473 | .xpath("//div[@id='exmail_main_body']/div[2]/table/tbody/tr[1]/td/table/tbody/tr[2]/td/div/span[1]")); |
---|
[3745] | 474 | this.replyAllEmail.click(); |
---|
| 475 | this.reply(id); |
---|
| 476 | } |
---|
| 477 | |
---|
| 478 | /** |
---|
[3663] | 479 | * Abre uma pasta de email especifica. |
---|
| 480 | * |
---|
| 481 | * @param folder |
---|
| 482 | * Pasta de email a ser aberta. |
---|
| 483 | */ |
---|
[4527] | 484 | public void openFolder(String folder, boolean waitEmail) { |
---|
| 485 | waitForElement(By.id(folder)); |
---|
[3766] | 486 | clickElement(By.id(folder)); |
---|
[4344] | 487 | // Espera pelo "Carregando..." aparecer. |
---|
| 488 | waitForElement(By.id("divProgressBar")); |
---|
[4780] | 489 | // waitForElement(By.id("divScrollMain_0")); |
---|
[4344] | 490 | // Espera pelo "Carregando..." desaparecer. |
---|
| 491 | isNotDisplayed(this |
---|
| 492 | .waitFindElement(By.id("divProgressBar"), 5000, 1000)); |
---|
[4527] | 493 | if (waitEmail) { |
---|
| 494 | waitForElement(By |
---|
| 495 | .xpath("//div[@id='divScrollMain_0']/table[@id='table_box']/tbody[@id='tbody_box']/tr[1]/td[1]/input[1]")); |
---|
| 496 | } |
---|
[3663] | 497 | } |
---|
| 498 | |
---|
[4527] | 499 | public void openFolder(String folder) { |
---|
| 500 | openFolder(folder, true); |
---|
| 501 | } |
---|
| 502 | |
---|
[3663] | 503 | /** |
---|
| 504 | * Abre uma pasta de email especifica. |
---|
| 505 | * |
---|
| 506 | * @param folder |
---|
| 507 | * Pasta de email a ser aberta. |
---|
| 508 | */ |
---|
| 509 | public void openFolder(WebElement folder) { |
---|
| 510 | folder.click(); |
---|
[3766] | 511 | waitForElement(By.id("divScrollMain_0")); |
---|
[3663] | 512 | } |
---|
| 513 | |
---|
[4344] | 514 | /** |
---|
| 515 | * Filtra somente as mensagens importantes. |
---|
| 516 | */ |
---|
[3708] | 517 | public void setImportantFilter() { |
---|
| 518 | this.importantFilter.click(); |
---|
| 519 | } |
---|
| 520 | |
---|
[3663] | 521 | /** |
---|
[4527] | 522 | * Filtra somente as mensagens lidas. |
---|
| 523 | */ |
---|
| 524 | public void setReadFilter() { |
---|
| 525 | this.readFilter.click(); |
---|
| 526 | } |
---|
| 527 | |
---|
| 528 | /** |
---|
| 529 | * Filtra somente as mensagens nao lidas. |
---|
| 530 | */ |
---|
| 531 | public void setNotReadFilter() { |
---|
| 532 | this.notReadFilter.click(); |
---|
| 533 | } |
---|
| 534 | |
---|
| 535 | /** |
---|
| 536 | * Filtra somente as mensagens respondidas. |
---|
| 537 | */ |
---|
| 538 | public void setAnsweredFilter() { |
---|
| 539 | this.answeredFilter.click(); |
---|
| 540 | } |
---|
| 541 | |
---|
| 542 | /** |
---|
[3663] | 543 | * Limpa a lixeira. |
---|
| 544 | */ |
---|
| 545 | public void cleanupTrash() { |
---|
| 546 | this.openFolder(this.trashFolder); |
---|
| 547 | this.emptyTrashLink.click(); |
---|
| 548 | } |
---|
| 549 | |
---|
| 550 | /** |
---|
| 551 | * @return Numero de emails na pasta selecionada. |
---|
| 552 | */ |
---|
| 553 | public int getTotalEmails() { |
---|
| 554 | return Integer.valueOf(this.totalEmails.getText()); |
---|
| 555 | } |
---|
| 556 | |
---|
[4344] | 557 | /** |
---|
| 558 | * Move email para um pasta no servidor. |
---|
| 559 | * |
---|
| 560 | * @param folderName |
---|
| 561 | * Nome da pasta pre-existente no servidor. |
---|
| 562 | */ |
---|
[3708] | 563 | public void moveEmail(String folderName) { |
---|
| 564 | this.moveEmailLink.click(); |
---|
[4902] | 565 | super.findAndClickElement(By.id(folderName)); |
---|
[3708] | 566 | this.moveEmailButton.click(); |
---|
| 567 | } |
---|
| 568 | |
---|
[4344] | 569 | /** |
---|
| 570 | * Edita nome de pasta. |
---|
| 571 | */ |
---|
[4620] | 572 | public MailFolderPage editFolder() { |
---|
[3708] | 573 | this.toolsMenu.click(); |
---|
[3766] | 574 | this.waitForElement(By |
---|
| 575 | .xpath("//div[@id='menu_tools']/table/tbody/tr[4]/td")); |
---|
[3708] | 576 | this.editFolder.click(); |
---|
| 577 | |
---|
[4620] | 578 | return PageFactory.initElements(driver, MailFolderPage.class); |
---|
[4606] | 579 | } |
---|
| 580 | |
---|
[4344] | 581 | /** |
---|
[4527] | 582 | * Edita filtros. |
---|
| 583 | */ |
---|
[4620] | 584 | public MailFilterPage editFilter() { |
---|
[4527] | 585 | this.toolsMenu.click(); |
---|
| 586 | this.waitForElement(By |
---|
| 587 | .xpath("//div[@id='menu_tools']/table/tbody/tr[3]/td")); |
---|
| 588 | this.editFilter.click(); |
---|
[4606] | 589 | this.waitForElement(By.id("set_rules_img")); |
---|
[4527] | 590 | |
---|
[4620] | 591 | return PageFactory.initElements(driver, MailFilterPage.class); |
---|
[4527] | 592 | } |
---|
| 593 | |
---|
| 594 | /** |
---|
[3663] | 595 | * Marca email sendo composto como importante. |
---|
| 596 | */ |
---|
[3708] | 597 | public void checkImportantFlag() { |
---|
[3663] | 598 | this.important.click(); |
---|
| 599 | } |
---|
| 600 | |
---|
[4344] | 601 | /** |
---|
| 602 | * Marca email como importante apos ler. |
---|
| 603 | */ |
---|
[3708] | 604 | public void setImportantFlag() { |
---|
[3766] | 605 | this.waitForElement(By |
---|
| 606 | .xpath("//div[@id='exmail_main_body']/div[2]/table/tbody/tr[1]/td/table/tbody/tr[1]/td[2]/span[3]")); |
---|
[3708] | 607 | this.importantFlag.click(); |
---|
| 608 | } |
---|
| 609 | |
---|
[4344] | 610 | /** |
---|
| 611 | * Marca email como normal apos ler. |
---|
| 612 | */ |
---|
[3708] | 613 | public void setNormalFlag() { |
---|
[3766] | 614 | this.waitForElement(By |
---|
| 615 | .xpath("//div[@id='exmail_main_body']/div[2]/table/tbody/tr[1]/td/table/tbody/tr[1]/td[2]/span[3]")); |
---|
[3708] | 616 | this.normalFlag.click(); |
---|
| 617 | } |
---|
| 618 | |
---|
[4344] | 619 | /** |
---|
| 620 | * Marca email como nao lido apos ler. |
---|
| 621 | */ |
---|
[3708] | 622 | public void setNotReadFlag() { |
---|
[3766] | 623 | this.waitForElement(By |
---|
| 624 | .xpath("//div[@id='exmail_main_body']/div[2]/table/tbody/tr[1]/td/table/tbody/tr[1]/td[2]/span[2]")); |
---|
[3708] | 625 | this.notReadFlag.click(); |
---|
| 626 | } |
---|
| 627 | |
---|
[3663] | 628 | /** |
---|
| 629 | * Marca solicitacao de confirmacao de leitura do email sendo composto. |
---|
| 630 | */ |
---|
[3708] | 631 | public void checkReturnReceipt() { |
---|
[3663] | 632 | this.returnReceipt.click(); |
---|
| 633 | } |
---|
| 634 | |
---|
| 635 | /** |
---|
| 636 | * Salva email sendo composto (devera ir para a pasta de Rascunhos). |
---|
| 637 | * |
---|
| 638 | * TODO adicionar teste para verificar se o email realmente esta presente na |
---|
| 639 | * pasta Rascunhos?? |
---|
| 640 | */ |
---|
| 641 | public void saveEmail() { |
---|
| 642 | this.saveEmail.click(); |
---|
| 643 | } |
---|
| 644 | |
---|
| 645 | /** |
---|
| 646 | * Apaga email previamente selecionado. |
---|
| 647 | */ |
---|
| 648 | public void deleteEmail() { |
---|
| 649 | this.deleteEmailLink.click(); |
---|
| 650 | } |
---|
| 651 | |
---|
[4344] | 652 | /** |
---|
[4527] | 653 | * Exporta email previamente selecionado. |
---|
| 654 | */ |
---|
| 655 | public void exportEmail() { |
---|
| 656 | this.exportEmailLink.click(); |
---|
| 657 | } |
---|
| 658 | |
---|
[4780] | 659 | public void importEmail() { |
---|
| 660 | this.importEmailLink.click(); |
---|
| 661 | } |
---|
| 662 | |
---|
| 663 | public void importSelectFolder() { |
---|
| 664 | this.importSelectFolderButton.click(); |
---|
| 665 | } |
---|
| 666 | |
---|
[4527] | 667 | /** |
---|
[4344] | 668 | * Seleciona todos emails da pasta corrente. |
---|
| 669 | */ |
---|
[3708] | 670 | public void selectAllEmails() { |
---|
| 671 | this.selectAllEmails.click(); |
---|
| 672 | } |
---|
| 673 | |
---|
[3663] | 674 | /** |
---|
| 675 | * Adiciona email no campo de copia oculta. |
---|
| 676 | * |
---|
| 677 | * @param email |
---|
| 678 | * Email a ser adicionado. |
---|
| 679 | */ |
---|
| 680 | public void setBlindCarbonCopy(String email) { |
---|
| 681 | this.blindCarbonCopyLink.click(); |
---|
| 682 | this.blindCarbonCopy.sendKeys(email); |
---|
| 683 | } |
---|
| 684 | |
---|
| 685 | /** |
---|
| 686 | * Adiciona email no campo de copia. |
---|
| 687 | * |
---|
| 688 | * @param email |
---|
| 689 | * Email a ser adicionado. |
---|
| 690 | */ |
---|
| 691 | public void setCarbonCopy(String email) { |
---|
| 692 | this.carbonCopyLink.click(); |
---|
| 693 | this.carbonCopy.sendKeys(email); |
---|
| 694 | } |
---|
| 695 | |
---|
| 696 | /** |
---|
| 697 | * Anexo um arquivo no email sendo composto. |
---|
| 698 | * |
---|
| 699 | * @param attachment |
---|
| 700 | * Caminho para o arquivo a ser anexado. |
---|
| 701 | */ |
---|
| 702 | public void addAttachment(String attachment) { |
---|
| 703 | this.attachmentLink.click(); |
---|
| 704 | this.attachment.sendKeys(attachment); |
---|
| 705 | } |
---|
| 706 | |
---|
[4344] | 707 | /** |
---|
| 708 | * Remove anexo do email sendo composto. |
---|
| 709 | */ |
---|
| 710 | public void removeAttachment() { |
---|
| 711 | this.removeAttachmentLink.click(); |
---|
| 712 | } |
---|
| 713 | |
---|
[3708] | 714 | public void addAttachment2(String attachment) { |
---|
| 715 | this.attachmentLink.click(); |
---|
| 716 | this.attachment2.sendKeys(attachment); |
---|
| 717 | } |
---|
| 718 | |
---|
[3663] | 719 | /** |
---|
| 720 | * Envia email sendo composto. |
---|
| 721 | */ |
---|
| 722 | public void sendMail() { |
---|
[4780] | 723 | this.sendMail(1); |
---|
[3663] | 724 | } |
---|
| 725 | |
---|
[3766] | 726 | /** |
---|
[4780] | 727 | * @param id |
---|
| 728 | */ |
---|
| 729 | public void sendMail(Integer id) { |
---|
| 730 | driver.findElement(By.id("send_button_" + id)).click(); |
---|
| 731 | } |
---|
| 732 | |
---|
| 733 | /** |
---|
[3766] | 734 | * Fecha aba do email sendo composto e confirma que email nao esta salvo. |
---|
| 735 | */ |
---|
| 736 | public void closeMail() { |
---|
| 737 | this.closeMail(true); |
---|
| 738 | } |
---|
| 739 | |
---|
[3799] | 740 | /** |
---|
[4344] | 741 | * @param discardEmail |
---|
[3799] | 742 | */ |
---|
[4344] | 743 | public void closeMail(boolean discardEmail) { |
---|
[3799] | 744 | |
---|
| 745 | // Na versao Serpro: |
---|
| 746 | // td[@id='border_id_1']/table/tbody/tr/td[2]/img |
---|
| 747 | |
---|
| 748 | // Na versao Comunidade: |
---|
| 749 | // td[@id='border_id_1']/div/div[2]/img |
---|
| 750 | |
---|
| 751 | // Resolvi usando o xpath abaixo: |
---|
| 752 | super.clickElement(By.xpath("//td[@id='border_id_1']//img")); |
---|
| 753 | |
---|
[4344] | 754 | // if (checkAlert) { |
---|
| 755 | // Alert closeAlert = driver.switchTo().alert(); |
---|
| 756 | // closeAlert.accept(); |
---|
| 757 | // } |
---|
| 758 | |
---|
| 759 | // Clica em descartar. |
---|
| 760 | if (discardEmail) { |
---|
| 761 | super.clickElement(By |
---|
| 762 | .xpath("//div[@id='lertWindow']/div[@id='lertButtons']/a[2]")); |
---|
[3766] | 763 | } |
---|
| 764 | } |
---|
| 765 | |
---|
[4344] | 766 | public void closeMail(String id, boolean discardEmail) { |
---|
[3853] | 767 | super.clickElement(By.xpath("//td[@id='border_id_" + id + "']//img")); |
---|
[4344] | 768 | // Clica em cancelar |
---|
| 769 | if (discardEmail) { |
---|
| 770 | super.clickElement(By |
---|
| 771 | .xpath("//div[@id='lertWindow']/div[@id='lertButtons']/a[2]")); |
---|
| 772 | } |
---|
[3853] | 773 | } |
---|
| 774 | |
---|
[4344] | 775 | /** |
---|
| 776 | * Envia email. |
---|
| 777 | * |
---|
| 778 | * @param id |
---|
| 779 | * Id do email a ser enviado. |
---|
| 780 | */ |
---|
[3745] | 781 | public void sendMail(String id) { |
---|
[4902] | 782 | super.findAndClickElement(By.id("send_button_" + id)); |
---|
[3745] | 783 | } |
---|
| 784 | |
---|
[3663] | 785 | /** |
---|
| 786 | * @param to |
---|
| 787 | * @param subject |
---|
| 788 | */ |
---|
| 789 | public void composeEmail(String to, String subject) { |
---|
| 790 | composeEmail(to, subject, null); |
---|
| 791 | } |
---|
| 792 | |
---|
| 793 | /** |
---|
| 794 | * @param to |
---|
| 795 | */ |
---|
| 796 | public void composeEmail(String to) { |
---|
| 797 | composeEmail(to, null, null); |
---|
| 798 | } |
---|
| 799 | |
---|
| 800 | /** |
---|
| 801 | * Procura um email pelo assunto. |
---|
| 802 | * |
---|
| 803 | * @param subject |
---|
| 804 | * Assunto a ser procurado. |
---|
| 805 | * @param select |
---|
| 806 | * Se email encontrado, deseja seleciona-lo? |
---|
[4344] | 807 | * @return "id" do email se encontrar, <code>null</code> se nao encontrar. |
---|
[3663] | 808 | */ |
---|
| 809 | public String findEmailIdBySuject(String subject, boolean select) { |
---|
[4527] | 810 | // System.out.println("searching for --------->" + subject); |
---|
[3663] | 811 | String html = driver.getPageSource(); |
---|
[4344] | 812 | // System.out.println(html.indexOf(subject)); |
---|
| 813 | // System.out.println(html); |
---|
| 814 | if (html.indexOf(subject) >= 0) { |
---|
| 815 | String part1 = StringUtils.substringBefore(html, subject); |
---|
| 816 | int start = StringUtils.lastIndexOf(part1, "id=\"") + 4; |
---|
| 817 | int last = StringUtils.indexOf(part1, "\"", start); |
---|
| 818 | String id = StringUtils.substring(part1, start, last); |
---|
[4527] | 819 | // System.out.println(id); |
---|
[4344] | 820 | if (select) { |
---|
| 821 | // Marca checkbox correspondente ao id da mensagem. |
---|
| 822 | clickElement(By.id("check_box" + id.substring(1))); |
---|
| 823 | } |
---|
| 824 | return id; |
---|
[3663] | 825 | } |
---|
[4527] | 826 | System.out.println("email not found"); |
---|
[4344] | 827 | return null; |
---|
[3663] | 828 | } |
---|
| 829 | |
---|
| 830 | /** |
---|
[3708] | 831 | * @return Ids de todos os emails da pasta selecionada. |
---|
| 832 | */ |
---|
| 833 | public String[] getEmailIds() { |
---|
| 834 | String[] ids = new String[this.getTotalEmails()]; |
---|
| 835 | for (int i = 1; i <= this.getTotalEmails(); i++) { |
---|
| 836 | String id = driver |
---|
| 837 | .findElement( |
---|
| 838 | By.xpath("//div[@id='divScrollMain_0']/table[@id='table_box']/tbody[@id='tbody_box']/tr[" |
---|
| 839 | + i + "]/td[1]/input[1]")).getAttribute( |
---|
| 840 | "id"); |
---|
| 841 | ids[i - 1] = id.substring(id.lastIndexOf("_") + 1); |
---|
| 842 | } |
---|
| 843 | return ids; |
---|
| 844 | } |
---|
| 845 | |
---|
| 846 | /** |
---|
| 847 | * @param emailId |
---|
| 848 | * Id do email. |
---|
| 849 | * @return <code>true</code> se email importante, <code>false</code> caso |
---|
| 850 | * contrario. |
---|
| 851 | */ |
---|
| 852 | public boolean isImportant(String emailId) { |
---|
| 853 | return super |
---|
| 854 | .isDisplayed((RenderedWebElement) driver.findElement(By |
---|
| 855 | .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='" |
---|
| 856 | + emailId + "']/td[5]/img"))); |
---|
| 857 | } |
---|
| 858 | |
---|
[4344] | 859 | /** |
---|
[4527] | 860 | * @param emailId |
---|
| 861 | * Id do email. |
---|
| 862 | * @return <code>true</code> se email lido, <code>false</code> caso |
---|
| 863 | * contrario. |
---|
| 864 | */ |
---|
| 865 | public boolean isRead(String emailId) { |
---|
| 866 | return super |
---|
| 867 | .isDisplayed((RenderedWebElement) driver.findElement(By |
---|
| 868 | .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='" |
---|
| 869 | + emailId |
---|
| 870 | + "']/td[@id='td_message_unseen_" |
---|
| 871 | + emailId + "']/img"))); |
---|
| 872 | } |
---|
| 873 | |
---|
| 874 | /** |
---|
| 875 | * @param emailId |
---|
| 876 | * Id do email. |
---|
| 877 | * @return <code>true</code> se email nao lido, <code>false</code> caso |
---|
| 878 | * contrario. |
---|
| 879 | */ |
---|
| 880 | public boolean isNotRead(String emailId) { |
---|
| 881 | return super |
---|
| 882 | .isDisplayed((RenderedWebElement) driver.findElement(By |
---|
| 883 | .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='" |
---|
| 884 | + emailId |
---|
| 885 | + "']/td[@id='td_message_unseen_" |
---|
| 886 | + emailId + "']/img"))); |
---|
| 887 | } |
---|
| 888 | |
---|
| 889 | /** |
---|
| 890 | * @param emailId |
---|
| 891 | * Id do email. |
---|
| 892 | * @return <code>true</code> se email respondido, <code>false</code> caso |
---|
| 893 | * contrario. |
---|
| 894 | */ |
---|
| 895 | public boolean isAnswered(String emailId) { |
---|
| 896 | return super |
---|
| 897 | .isDisplayed((RenderedWebElement) driver.findElement(By |
---|
| 898 | .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='" |
---|
| 899 | + emailId |
---|
| 900 | + "']/td[@id='td_message_answered_" |
---|
| 901 | + emailId + "']/img"))); |
---|
| 902 | } |
---|
| 903 | |
---|
| 904 | /** |
---|
[4344] | 905 | * Procura email baseado no assunto na pasta corrente. |
---|
| 906 | * |
---|
| 907 | * @param subject |
---|
| 908 | * Assunto a ser pesquisado. |
---|
| 909 | * @return Id do email encontrado. |
---|
| 910 | */ |
---|
| 911 | public String findEmailIdBySubject(String subject) { |
---|
[3708] | 912 | return findEmailIdBySuject(subject, false); |
---|
| 913 | } |
---|
| 914 | |
---|
| 915 | /** |
---|
[4344] | 916 | * Procura email baseado no assunto em uma pasta especifica. |
---|
| 917 | * |
---|
| 918 | * @param folder |
---|
| 919 | * Pasta de pesquisa. |
---|
| 920 | * @param subject |
---|
| 921 | * Assunto a ser pesquisado. |
---|
| 922 | * @return Id do email encontrado. |
---|
| 923 | */ |
---|
| 924 | public String findEmailIdBySubject(String folder, String subject) { |
---|
| 925 | this.openFolder(folder); |
---|
| 926 | return findEmailIdBySuject(subject, false); |
---|
| 927 | } |
---|
| 928 | |
---|
| 929 | /** |
---|
[3663] | 930 | * Verifica se mensagem informada corresponde ao exibido pelo Expresso na |
---|
| 931 | * div onde sao exibidas mensagens ao usuario. |
---|
| 932 | * |
---|
| 933 | * @param message |
---|
| 934 | * Mensagem a ser validada. |
---|
| 935 | */ |
---|
| 936 | public void assertMessage(String message) { |
---|
[4902] | 937 | Assert.assertEquals( |
---|
| 938 | getDisplayedElementContent(By.id("em_div_write_msg")), message); |
---|
[3663] | 939 | } |
---|
[3799] | 940 | |
---|
| 941 | /** |
---|
| 942 | * @return the to |
---|
| 943 | */ |
---|
| 944 | public WebElement getTo(String id) { |
---|
| 945 | waitForElement(By.id("to_" + id)); |
---|
| 946 | // findAndClickElement("to_" + id); |
---|
| 947 | // return getDisplayedElementContent(id); |
---|
| 948 | return driver.findElement(By.id("to_" + id)); |
---|
| 949 | } |
---|
| 950 | |
---|
| 951 | /** |
---|
| 952 | * @return the subject |
---|
| 953 | */ |
---|
| 954 | public WebElement getSubject(String id) { |
---|
| 955 | waitForElement(By.id("subject_" + id)); |
---|
| 956 | return driver.findElement(By.id("subject_" + id)); |
---|
| 957 | } |
---|
| 958 | |
---|
| 959 | /** |
---|
| 960 | * @return the blindCarbonCopy |
---|
| 961 | */ |
---|
| 962 | public WebElement getBlindCarbonCopy(String id) { |
---|
| 963 | waitForElement(By.id("cco_" + id)); |
---|
| 964 | return driver.findElement(By.id("cco_" + id)); |
---|
| 965 | } |
---|
| 966 | |
---|
| 967 | /** |
---|
| 968 | * @return the carbonCopy |
---|
| 969 | */ |
---|
| 970 | public WebElement getCarbonCopy(String id) { |
---|
| 971 | waitForElement(By.id("cc_" + id)); |
---|
| 972 | return driver.findElement(By.id("cc_" + id)); |
---|
| 973 | } |
---|
| 974 | |
---|
[4344] | 975 | /** |
---|
| 976 | * @param id |
---|
| 977 | * Id do email. |
---|
| 978 | * @return Texto do email. |
---|
| 979 | */ |
---|
[3799] | 980 | public Object getBody(String id) { |
---|
| 981 | waitForElement(By.id("body_" + id)); |
---|
| 982 | return ((JavascriptExecutor) driver) |
---|
| 983 | .executeScript("return document.getElementById('body_" + id |
---|
| 984 | + "').contentWindow.document.body.innerHTML;"); |
---|
| 985 | } |
---|
| 986 | |
---|
[4962] | 987 | /** |
---|
| 988 | * O email de notificacao de agendamento tem um "_r" no fim do id. |
---|
| 989 | * |
---|
| 990 | * @param id |
---|
| 991 | * @return |
---|
| 992 | */ |
---|
| 993 | public Object getAppointmentBody(String id) { |
---|
| 994 | waitForElement(By.id("body_" + id + "_r")); |
---|
| 995 | return ((JavascriptExecutor) driver) |
---|
| 996 | .executeScript("return document.getElementById('body_" + id |
---|
| 997 | + "_r" + "').innerHTML;"); |
---|
| 998 | } |
---|
| 999 | |
---|
[4780] | 1000 | public WebElement getReturnReceipt() { |
---|
| 1001 | return returnReceipt; |
---|
| 1002 | } |
---|
[3663] | 1003 | } |
---|