1 | package org.expressolivre.cte.pages.calendar; |
---|
2 | |
---|
3 | import java.util.List; |
---|
4 | |
---|
5 | import org.expressolivre.cte.pages.common.Page; |
---|
6 | import org.openqa.selenium.By; |
---|
7 | import org.openqa.selenium.WebDriver; |
---|
8 | import org.openqa.selenium.WebElement; |
---|
9 | import org.openqa.selenium.support.FindBy; |
---|
10 | import org.openqa.selenium.support.PageFactory; |
---|
11 | |
---|
12 | /** |
---|
13 | * @author L.F.Estivalet (Serpro) |
---|
14 | * |
---|
15 | * Created on Feb 8, 2011 at 9:19:20 AM |
---|
16 | * |
---|
17 | */ |
---|
18 | public class AppointmentPage extends Page { |
---|
19 | |
---|
20 | /** Mensagens de validacao do formulario. */ |
---|
21 | @FindBy(id = "formStatus") |
---|
22 | private WebElement formStatus; |
---|
23 | |
---|
24 | /** Tipo do evento. */ |
---|
25 | @FindBy(id = "cal[type]") |
---|
26 | private WebElement type; |
---|
27 | |
---|
28 | /** Titulo do evento. */ |
---|
29 | @FindBy(name = "cal[title]") |
---|
30 | private WebElement title; |
---|
31 | |
---|
32 | /** Descrição completa do evento. */ |
---|
33 | @FindBy(name = "cal[description]") |
---|
34 | private WebElement description; |
---|
35 | |
---|
36 | /** Categorias do evento. */ |
---|
37 | @FindBy(name = "categories[]") |
---|
38 | private WebElement categories; |
---|
39 | |
---|
40 | /** Localização do evento. */ |
---|
41 | @FindBy(name = "cal[location]") |
---|
42 | private WebElement location; |
---|
43 | |
---|
44 | /** Data inicial do evento. */ |
---|
45 | @FindBy(name = "start[str]") |
---|
46 | private WebElement startDate; |
---|
47 | |
---|
48 | /** Hora inicial do evento. */ |
---|
49 | @FindBy(id = "start_hour") |
---|
50 | private WebElement startHour; |
---|
51 | |
---|
52 | /** Minuto inicial do evento; */ |
---|
53 | @FindBy(id = "start_minute") |
---|
54 | private WebElement startMinute; |
---|
55 | |
---|
56 | /** Data final do evento. */ |
---|
57 | @FindBy(name = "end[str]") |
---|
58 | private WebElement endDate; |
---|
59 | |
---|
60 | /** Hora final do evento. */ |
---|
61 | @FindBy(id = "end_hour") |
---|
62 | private WebElement endHour; |
---|
63 | |
---|
64 | /** Minuto final do evento; */ |
---|
65 | @FindBy(id = "end_minute") |
---|
66 | private WebElement endMinute; |
---|
67 | |
---|
68 | /** Prioridade do evento. */ |
---|
69 | @FindBy(name = "cal[priority]") |
---|
70 | private WebElement priority; |
---|
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 | |
---|
84 | @FindBy(id = "usuarioParticipa") |
---|
85 | private WebElement includeUser; |
---|
86 | |
---|
87 | /** Alarme dia. */ |
---|
88 | @FindBy(name = "cal[alarmdays]") |
---|
89 | private WebElement alarmDays; |
---|
90 | |
---|
91 | /** Alarme hora. */ |
---|
92 | @FindBy(name = "cal[alarmhours]") |
---|
93 | private WebElement alarmHours; |
---|
94 | |
---|
95 | /** Alarme minuto. */ |
---|
96 | @FindBy(name = "cal[alarmminutes]") |
---|
97 | private WebElement alarmMinutes; |
---|
98 | |
---|
99 | /** Tipo recursao. */ |
---|
100 | @FindBy(name = "cal[recur_type]") |
---|
101 | private WebElement recurType; |
---|
102 | |
---|
103 | @FindBy(name = "cal[rpt_use_end]") |
---|
104 | private WebElement rptUseEnd; |
---|
105 | |
---|
106 | @FindBy(name = "recur_enddate[str]") |
---|
107 | private WebElement recurEndDate; |
---|
108 | |
---|
109 | @FindBy(name = "cal[recur_interval]") |
---|
110 | private WebElement recurInterval; |
---|
111 | |
---|
112 | /** Observacao. */ |
---|
113 | @FindBy(name = "cal[#Observação]") |
---|
114 | private WebElement notes; |
---|
115 | |
---|
116 | /** Salvar. */ |
---|
117 | @FindBy(id = "submit_button") |
---|
118 | private WebElement save; |
---|
119 | |
---|
120 | public AppointmentPage(WebDriver driver) { |
---|
121 | super(driver); |
---|
122 | // TODO Auto-generated constructor stub |
---|
123 | } |
---|
124 | |
---|
125 | /** |
---|
126 | * @return Retorna o texto de validacao do formulario. |
---|
127 | */ |
---|
128 | public String getFormStatus() { |
---|
129 | return this.formStatus.getText(); |
---|
130 | } |
---|
131 | |
---|
132 | /** |
---|
133 | * @param type |
---|
134 | * the type to set |
---|
135 | */ |
---|
136 | public void setType(String type) { |
---|
137 | super.setComboValue(this.type, type); |
---|
138 | } |
---|
139 | |
---|
140 | /** |
---|
141 | * @param title |
---|
142 | * the title to set |
---|
143 | */ |
---|
144 | public void setTitle(String title) { |
---|
145 | this.title.clear(); |
---|
146 | this.title.sendKeys(title); |
---|
147 | } |
---|
148 | |
---|
149 | /** |
---|
150 | * @param description |
---|
151 | * the description to set |
---|
152 | */ |
---|
153 | public void setDescription(String description) { |
---|
154 | this.description.clear(); |
---|
155 | this.description.sendKeys(description); |
---|
156 | } |
---|
157 | |
---|
158 | /** |
---|
159 | * @param categories |
---|
160 | * the categories to set |
---|
161 | */ |
---|
162 | public void setCategories(String 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 | } |
---|
173 | } |
---|
174 | |
---|
175 | /** |
---|
176 | * @param location |
---|
177 | * the location to set |
---|
178 | */ |
---|
179 | public void setLocation(String location) { |
---|
180 | this.location.clear(); |
---|
181 | this.location.sendKeys(location); |
---|
182 | } |
---|
183 | |
---|
184 | /** |
---|
185 | * @param startDate |
---|
186 | * the start to set |
---|
187 | */ |
---|
188 | public void setStartDate(String startDate) { |
---|
189 | this.startDate.clear(); |
---|
190 | this.startDate.sendKeys(startDate); |
---|
191 | } |
---|
192 | |
---|
193 | /** |
---|
194 | * @param startHour |
---|
195 | * the startHour to set |
---|
196 | */ |
---|
197 | public void setStartHour(String startHour) { |
---|
198 | this.startHour.clear(); |
---|
199 | this.startHour.sendKeys(startHour); |
---|
200 | } |
---|
201 | |
---|
202 | /** |
---|
203 | * @param startMinute |
---|
204 | * the startMinute to set |
---|
205 | */ |
---|
206 | public void setStartMinute(String startMinute) { |
---|
207 | this.startMinute.clear(); |
---|
208 | this.startMinute.sendKeys(startMinute); |
---|
209 | } |
---|
210 | |
---|
211 | /** |
---|
212 | * @param endDate |
---|
213 | * the end to set |
---|
214 | */ |
---|
215 | public void setEndDate(String endDate) { |
---|
216 | this.endDate.clear(); |
---|
217 | this.endDate.sendKeys(endDate); |
---|
218 | } |
---|
219 | |
---|
220 | /** |
---|
221 | * @param endHour |
---|
222 | * the endHour to set |
---|
223 | */ |
---|
224 | public void setEndHour(String endHour) { |
---|
225 | this.endHour.clear(); |
---|
226 | this.endHour.sendKeys(endHour); |
---|
227 | } |
---|
228 | |
---|
229 | /** |
---|
230 | * @param endMinute |
---|
231 | * the endMinute to set |
---|
232 | */ |
---|
233 | public void setEndMinute(String endMinute) { |
---|
234 | this.endMinute.clear(); |
---|
235 | this.endMinute.sendKeys(endMinute); |
---|
236 | } |
---|
237 | |
---|
238 | /** |
---|
239 | * @param priority |
---|
240 | * the priority to set |
---|
241 | */ |
---|
242 | public void setPriority(String priority) { |
---|
243 | super.setComboValue(this.priority, priority); |
---|
244 | } |
---|
245 | |
---|
246 | /** |
---|
247 | * Inclui/Exclui usuario criador do compromisso. |
---|
248 | * |
---|
249 | * @param include |
---|
250 | * <code>true</code> para incluir usuario, <code>false</code> |
---|
251 | * para excluir. |
---|
252 | */ |
---|
253 | public void setIncludeUser(Boolean include) { |
---|
254 | if (include && !this.includeUser.isSelected()) { |
---|
255 | this.includeUser.click(); |
---|
256 | } |
---|
257 | |
---|
258 | if (!include && this.includeUser.isSelected()) { |
---|
259 | this.includeUser.click(); |
---|
260 | } |
---|
261 | } |
---|
262 | |
---|
263 | /** |
---|
264 | * @param notes |
---|
265 | * the notes to set |
---|
266 | */ |
---|
267 | public void setNotes(String notes) { |
---|
268 | this.notes.clear(); |
---|
269 | this.notes.sendKeys(notes); |
---|
270 | } |
---|
271 | |
---|
272 | /** |
---|
273 | * @param alarmDays |
---|
274 | * the alarmDays to set |
---|
275 | */ |
---|
276 | public void setAlarmDays(String alarmDays) { |
---|
277 | super.setComboValue(this.alarmDays, alarmDays); |
---|
278 | } |
---|
279 | |
---|
280 | /** |
---|
281 | * @param alarmHours |
---|
282 | * the alarmHours to set |
---|
283 | */ |
---|
284 | public void setAlarmHours(String alarmHours) { |
---|
285 | super.setComboValue(this.alarmHours, alarmHours); |
---|
286 | } |
---|
287 | |
---|
288 | /** |
---|
289 | * @param alarmMinutes |
---|
290 | * the alarmMinutes to set |
---|
291 | */ |
---|
292 | public void setAlarmMinutes(String alarmMinutes) { |
---|
293 | super.setComboValue(this.alarmMinutes, alarmMinutes); |
---|
294 | } |
---|
295 | |
---|
296 | /** |
---|
297 | * @param recurType |
---|
298 | * the recurType to set |
---|
299 | */ |
---|
300 | public void setRecurType(String recurType) { |
---|
301 | super.setComboValue(this.recurType, recurType); |
---|
302 | } |
---|
303 | |
---|
304 | public void setRptUseEnd(String finalDate) { |
---|
305 | super.waitForElement(By.name("cal[rpt_use_end]")); |
---|
306 | this.rptUseEnd.click(); |
---|
307 | this.recurEndDate.clear(); |
---|
308 | this.recurEndDate.sendKeys(finalDate); |
---|
309 | } |
---|
310 | |
---|
311 | /** |
---|
312 | * Valores para os dias da semana: |
---|
313 | * |
---|
314 | * <pre> |
---|
315 | * 1 - Domingo |
---|
316 | * 2 - Segunda |
---|
317 | * 4 - Terça |
---|
318 | * 8 - Quarta |
---|
319 | * 16 - Quinta |
---|
320 | * 32 - Sexta |
---|
321 | * 64 - Sabado |
---|
322 | * </pre> |
---|
323 | * |
---|
324 | * @param values |
---|
325 | */ |
---|
326 | public void setRecurDays(List<String> values) { |
---|
327 | List<WebElement> elements = driver.findElements(By |
---|
328 | .name("cal[rpt_day][]")); |
---|
329 | |
---|
330 | for (WebElement e : elements) { |
---|
331 | if (values.contains(e.getValue())) { |
---|
332 | e.click(); |
---|
333 | } |
---|
334 | } |
---|
335 | } |
---|
336 | |
---|
337 | /** |
---|
338 | * Salva o compromisso. |
---|
339 | */ |
---|
340 | public void saveAppointment() { |
---|
341 | this.save.click(); |
---|
342 | } |
---|
343 | |
---|
344 | /** |
---|
345 | * Salva o compromisso, mas este ira causar um conflito. |
---|
346 | * |
---|
347 | * @return Pagina para resolver conflito de agenda. |
---|
348 | */ |
---|
349 | public AppointmentConflictPage saveConflictAppointment() { |
---|
350 | this.saveAppointment(); |
---|
351 | return PageFactory.initElements(driver, AppointmentConflictPage.class); |
---|
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 | |
---|
406 | } |
---|