Changeset 3708 for devel/testlink/automation2.0/src/test/java/br/gov/serpro/expresso/cte/pages/email/MailPage.java
- Timestamp:
- 01/19/11 14:25:51 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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.