Changeset 4962 for devel/testlink/automation2.0/src/test
- Timestamp:
- 08/19/11 16:38:24 (13 years ago)
- Location:
- devel/testlink/automation2.0/src/test
- Files:
-
- 26 added
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
devel/testlink/automation2.0/src/test/java/org/expressolivre/cte/common/BaseCalendarTestCase.java
r4917 r4962 1 1 package org.expressolivre.cte.common; 2 2 3 import java.util.Calendar; 4 5 import org.expressolivre.cte.pages.calendar.AgendaPermissionPage; 3 6 import org.expressolivre.cte.pages.calendar.AppointmentCategoryPage; 4 7 import org.expressolivre.cte.pages.calendar.AppointmentPage; … … 77 80 return PageFactory.initElements(driver, AppointmentCategoryPage.class); 78 81 } 82 83 /** 84 * @return 85 */ 86 public AgendaPermissionPage openAgendaPermissionPage() { 87 driver.get(URL 88 + "/index.php?menuaction=preferences.uiaclprefs.index&acl_app=calendar"); 89 return PageFactory.initElements(driver, AgendaPermissionPage.class); 90 } 91 92 /** 93 * @param cal 94 * @return Nome do mes concatenado com o nome do ano. Exemplo: Agosto 2011 95 */ 96 private String getMonthYearName(Calendar cal) { 97 String[] monthName = { "Janeiro", "Fevereiro", "Março", "Abril", 98 "Maio", "Junho", "Julho", "Agosto", "Setembro", "Outubro", 99 "Novembro", "Dezembro" }; 100 101 String month = monthName[cal.get(Calendar.MONTH)]; 102 Integer year = cal.get(Calendar.YEAR); 103 104 return month + " " + year; 105 106 } 107 108 /** 109 * @return O nome por extenso do mes concatenado com o ano corrente. 110 */ 111 public String getCurrentMonthYearName() { 112 return this.getMonthYearName(Calendar.getInstance()); 113 } 114 115 /** 116 * @return O nome por extenso do mes anterior concatenado com o ano; 117 */ 118 public String getPreviousMonthYearName() { 119 Calendar cal = Calendar.getInstance(); 120 cal.add(Calendar.MONTH, -1); 121 122 return this.getMonthYearName(cal); 123 } 124 125 public String getNextMonthYearName(Calendar cal) { 126 cal.add(Calendar.MONTH, 1); 127 128 return this.getMonthYearName(cal); 129 } 130 131 /** 132 * @return 133 */ 134 public String getNextMonthYearName() { 135 return getNextMonthYearName(Calendar.getInstance()); 136 } 137 79 138 } -
devel/testlink/automation2.0/src/test/java/org/expressolivre/cte/common/BaseTestCase.java
r4917 r4962 13 13 import org.testng.annotations.BeforeClass; 14 14 import org.testng.annotations.BeforeSuite; 15 import org.testng.annotations.Optional; 16 import org.testng.annotations.Parameters; 15 17 16 18 /** … … 51 53 * Antes de cada classe de teste o login na aplicacao eh realizado. 52 54 */ 55 @Parameters({ "usuario" }) 53 56 @BeforeClass 54 public void login( ) {57 public void login(@Optional("user") String usuario) { 55 58 LoginPage page = PageFactory.initElements(driver, LoginPage.class); 56 page.login(USER, PASS); 59 // Se nao foi informado um usuario para logar, usar o usuario padrao. 60 if ("user".equals(usuario)) { 61 page.login(USER, PASS); 62 } else { 63 // Caso contrario busca o login e senha do usuario passado por 64 // parametro. 65 String user = Config.getInstance().getConfig(usuario); 66 String passwd = Config.getInstance().getConfig(usuario + ".passwd"); 67 page.login(user, passwd); 68 } 57 69 } 58 70 -
devel/testlink/automation2.0/src/test/java/org/expressolivre/cte/pages/calendar/AppointmentPage.java
r4917 r4962 70 70 private WebElement priority; 71 71 72 @FindBy(id = "combo_org") 73 private WebElement organization; 74 75 @FindBy(id = "cal_input_searchUser") 76 private WebElement searchUser; 77 78 @FindBy(id = "user_list_in") 79 private WebElement userList; 80 81 @FindBy(xpath = "//table[@id='editFormTable']/tbody/tr[12]/td[2]/table[1]/tbody/tr[2]/td[3]/button[1]") 82 private WebElement addUser; 83 72 84 @FindBy(id = "usuarioParticipa") 73 85 private WebElement includeUser; … … 149 161 */ 150 162 public void setCategories(String categories) { 151 this.categories.sendKeys(categories); 163 super.setComboValue(this.categories, categories); 164 } 165 166 /** 167 * @param categories 168 */ 169 public void setCategories(String[] categories) { 170 for (String cat : categories) { 171 super.setComboValue(this.categories, cat); 172 } 152 173 } 153 174 … … 330 351 return PageFactory.initElements(driver, AppointmentConflictPage.class); 331 352 } 353 354 /** 355 * Adiciona um anexo ao compromisso. 356 * 357 * @param num 358 * Numero sequencial, 1 para o primeiro anexo, 2 para o segundo e 359 * assim sucessivamente. 360 * @param fileName 361 * Caminho completo para o arquivo anexo. 362 */ 363 public void addAttachment(Integer num, String fileName) { 364 driver.findElement( 365 By.xpath("//table[@id='editFormTable']/tbody/tr[21]/td[2]/a")) 366 .click(); 367 WebElement attachment = driver.findElement(By.id("inputFile_" + num)); 368 attachment.sendKeys(fileName); 369 } 370 371 /** 372 * Procura por um usuario para adicionar ao compromisso. 373 * 374 * @param name 375 * Nome do usuario a procurar. 376 */ 377 public void searchUser(String name) { 378 this.searchUser.clear(); 379 this.searchUser.sendKeys(name); 380 // Espera pelo "Carregando..." aparecer. 381 waitForElement(By.id("divProgressBar")); 382 // Espera pelo "Carregando..." desaparecer. 383 isNotDisplayed(this 384 .waitFindElement(By.id("divProgressBar"), 5000, 1000)); 385 386 } 387 388 /** 389 * Seleciona o nome do usuario na lista de usuarios retornados pela 390 * pesquisa. 391 * 392 * @param name 393 * Nome do usuario para selecionar. 394 */ 395 public void selectUser(String name) { 396 super.setComboValue(this.userList, name); 397 } 398 399 /** 400 * Adiciona usuario ao compromisso. 401 */ 402 public void addUser() { 403 this.addUser.click(); 404 } 405 332 406 } -
devel/testlink/automation2.0/src/test/java/org/expressolivre/cte/pages/calendar/AppointmentViewPage.java
r4917 r4962 1 1 package org.expressolivre.cte.pages.calendar; 2 3 import java.util.List; 2 4 3 5 import org.expressolivre.cte.pages.common.Page; 4 6 import org.openqa.selenium.Alert; 7 import org.openqa.selenium.By; 5 8 import org.openqa.selenium.WebDriver; 6 9 import org.openqa.selenium.WebElement; … … 16 19 */ 17 20 public class AppointmentViewPage extends Page { 21 22 public static final String DESCRIPTION = "Descrição:"; 23 public static final String LOCAL = "Localização:"; 24 public static final String START = "InÃcio Data/Hora:"; 25 public static final String END = "Data/Hora de término:"; 26 public static final String PRIORITY = "Prioridade:"; 27 public static final String ACCESS = "Acesso:"; 28 public static final String PARTICIPANTS = "Participantes:"; 29 public static final String CREATED_BY = "Criado por:"; 30 public static final String UPDATED = "Atualizado:"; 31 public static final String LAST_UPDATED_BY = "Ãltima alteração realizada por:"; 32 public static final String ATTACHMENTS = "Anexos:"; 18 33 19 34 /** Botao para editar um compromisso. */ … … 94 109 return title.getText(); 95 110 } 111 112 /** 113 * Percorre a tabela em busca da informacao desejada. 114 * 115 * @param label 116 * Informa o label procurado. Ex: "Descrição". 117 * @return Retorna o valor correspondente ao label encontrado. Se label nao 118 * for encontrado retorna <code>null</code>. 119 */ 120 public String getAppointmentInfo(String label) { 121 List<WebElement> rows = driver.findElements(By 122 .xpath("//table[@id='calendar_view_event']/tbody/tr")); 123 // Comeca a partir da linha 2 pois a linha eh sempre o titulo do 124 // compromisso. 125 for (int i = 2; i <= rows.size(); i++) { 126 WebElement row = driver.findElement(By 127 .xpath("//table[@id='calendar_view_event']/tbody/tr[" + i 128 + "]/td[1]")); 129 // Se o label for encontrado entao pega o valor encontrado na 130 // segunda coluna da tabela. 131 if (label.equals(row.getText())) { 132 return driver.findElement( 133 By.xpath("//table[@id='calendar_view_event']/tbody/tr[" 134 + i + "]/td[2]")).getText(); 135 } 136 } 137 return null; 138 } 96 139 } -
devel/testlink/automation2.0/src/test/java/org/expressolivre/cte/pages/calendar/CalendarPage.java
r4917 r4962 36 36 37 37 /** Combo para selecionar mes. */ 38 @FindBy( name = "date")38 @FindBy(xpath = "//table[@id='tableDivAppbox']/tbody/tr/td/font/table/tbody/tr/td[2]/font[1]/form/select") 39 39 private WebElement date; 40 40 … … 60 60 .xpath("//table[@id='calendar_head_table']/tbody/tr/td[2]/a/img")); 61 61 return PageFactory.initElements(driver, CalendarTodayViewPage.class); 62 } 63 64 /** 65 * Abre a visao semanal da agenda. 66 * 67 * @return 68 */ 69 public CalendarWeeklyViewPage openWeeklyView() { 70 super.clickElement(By 71 .xpath("//table[@id='calendar_head_table']/tbody/tr/td[3]/a/img")); 72 return PageFactory.initElements(driver, CalendarWeeklyViewPage.class); 73 } 74 75 /** 76 * Abre a visao mensal da agenda. 77 * 78 * @return 79 */ 80 public CalendarMonthlyViewPage openMonthlyView() { 81 super.clickElement(By 82 .xpath("//table[@id='calendar_head_table']/tbody/tr/td[4]/a/img")); 83 return PageFactory.initElements(driver, CalendarMonthlyViewPage.class); 84 } 85 86 /** 87 * Abre a visao anual da agenda. 88 * 89 * @return 90 */ 91 public CalendarYearlyViewPage openYearlyView() { 92 super.clickElement(By 93 .xpath("//table[@id='calendar_head_table']/tbody/tr/td[5]/a/img")); 94 return PageFactory.initElements(driver, CalendarYearlyViewPage.class); 62 95 } 63 96 … … 130 163 } 131 164 165 /** 166 * Seleciona uma categoria para filtragem. 167 * 168 * @param category 169 * Categoria selecionada. 170 */ 171 public void setCategoryFilter(String category) { 172 super.setComboValue(this.category, category); 173 } 174 175 /** 176 * Seleciona um mes para filtragem. 177 * 178 * @param monthYear 179 * Mes selecionado no formato "nome do ano" "ano" (ex: Agosto 180 * 2011) 181 */ 182 public CalendarMonthlyViewPage setMonthFilter(String monthYear) { 183 super.setComboValue(this.date, monthYear); 184 return PageFactory.initElements(driver, CalendarMonthlyViewPage.class); 185 } 186 132 187 } -
devel/testlink/automation2.0/src/test/java/org/expressolivre/cte/pages/common/Page.java
r4917 r4962 53 53 */ 54 54 public void waitForElement(By by) { 55 isDisplayed(this.waitFindElement(by, 5000, 1000));55 isDisplayed(this.waitFindElement(by, 10000, 1000)); 56 56 } 57 57 -
devel/testlink/automation2.0/src/test/java/org/expressolivre/cte/pages/email/MailPage.java
r4902 r4962 2 2 3 3 import org.apache.commons.lang.StringUtils; 4 import org.expressolivre.cte.pages.calendar.AppointmentEmailPage; 4 5 import org.expressolivre.cte.pages.common.Page; 5 6 import org.openqa.selenium.Alert; … … 311 312 312 313 public String readEmail(String subject) { 313 // waitForElementByXpath("//div[@id='exmail_main_body']/table[1]/tbody[@id='border_tbody']/tr[1]/td[2]/table/tbody/tr/td[1]");314 314 String id = findEmailIdBySubject(subject); 315 315 id = id.substring(id.lastIndexOf("_") + 1); … … 317 317 super.waitForElement(By.id("div_message_scroll_" + id + "_r")); 318 318 return id; 319 } 320 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); 319 343 } 320 344 … … 961 985 } 962 986 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 963 1000 public WebElement getReturnReceipt() { 964 1001 return returnReceipt; -
devel/testlink/automation2.0/src/test/resources/config.properties
r4890 r4962 16 16 user=expresso-admin 17 17 passwd=3xpr3ss0 18 19 user2=teste.agenda 20 user2.passwd=senha123 21 # organização do usuário 22 user2.ou=corp 23 user2.setor=caixascorp 18 24 19 25 #url=https://10.200.113.112/ … … 37 43 # Email que será utilizado para receber as mensagens enviadas pelos casos de teste de cópia, cópia oculta 38 44 config.email.teste.2=luiz-fernando.estivalet@serpro.gov.br 45 config.email.teste.agenda=teste.agenda@serpro.gov.br 39 46 config.email.remetente=Luiz Fernando Estivalet 40 47 # Email que será utilizado para receber as mensagens enviadas pelos casos de teste de para envio de múltiplos destinatários
Note: See TracChangeset
for help on using the changeset viewer.