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