Changeset 3708 for devel/testlink/automation2.0/src/test/java/br
- Timestamp:
- 01/19/11 14:25:51 (13 years ago)
- Location:
- devel/testlink/automation2.0/src/test/java/br/gov/serpro/expresso/cte
- Files:
-
- 19 added
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
devel/testlink/automation2.0/src/test/java/br/gov/serpro/expresso/cte/common/BaseTestCase.java
r3663 r3708 34 34 } 35 35 36 /** 37 * TODO Rever esse metodo. Foi o unico jeito que consegui fazer pegar o 38 * numero total de mensagens importantes. O metodo apenas aguarda 5 segundos 39 * antes de continuar a execucao. 40 * 41 * @throws Exception 42 * 43 * @see br.gov.serpro.cte.email.listar.ListarEmailsImportantesTestCase 44 */ 45 public void dummyWait() throws Exception { 46 dummyWait(5); 47 } 48 49 /** 50 * @param seconds 51 * @throws Exception 52 */ 53 public void dummyWait(int seconds) throws Exception { 54 for (int second = 0;; second++) { 55 if (second >= seconds) { 56 System.out.println("timeout"); 57 return; 58 } 59 Thread.sleep(1000); 60 } 61 62 } 63 36 64 } -
devel/testlink/automation2.0/src/test/java/br/gov/serpro/expresso/cte/common/Constants.java
r3663 r3708 8 8 public static final String EMAIL_TESTE_1 = Config.getInstance().getValor( 9 9 "email.teste.1"); 10 public static final String EMAIL_TESTE_N_DESTINATARIOS = Config 11 .getInstance().getValor("email.teste.multiplos"); 12 public static final String EMAIL_INVALIDO = Config.getInstance().getValor( 13 "email.invalido"); 10 14 public static final String EMAIL_ASSUNTO = Config.getInstance().getValor( 11 15 "assunto"); 16 public static final String EMAIL_ASSUNTO_COPIA_OCULTA = Config 17 .getInstance().getValor("assunto.somente.copia.oculta"); 18 public static final String EMAIL_ASSUNTO_COPIA = Config.getInstance() 19 .getValor("assunto.somente.copia"); 20 public static final String EMAIL_ASSUNTO_MULTIPLOS_ANEXOS = Config 21 .getInstance().getValor("assunto.multiplos.anexos"); 22 public static final String EMAIL_ASSUNTO_MULTIPLOS_DESTINATARIOS = Config 23 .getInstance().getValor("assunto.multiplos.destinatarios"); 12 24 public static final String EMAIL_TEXTO = Config.getInstance().getValor( 13 25 "texto.email"); 14 public static final String EMAIL_ENVIADO = Config.getInstance() 26 public static final String EMAIL_TEXTO_COPIA_OCULTA = Config.getInstance() 27 .getValor("texto.email.copia.oculta"); 28 public static final String EMAIL_TEXTO_COPIA = Config.getInstance() 29 .getValor("texto.email.copia"); 30 public static final String EMAIL_TEXTO_MULTIPLOS_ANEXOS = Config 31 .getInstance().getValor("texto.email.multiplos.anexos"); 32 public static final String EMAIL_TEXTO_MULTIPLOS_DESTINATARIOS = Config 33 .getInstance().getValor("texto.email.multiplos.destinatarios"); 34 35 public static final String MSG_EMAIL_ENVIADO = Config.getInstance() 15 36 .getMensagem("email.enviado"); 16 17 public static final String EMAIL_APAGAR_MENSAGEM = Config.getInstance() 37 public static final String MSG_EMAIL_APAGAR_MENSAGEM = Config.getInstance() 18 38 .getMensagem("apagar.uma.mensagem"); 19 public static final String EMAIL_LIMPAR_LIXEIRA = Config.getInstance() 39 public static final String MSG_EMAIL_APAGAR_MENSAGENS = Config 40 .getInstance().getMensagem("apagar.mensagem"); 41 public static final String MSG_EMAIL_LIMPAR_LIXEIRA = Config.getInstance() 20 42 .getMensagem("limpar.lixeira"); 43 public static final String MSG_EMAIL_DESTINATARIO_INVALIDO = Config 44 .getInstance().getMensagem("destinatario.invalido"); 45 public static final String MSG_EMAIL_IMPORTANTE = Config.getInstance() 46 .getMensagem("marcar.importante"); 47 public static final String MSG_EMAIL_NORMAL = Config.getInstance() 48 .getMensagem("marcar.normal"); 49 public static final String MSG_EMAIL_NAO_LIDO = Config.getInstance() 50 .getMensagem("marcar.nao.lido"); 21 51 22 52 } -
devel/testlink/automation2.0/src/test/java/br/gov/serpro/expresso/cte/email/compor/EnviarEmailConfirmacaoLeituraTestCase.java
r3663 r3708 17 17 mp.composeEmail("luiz-fernando.estivalet@cte.serpro.gov.br", 18 18 "assunto conf leitura", "texto conf leitura"); 19 mp. setReturnReceipt();19 mp.checkReturnReceipt(); 20 20 mp.sendMail(); 21 21 mp.assertMessage("Sua mensagem foi enviada e salva."); -
devel/testlink/automation2.0/src/test/java/br/gov/serpro/expresso/cte/email/compor/EnviarEmailImportanteTestCase.java
r3663 r3708 16 16 mp.composeEmail("luiz-fernando.estivalet@cte.serpro.gov.br", 17 17 "assunto importante", "texto importante"); 18 mp. setImportantFlag();18 mp.checkImportantFlag(); 19 19 mp.sendMail(); 20 20 mp.assertMessage("Sua mensagem foi enviada e salva."); -
devel/testlink/automation2.0/src/test/java/br/gov/serpro/expresso/cte/email/compor/EnviarEmailTestCase.java
r3663 r3708 17 17 mp.composeEmail(EMAIL_TESTE_1, EMAIL_ASSUNTO, EMAIL_TEXTO); 18 18 mp.sendMail(); 19 mp.assertMessage( EMAIL_ENVIADO);19 mp.assertMessage(MSG_EMAIL_ENVIADO); 20 20 } 21 21 } -
devel/testlink/automation2.0/src/test/java/br/gov/serpro/expresso/cte/email/listar/ApagarEmailSelecionadoTestCase.java
r3663 r3708 17 17 mp.findEmailIdBySuject(EMAIL_ASSUNTO, true); 18 18 mp.deleteEmail(); 19 mp.assertMessage( EMAIL_APAGAR_MENSAGEM);19 mp.assertMessage(MSG_EMAIL_APAGAR_MENSAGEM); 20 20 } 21 21 -
devel/testlink/automation2.0/src/test/java/br/gov/serpro/expresso/cte/email/listar/LimparLixeiraTestCase.java
r3663 r3708 19 19 // Alerta de confirmacao de limpeza da lixeira. 20 20 Alert confirm = driver.switchTo().alert(); 21 assert EMAIL_LIMPAR_LIXEIRA.equals(confirm.getText());21 assert MSG_EMAIL_LIMPAR_LIXEIRA.equals(confirm.getText()); 22 22 confirm.accept(); 23 23 -
devel/testlink/automation2.0/src/test/java/br/gov/serpro/expresso/cte/pages/common/Page.java
r3663 r3708 43 43 44 44 /** 45 * Aguarda elemento aparecer e depois clica. 46 * 47 * @param id 48 * Id do elemento a ser clicado. 49 */ 50 public void findAndClickElement(String id) { 51 this.waitForElementById(id); 52 this.clickElement(id); 53 } 54 55 /** 45 56 * Aguarda por um elemento. 46 57 * … … 76 87 * @param e 77 88 */ 78 p rivate voidisDisplayed(RenderedWebElement e) {89 public boolean isDisplayed(RenderedWebElement e) { 79 90 System.out.println("starting tentatives"); 80 91 // Up to 10 times … … 83 94 // Check whether our element is visible yet 84 95 if (e.isDisplayed()) { 85 return ;96 return true; 86 97 } 87 98 … … 92 103 } 93 104 } 94 105 return false; 95 106 } 96 107 -
devel/testlink/automation2.0/src/test/java/br/gov/serpro/expresso/cte/pages/email/MailPage.java
r3663 r3708 2 2 3 3 import org.apache.commons.lang.StringUtils; 4 import org.openqa.selenium.Alert; 5 import org.openqa.selenium.By; 4 6 import org.openqa.selenium.JavascriptExecutor; 7 import org.openqa.selenium.RenderedWebElement; 5 8 import org.openqa.selenium.WebDriver; 6 9 import org.openqa.selenium.WebElement; … … 30 33 31 34 @FindBy(id = "important_message_1") 35 /** Flag de importante no momento de compor um email. */ 32 36 private WebElement important; 37 38 @FindBy(xpath = "//div[@id='exmail_main_body']/div[2]/table/tbody/tr[1]/td/table/tbody/tr[1]/td[2]/span[3]") 39 /** Flag de importante de um email aberto. */ 40 private WebElement importantFlag; 41 42 @FindBy(id = "span_flag_FLAGGED") 43 /** Filtra emails importantes. */ 44 private WebElement importantFilter; 45 46 @FindBy(xpath = "//div[@id='exmail_main_body']/div[2]/table/tbody/tr[1]/td/table/tbody/tr[1]/td[2]/span[3]") 47 private WebElement normalFlag; 48 49 @FindBy(xpath = "//div[@id='exmail_main_body']/div[2]/table/tbody/tr[1]/td/table/tbody/tr[1]/td[2]/span[2]") 50 private WebElement notReadFlag; 33 51 34 52 @FindBy(id = "return_receipt_1") … … 50 68 private WebElement saveEmail; 51 69 52 @FindBy( xpath = "//div[@id='div_message_scroll_1']/form/table/tbody/tr[10]/td[2]/a")70 @FindBy(linkText = "Anexos: adicionar+") 53 71 private WebElement attachmentLink; 54 72 … … 56 74 private WebElement attachment; 57 75 76 @FindBy(id = "inputFile_1_2") 77 private WebElement attachment2; 78 58 79 @FindBy(xpath = "//div[@id='footer_menu']/table[@id='footer_box']/tbody/tr[@id='table_message']/td[@id='span_options']/span[1]/span") 59 80 private WebElement deleteEmailLink; … … 71 92 private WebElement totalEmails; 72 93 94 @FindBy(xpath = "//div[@id='exmail_main_body']/table[1]/tbody[@id='border_tbody']/tr[1]/td[2]/table/tbody/tr/td[1]") 95 private WebElement emailTab; 96 97 @FindBy(id = "chk_box_select_all_messages") 98 private WebElement selectAllEmails; 99 100 @FindBy(xpath = "//td[@id='link_tools']/div/span") 101 private WebElement toolsMenu; 102 103 @FindBy(xpath = "//div[@id='menu_tools']/table/tbody/tr[4]/td") 104 private WebElement editFolder; 105 106 @FindBy(xpath = "//input[@value='Nova Pasta']") 107 private WebElement createNewFolder; 108 109 @FindBy(xpath = "//input[@value='Excluir pasta']") 110 private WebElement deleteFolder; 111 112 @FindBy(xpath = "//span[@onclick='wfolders.makeWindow(\"\",\"move_to\")']") 113 /** Opcao de mover do rodape. */ 114 private WebElement moveEmailLink; 115 116 @FindBy(id = "dJSWin_wfolders_bok") 117 private WebElement moveEmailButton; 118 119 @FindBy(xpath = "//div[@id='exmail_main_body']/div[2]/table/tbody/tr[1]/td/table/tbody/tr[1]/td[3]/span[3]") 120 private WebElement forwardEmail; 121 73 122 /** 74 123 * @param driver … … 78 127 } 79 128 80 /** 81 * @param to 82 * @param subject 83 * @param body 84 */ 85 public void composeEmail(String to, String subject, String body) { 129 public void createNewEmail() { 86 130 this.newEmail.click(); 87 131 waitForElementById("to_1"); 88 this.to.sendKeys(to); 132 } 133 134 public void setSubject(String subject) { 89 135 this.subject.sendKeys(subject != null ? subject : ""); 90 136 } 137 138 public void setBody(String body) { 91 139 // Foi o unico jeito que consegui pegar o richtexteditor... 92 140 if (body != null) { … … 98 146 99 147 /** 148 * @param to 149 * @param subject 150 * @param body 151 */ 152 public void composeEmail(String to, String subject, String body) { 153 this.createNewEmail(); 154 this.to.sendKeys(to); 155 this.setSubject(subject); 156 this.setBody(body); 157 } 158 159 public String readEmail(String subject) { 160 String id = findEmailIdBySuject(subject); 161 clickElement(id); 162 return id.substring(id.lastIndexOf("_") + 1); 163 // waitForElementByXpath("//div[@id='exmail_main_body']/table[1]/tbody[@id='border_tbody']/tr[1]/td[2]/table/tbody/tr/td[1]"); 164 } 165 166 /** 167 * Encaminha uma mensagem. 168 * 169 * @param id 170 * Id da mensagem a ser encaminhada 171 * @param to 172 * Destinatario 173 */ 174 public void forwardEmail(String id, String to) { 175 super.waitForElementByXpath("//div[@id='exmail_main_body']/div[2]/table/tbody/tr[1]/td/table/tbody/tr[1]/td[3]/span[3]"); 176 this.forwardEmail.click(); 177 super.waitForElementById("to_" + id); 178 driver.findElement(By.id("to_" + id)).sendKeys(to); 179 driver.findElement(By.id("send_button_" + id)).click(); 180 } 181 182 /** 100 183 * Abre uma pasta de email especifica. 101 184 * … … 119 202 } 120 203 204 public void setImportantFilter() { 205 this.importantFilter.click(); 206 } 207 121 208 /** 122 209 * Limpa a lixeira. … … 134 221 } 135 222 223 public void moveEmail(String folderName) { 224 this.moveEmailLink.click(); 225 super.findAndClickElement("lINBOX/" + folderName + "wfolders_tree"); 226 this.moveEmailButton.click(); 227 } 228 229 public void editFolder() { 230 this.toolsMenu.click(); 231 this.waitForElementByXpath("//div[@id='menu_tools']/table/tbody/tr[4]/td"); 232 this.editFolder.click(); 233 } 234 235 public void createNewFolder(String folderName) { 236 this.editFolder(); 237 this.createNewFolder.click(); 238 Alert newFolder = driver.switchTo().alert(); 239 assert "Insira o nome da nova pasta: ".equals(newFolder.getText()); 240 newFolder.sendKeys(folderName); 241 newFolder.accept(); 242 } 243 244 public void deleteFolder(String folderName) { 245 this.editFolder(); 246 this.driver.findElement(By.id("lINBOX/" + folderName + "folders_tree")) 247 .click(); 248 this.deleteFolder.click(); 249 Alert confirm = driver.switchTo().alert(); 250 assert ("Você gostaria de excluir a pasta: " + folderName + "?") 251 .equals(confirm.getText()); 252 confirm.accept(); 253 } 254 136 255 /** 137 256 * Marca email sendo composto como importante. 138 257 */ 258 public void checkImportantFlag() { 259 this.important.click(); 260 } 261 139 262 public void setImportantFlag() { 140 this.important.click(); 263 this.waitForElementByXpath("//div[@id='exmail_main_body']/div[2]/table/tbody/tr[1]/td/table/tbody/tr[1]/td[2]/span[3]"); 264 this.importantFlag.click(); 265 } 266 267 public void setNormalFlag() { 268 this.waitForElementByXpath("//div[@id='exmail_main_body']/div[2]/table/tbody/tr[1]/td/table/tbody/tr[1]/td[2]/span[3]"); 269 this.normalFlag.click(); 270 } 271 272 public void setNotReadFlag() { 273 this.waitForElementByXpath("//div[@id='exmail_main_body']/div[2]/table/tbody/tr[1]/td/table/tbody/tr[1]/td[2]/span[2]"); 274 this.notReadFlag.click(); 141 275 } 142 276 … … 144 278 * Marca solicitacao de confirmacao de leitura do email sendo composto. 145 279 */ 146 public void setReturnReceipt() {280 public void checkReturnReceipt() { 147 281 this.returnReceipt.click(); 148 282 } … … 163 297 public void deleteEmail() { 164 298 this.deleteEmailLink.click(); 299 } 300 301 public void selectAllEmails() { 302 this.selectAllEmails.click(); 165 303 } 166 304 … … 196 334 this.attachmentLink.click(); 197 335 this.attachment.sendKeys(attachment); 336 } 337 338 public void addAttachment2(String attachment) { 339 this.attachmentLink.click(); 340 this.attachment2.sendKeys(attachment); 198 341 } 199 342 … … 244 387 245 388 /** 389 * @return Ids de todos os emails da pasta selecionada. 390 */ 391 public String[] getEmailIds() { 392 String[] ids = new String[this.getTotalEmails()]; 393 for (int i = 1; i <= this.getTotalEmails(); i++) { 394 String id = driver 395 .findElement( 396 By.xpath("//div[@id='divScrollMain_0']/table[@id='table_box']/tbody[@id='tbody_box']/tr[" 397 + i + "]/td[1]/input[1]")).getAttribute( 398 "id"); 399 ids[i - 1] = id.substring(id.lastIndexOf("_") + 1); 400 } 401 return ids; 402 } 403 404 /** 405 * @param emailId 406 * Id do email. 407 * @return <code>true</code> se email importante, <code>false</code> caso 408 * contrario. 409 */ 410 public boolean isImportant(String emailId) { 411 return super 412 .isDisplayed((RenderedWebElement) driver.findElement(By 413 .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='" 414 + emailId + "']/td[5]/img"))); 415 } 416 417 public String findEmailIdBySuject(String subject) { 418 return findEmailIdBySuject(subject, false); 419 } 420 421 /** 246 422 * Verifica se mensagem informada corresponde ao exibido pelo Expresso na 247 423 * div onde sao exibidas mensagens ao usuario.
Note: See TracChangeset
for help on using the changeset viewer.