Changeset 4344 for devel/testlink/automation2.0/src/test/java/org/expressolivre/cte/pages/email/MailPage.java
- Timestamp:
- 05/11/11 15:25:35 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
devel/testlink/automation2.0/src/test/java/org/expressolivre/cte/pages/email/MailPage.java
r3853 r4344 19 19 public class MailPage extends Page { 20 20 21 /** Botao para criar novo email. */ 21 22 @FindBy(xpath = "//table[@id='folders_tbl']/tbody/tr[1]/td/table/tbody/tr[2]/td/div/span") 22 23 private WebElement newEmail; 23 24 25 /** Campo "Para:". */ 24 26 @FindBy(id = "to_1") 25 27 private WebElement to; 26 28 29 /** Campo "Assunto:". */ 27 30 @FindBy(id = "subject_1") 28 31 private WebElement subject; 29 32 33 /** Botao para enviar email. */ 30 34 @FindBy(id = "send_button_1") 31 35 private WebElement send; 32 36 37 /** Flag de importante no momento de compor um email. */ 33 38 @FindBy(id = "important_message_1") 34 /** Flag de importante no momento de compor um email. */35 39 private WebElement important; 36 40 41 /** Flag de importante de um email aberto. */ 37 42 @FindBy(xpath = "//div[@id='exmail_main_body']/div[2]/table/tbody/tr[1]/td/table/tbody/tr[1]/td[2]/span[3]") 38 /** Flag de importante de um email aberto. */39 43 private WebElement importantFlag; 40 44 45 /** Filtra emails importantes. */ 41 46 @FindBy(id = "span_flag_FLAGGED") 42 /** Filtra emails importantes. */43 47 private WebElement importantFilter; 44 48 49 /** Flag normal de um email aberto. */ 45 50 @FindBy(xpath = "//div[@id='exmail_main_body']/div[2]/table/tbody/tr[1]/td/table/tbody/tr[1]/td[2]/span[3]") 46 51 private WebElement normalFlag; 47 52 53 /** Flag nao lido de um email aberto. */ 48 54 @FindBy(xpath = "//div[@id='exmail_main_body']/div[2]/table/tbody/tr[1]/td/table/tbody/tr[1]/td[2]/span[2]") 49 55 private WebElement notReadFlag; 50 56 57 /** Checkbox de confirmacao de leitura. */ 51 58 @FindBy(id = "return_receipt_1") 52 59 private WebElement returnReceipt; 53 60 61 /** Link para acionar exibicao do campo copia oculta Cco. */ 54 62 @FindBy(id = "a_cco_link_1") 55 63 private WebElement blindCarbonCopyLink; 56 64 65 /** Campo copia oculta "Cco:". */ 57 66 @FindBy(id = "cco_1") 58 67 private WebElement blindCarbonCopy; 59 68 69 /** Link para acionar exibicao do campo copia Cc. */ 60 70 @FindBy(id = "a_cc_link_1") 61 71 private WebElement carbonCopyLink; 62 72 73 /** Campo copia "Cc:". */ 63 74 @FindBy(id = "cc_1") 64 75 private WebElement carbonCopy; 65 76 77 /** Link para salvar email. */ 66 78 @FindBy(id = "save_message_options_1") 67 79 private WebElement saveEmail; 68 80 81 /** Link para adicionar anexos ao email. */ 69 82 @FindBy(linkText = "Anexos: adicionar+") 70 83 private WebElement attachmentLink; 71 84 85 /** Link para adicionar 1o anexo. */ 72 86 @FindBy(id = "inputFile_1_1") 73 87 private WebElement attachment; 74 88 89 /** Link para adicionar 2o anexo. */ 75 90 @FindBy(id = "inputFile_1_2") 76 91 private WebElement attachment2; 77 92 93 /** Link para remover anexo. */ 94 @FindBy(id = "linkFile_1_1") 95 private WebElement removeAttachmentLink; 96 97 /** Link para apagar email quando este estiver aberto. */ 78 98 @FindBy(xpath = "//div[@id='footer_menu']/table[@id='footer_box']/tbody/tr[@id='table_message']/td[@id='span_options']/span[1]/span") 79 99 private WebElement deleteEmailLink; 80 100 101 /** Link para pasta lixeira. */ 81 102 @FindBy(id = "lINBOX/Trashtree_folders") 82 103 private WebElement trashFolder; 83 104 105 /** Link para limpar lixeira. */ 84 106 @FindBy(id = "empty_trash") 85 107 private WebElement emptyTrashLink; … … 88 110 private WebElement emailsListDiv; 89 111 112 /** Campo contendo total de emails de uma pasta. */ 90 113 @FindBy(id = "tot_m") 91 114 private WebElement totalEmails; … … 94 117 private WebElement emailTab; 95 118 119 /** Checkbox para selecao de todos emails de uma pasta. */ 96 120 @FindBy(id = "chk_box_select_all_messages") 97 121 private WebElement selectAllEmails; 98 122 123 /** Link para acionar o menu Ferramentas. */ 99 124 @FindBy(xpath = "//td[@id='link_tools']/div/span") 100 125 private WebElement toolsMenu; … … 116 141 private WebElement moveEmailButton; 117 142 143 /** Link para encaminhar em email aberto. */ 118 144 @FindBy(xpath = "//div[@id='exmail_main_body']/div[2]/table/tbody/tr[1]/td/table/tbody/tr[1]/td[3]/span[3]") 119 145 private WebElement forwardEmail; 120 146 147 /** Link para responder em email aberto. */ 121 148 @FindBy(xpath = "//div[@id='exmail_main_body']/div[2]/table/tbody/tr[1]/td/table/tbody/tr[1]/td[3]/span[5]") 122 149 private WebElement replyEmail; 123 150 151 /** Link para responder a todos em email aberto. */ 124 152 @FindBy(xpath = "//div[@id='exmail_main_body']/div[2]/table/tbody/tr[1]/td/table/tbody/tr[2]/td/div/span[1]") 125 153 private WebElement replyAllEmail; 126 154 155 /** Link para responder sem historico em email aberto. */ 127 156 @FindBy(xpath = "//div[@id='exmail_main_body']/div[2]/table/tbody/tr[1]/td/table/tbody/tr[2]/td/div/span[2]") 128 157 private WebElement replyEmailWithoutHistory; 129 158 159 /** Link para responder a todos sem historico em email aberto. */ 130 160 @FindBy(xpath = "//div[@id='exmail_main_body']/div[2]/table/tbody/tr[1]/td/table/tbody/tr[2]/td/div/span[3]") 131 161 private WebElement replyAllEmailWithoutHistory; 132 162 163 /** Link para editar email na pasta de rascunhos. */ 133 164 @FindBy(xpath = "//div[@id='exmail_main_body']/div[2]/table/tbody/tr[1]/td/table/tbody/tr/td[2]/span[2]/span[1]") 134 165 private WebElement editEmail; … … 140 171 private WebElement discardNewEmail; 141 172 173 /** 174 * Esse botao eh no alerta ao fechar uma mensagem nao salva e nao o botao 175 * salvar para rascunhos. 176 */ 142 177 @FindBy(xpath = "//div[@id='lertContainer']/div[@id='lertWindow']/div[@id='lertButtons']/a[3]") 143 /** Esse botao eh no alerta ao fechar uma mensagem nao salva e nao o botao salvar para rascunhos. */144 178 private WebElement saveNewEmail; 179 180 /** Nome da pasta "Caixa de Entrada". */ 181 public static final String INBOX_FOLDER = "lINBOXtree_folders"; 182 183 /** Nome da pasta "Enviados". */ 184 public static final String SENT_FOLDER = "lINBOX/Senttree_folders"; 145 185 146 186 /** … … 151 191 } 152 192 193 /** 194 * Cria um novo email. 195 */ 153 196 public void createNewEmail() { 154 197 this.newEmail.click(); … … 156 199 } 157 200 201 /** 202 * Cancela criacao de novo email. 203 */ 158 204 public void cancelNewEmail() { 159 205 this.cancelNewEmail.click(); 160 206 } 161 207 208 /** 209 * Descarta criacao de novo email. 210 */ 162 211 public void discardNewEmail() { 163 212 this.discardNewEmail.click(); 164 213 } 165 214 215 /** 216 * Salva email na pasta rascunhos. 217 */ 166 218 public void saveNewEmail() { 167 219 this.saveNewEmail.click(); 168 220 } 169 221 222 /** 223 * Preenche campo assunto. 224 * 225 * @param subject 226 * Assunto a ser preenchido. 227 */ 170 228 public void setSubject(String subject) { 171 229 this.subject.sendKeys(subject != null ? subject : ""); 172 230 } 173 231 232 /** 233 * Preenche corpo (texto) do email. 234 * 235 * @param body 236 * Texto a ser preenchido. 237 */ 174 238 public void setBody(String body) { 175 239 // Foi o unico jeito que consegui pegar o richtexteditor... 176 240 if (body != null) { 241 // Troca CR&|LF por <br> 242 body = body.replaceAll("(\r\n|\r|\n|\n\r)", "<br>"); 177 243 ((JavascriptExecutor) driver) 178 244 .executeScript("document.getElementById('body_1').contentWindow.document.body.innerHTML='" … … 195 261 public String readEmail(String subject) { 196 262 // waitForElementByXpath("//div[@id='exmail_main_body']/table[1]/tbody[@id='border_tbody']/tr[1]/td[2]/table/tbody/tr/td[1]"); 197 String id = findEmailIdBySu ject(subject);263 String id = findEmailIdBySubject(subject); 198 264 id = id.substring(id.lastIndexOf("_") + 1); 199 265 clickElement(By.id("td_who_" + id)); … … 302 368 public void openFolder(String folder) { 303 369 clickElement(By.id(folder)); 370 // Espera pelo "Carregando..." aparecer. 371 waitForElement(By.id("divProgressBar")); 304 372 waitForElement(By.id("divScrollMain_0")); 373 // Espera pelo "Carregando..." desaparecer. 374 isNotDisplayed(this 375 .waitFindElement(By.id("divProgressBar"), 5000, 1000)); 305 376 waitForElement(By 306 377 .xpath("//div[@id='divScrollMain_0']/table[@id='table_box']/tbody[@id='tbody_box']/tr[1]/td[1]/input[1]")); … … 318 389 } 319 390 391 /** 392 * Filtra somente as mensagens importantes. 393 */ 320 394 public void setImportantFilter() { 321 395 this.importantFilter.click(); … … 337 411 } 338 412 413 /** 414 * Move email para um pasta no servidor. 415 * 416 * @param folderName 417 * Nome da pasta pre-existente no servidor. 418 */ 339 419 public void moveEmail(String folderName) { 340 420 this.moveEmailLink.click(); … … 343 423 } 344 424 425 /** 426 * Edita nome de pasta. 427 */ 345 428 public void editFolder() { 346 429 this.toolsMenu.click(); … … 350 433 } 351 434 435 /** 436 * Cria nova pasta. 437 * 438 * @param folderName 439 * Nome da pasta a ser criada. 440 */ 352 441 public void createNewFolder(String folderName) { 353 442 this.editFolder(); … … 359 448 } 360 449 450 /** 451 * Exclui pasta. 452 * 453 * @param folderName 454 * Nome da pasta a ser excluida. 455 */ 361 456 public void deleteFolder(String folderName) { 362 457 this.editFolder(); … … 377 472 } 378 473 474 /** 475 * Marca email como importante apos ler. 476 */ 379 477 public void setImportantFlag() { 380 478 this.waitForElement(By … … 383 481 } 384 482 483 /** 484 * Marca email como normal apos ler. 485 */ 385 486 public void setNormalFlag() { 386 487 this.waitForElement(By … … 389 490 } 390 491 492 /** 493 * Marca email como nao lido apos ler. 494 */ 391 495 public void setNotReadFlag() { 392 496 this.waitForElement(By … … 419 523 } 420 524 525 /** 526 * Seleciona todos emails da pasta corrente. 527 */ 421 528 public void selectAllEmails() { 422 529 this.selectAllEmails.click(); … … 456 563 } 457 564 565 /** 566 * Remove anexo do email sendo composto. 567 */ 568 public void removeAttachment() { 569 this.removeAttachmentLink.click(); 570 } 571 458 572 public void addAttachment2(String attachment) { 459 573 this.attachmentLink.click(); … … 476 590 477 591 /** 478 * @param checkAlert479 */ 480 public void closeMail(boolean checkAlert) {592 * @param discardEmail 593 */ 594 public void closeMail(boolean discardEmail) { 481 595 482 596 // Na versao Serpro: … … 489 603 super.clickElement(By.xpath("//td[@id='border_id_1']//img")); 490 604 491 if (checkAlert) { 492 Alert closeAlert = driver.switchTo().alert(); 493 closeAlert.accept(); 605 // if (checkAlert) { 606 // Alert closeAlert = driver.switchTo().alert(); 607 // closeAlert.accept(); 608 // } 609 610 // Clica em descartar. 611 if (discardEmail) { 612 super.clickElement(By 613 .xpath("//div[@id='lertWindow']/div[@id='lertButtons']/a[2]")); 494 614 } 495 615 } 496 616 497 public void closeMail(String id ) {617 public void closeMail(String id, boolean discardEmail) { 498 618 super.clickElement(By.xpath("//td[@id='border_id_" + id + "']//img")); 499 } 500 619 // Clica em cancelar 620 if (discardEmail) { 621 super.clickElement(By 622 .xpath("//div[@id='lertWindow']/div[@id='lertButtons']/a[2]")); 623 } 624 } 625 626 /** 627 * Envia email. 628 * 629 * @param id 630 * Id do email a ser enviado. 631 */ 501 632 public void sendMail(String id) { 502 633 super.findAndClickElement("send_button_" + id); … … 525 656 * @param select 526 657 * Se email encontrado, deseja seleciona-lo? 527 * @return "id" do email .658 * @return "id" do email se encontrar, <code>null</code> se nao encontrar. 528 659 */ 529 660 public String findEmailIdBySuject(String subject, boolean select) { 661 System.out.println("searching for --------->" + subject); 530 662 String html = driver.getPageSource(); 531 String part1 = StringUtils.substringBefore(html, subject); 532 int start = StringUtils.lastIndexOf(part1, "id=\"") + 4; 533 int last = StringUtils.indexOf(part1, "\"", start); 534 String id = StringUtils.substring(part1, start, last); 535 536 if (select) { 537 // Marca checkbox correspondente ao id da mensagem. 538 clickElement(By.id("check_box" + id.substring(1))); 663 // System.out.println(html.indexOf(subject)); 664 // System.out.println(html); 665 if (html.indexOf(subject) >= 0) { 666 String part1 = StringUtils.substringBefore(html, subject); 667 int start = StringUtils.lastIndexOf(part1, "id=\"") + 4; 668 int last = StringUtils.indexOf(part1, "\"", start); 669 String id = StringUtils.substring(part1, start, last); 670 System.out.println("******************"); 671 System.out.println("******************"); 672 System.out.println("******************"); 673 System.out.println("******************"); 674 System.out.println("******************"); 675 System.out.println("******************"); 676 System.out.println(id); 677 if (select) { 678 // Marca checkbox correspondente ao id da mensagem. 679 clickElement(By.id("check_box" + id.substring(1))); 680 } 681 return id; 539 682 } 540 return id;683 return null; 541 684 } 542 685 … … 570 713 } 571 714 572 public String findEmailIdBySuject(String subject) { 715 /** 716 * Procura email baseado no assunto na pasta corrente. 717 * 718 * @param subject 719 * Assunto a ser pesquisado. 720 * @return Id do email encontrado. 721 */ 722 public String findEmailIdBySubject(String subject) { 723 return findEmailIdBySuject(subject, false); 724 } 725 726 /** 727 * Procura email baseado no assunto em uma pasta especifica. 728 * 729 * @param folder 730 * Pasta de pesquisa. 731 * @param subject 732 * Assunto a ser pesquisado. 733 * @return Id do email encontrado. 734 */ 735 public String findEmailIdBySubject(String folder, String subject) { 736 this.openFolder(folder); 573 737 return findEmailIdBySuject(subject, false); 574 738 } … … 619 783 } 620 784 785 /** 786 * @param id 787 * Id do email. 788 * @return Texto do email. 789 */ 621 790 public Object getBody(String id) { 622 791 waitForElement(By.id("body_" + id));
Note: See TracChangeset
for help on using the changeset viewer.