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 = "usuarioParticipa") |
---|
73 | private WebElement includeUser; |
---|
74 | |
---|
75 | /** Alarme dia. */ |
---|
76 | @FindBy(name = "cal[alarmdays]") |
---|
77 | private WebElement alarmDays; |
---|
78 | |
---|
79 | /** Alarme hora. */ |
---|
80 | @FindBy(name = "cal[alarmhours]") |
---|
81 | private WebElement alarmHours; |
---|
82 | |
---|
83 | /** Alarme minuto. */ |
---|
84 | @FindBy(name = "cal[alarmminutes]") |
---|
85 | private WebElement alarmMinutes; |
---|
86 | |
---|
87 | /** Tipo recursao. */ |
---|
88 | @FindBy(name = "cal[recur_type]") |
---|
89 | private WebElement recurType; |
---|
90 | |
---|
91 | @FindBy(name = "cal[rpt_use_end]") |
---|
92 | private WebElement rptUseEnd; |
---|
93 | |
---|
94 | @FindBy(name = "recur_enddate[str]") |
---|
95 | private WebElement recurEndDate; |
---|
96 | |
---|
97 | @FindBy(name = "cal[recur_interval]") |
---|
98 | private WebElement recurInterval; |
---|
99 | |
---|
100 | /** Observacao. */ |
---|
101 | @FindBy(name = "cal[#Observação]") |
---|
102 | private WebElement notes; |
---|
103 | |
---|
104 | /** Salvar. */ |
---|
105 | @FindBy(id = "submit_button") |
---|
106 | private WebElement save; |
---|
107 | |
---|
108 | public AppointmentPage(WebDriver driver) { |
---|
109 | super(driver); |
---|
110 | // TODO Auto-generated constructor stub |
---|
111 | } |
---|
112 | |
---|
113 | /** |
---|
114 | * @return Retorna o texto de validacao do formulario. |
---|
115 | */ |
---|
116 | public String getFormStatus() { |
---|
117 | return this.formStatus.getText(); |
---|
118 | } |
---|
119 | |
---|
120 | /** |
---|
121 | * @param type |
---|
122 | * the type to set |
---|
123 | */ |
---|
124 | public void setType(String type) { |
---|
125 | super.setComboValue(this.type, type); |
---|
126 | } |
---|
127 | |
---|
128 | /** |
---|
129 | * @param title |
---|
130 | * the title to set |
---|
131 | */ |
---|
132 | public void setTitle(String title) { |
---|
133 | this.title.clear(); |
---|
134 | this.title.sendKeys(title); |
---|
135 | } |
---|
136 | |
---|
137 | /** |
---|
138 | * @param description |
---|
139 | * the description to set |
---|
140 | */ |
---|
141 | public void setDescription(String description) { |
---|
142 | this.description.clear(); |
---|
143 | this.description.sendKeys(description); |
---|
144 | } |
---|
145 | |
---|
146 | /** |
---|
147 | * @param categories |
---|
148 | * the categories to set |
---|
149 | */ |
---|
150 | public void setCategories(String categories) { |
---|
151 | this.categories.sendKeys(categories); |
---|
152 | } |
---|
153 | |
---|
154 | /** |
---|
155 | * @param location |
---|
156 | * the location to set |
---|
157 | */ |
---|
158 | public void setLocation(String location) { |
---|
159 | this.location.clear(); |
---|
160 | this.location.sendKeys(location); |
---|
161 | } |
---|
162 | |
---|
163 | /** |
---|
164 | * @param startDate |
---|
165 | * the start to set |
---|
166 | */ |
---|
167 | public void setStartDate(String startDate) { |
---|
168 | this.startDate.clear(); |
---|
169 | this.startDate.sendKeys(startDate); |
---|
170 | } |
---|
171 | |
---|
172 | /** |
---|
173 | * @param startHour |
---|
174 | * the startHour to set |
---|
175 | */ |
---|
176 | public void setStartHour(String startHour) { |
---|
177 | this.startHour.clear(); |
---|
178 | this.startHour.sendKeys(startHour); |
---|
179 | } |
---|
180 | |
---|
181 | /** |
---|
182 | * @param startMinute |
---|
183 | * the startMinute to set |
---|
184 | */ |
---|
185 | public void setStartMinute(String startMinute) { |
---|
186 | this.startMinute.clear(); |
---|
187 | this.startMinute.sendKeys(startMinute); |
---|
188 | } |
---|
189 | |
---|
190 | /** |
---|
191 | * @param endDate |
---|
192 | * the end to set |
---|
193 | */ |
---|
194 | public void setEndDate(String endDate) { |
---|
195 | this.endDate.clear(); |
---|
196 | this.endDate.sendKeys(endDate); |
---|
197 | } |
---|
198 | |
---|
199 | /** |
---|
200 | * @param endHour |
---|
201 | * the endHour to set |
---|
202 | */ |
---|
203 | public void setEndHour(String endHour) { |
---|
204 | this.endHour.clear(); |
---|
205 | this.endHour.sendKeys(endHour); |
---|
206 | } |
---|
207 | |
---|
208 | /** |
---|
209 | * @param endMinute |
---|
210 | * the endMinute to set |
---|
211 | */ |
---|
212 | public void setEndMinute(String endMinute) { |
---|
213 | this.endMinute.clear(); |
---|
214 | this.endMinute.sendKeys(endMinute); |
---|
215 | } |
---|
216 | |
---|
217 | /** |
---|
218 | * @param priority |
---|
219 | * the priority to set |
---|
220 | */ |
---|
221 | public void setPriority(String priority) { |
---|
222 | super.setComboValue(this.priority, priority); |
---|
223 | } |
---|
224 | |
---|
225 | /** |
---|
226 | * Inclui/Exclui usuario criador do compromisso. |
---|
227 | * |
---|
228 | * @param include |
---|
229 | * <code>true</code> para incluir usuario, <code>false</code> |
---|
230 | * para excluir. |
---|
231 | */ |
---|
232 | public void setIncludeUser(Boolean include) { |
---|
233 | if (include && !this.includeUser.isSelected()) { |
---|
234 | this.includeUser.click(); |
---|
235 | } |
---|
236 | |
---|
237 | if (!include && this.includeUser.isSelected()) { |
---|
238 | this.includeUser.click(); |
---|
239 | } |
---|
240 | } |
---|
241 | |
---|
242 | /** |
---|
243 | * @param notes |
---|
244 | * the notes to set |
---|
245 | */ |
---|
246 | public void setNotes(String notes) { |
---|
247 | this.notes.clear(); |
---|
248 | this.notes.sendKeys(notes); |
---|
249 | } |
---|
250 | |
---|
251 | /** |
---|
252 | * @param alarmDays |
---|
253 | * the alarmDays to set |
---|
254 | */ |
---|
255 | public void setAlarmDays(String alarmDays) { |
---|
256 | super.setComboValue(this.alarmDays, alarmDays); |
---|
257 | } |
---|
258 | |
---|
259 | /** |
---|
260 | * @param alarmHours |
---|
261 | * the alarmHours to set |
---|
262 | */ |
---|
263 | public void setAlarmHours(String alarmHours) { |
---|
264 | super.setComboValue(this.alarmHours, alarmHours); |
---|
265 | } |
---|
266 | |
---|
267 | /** |
---|
268 | * @param alarmMinutes |
---|
269 | * the alarmMinutes to set |
---|
270 | */ |
---|
271 | public void setAlarmMinutes(String alarmMinutes) { |
---|
272 | super.setComboValue(this.alarmMinutes, alarmMinutes); |
---|
273 | } |
---|
274 | |
---|
275 | /** |
---|
276 | * @param recurType |
---|
277 | * the recurType to set |
---|
278 | */ |
---|
279 | public void setRecurType(String recurType) { |
---|
280 | super.setComboValue(this.recurType, recurType); |
---|
281 | } |
---|
282 | |
---|
283 | public void setRptUseEnd(String finalDate) { |
---|
284 | super.waitForElement(By.name("cal[rpt_use_end]")); |
---|
285 | this.rptUseEnd.click(); |
---|
286 | this.recurEndDate.clear(); |
---|
287 | this.recurEndDate.sendKeys(finalDate); |
---|
288 | } |
---|
289 | |
---|
290 | /** |
---|
291 | * Valores para os dias da semana: |
---|
292 | * |
---|
293 | * <pre> |
---|
294 | * 1 - Domingo |
---|
295 | * 2 - Segunda |
---|
296 | * 4 - Terça |
---|
297 | * 8 - Quarta |
---|
298 | * 16 - Quinta |
---|
299 | * 32 - Sexta |
---|
300 | * 64 - Sabado |
---|
301 | * </pre> |
---|
302 | * |
---|
303 | * @param values |
---|
304 | */ |
---|
305 | public void setRecurDays(List<String> values) { |
---|
306 | List<WebElement> elements = driver.findElements(By |
---|
307 | .name("cal[rpt_day][]")); |
---|
308 | |
---|
309 | for (WebElement e : elements) { |
---|
310 | if (values.contains(e.getValue())) { |
---|
311 | e.click(); |
---|
312 | } |
---|
313 | } |
---|
314 | } |
---|
315 | |
---|
316 | /** |
---|
317 | * Salva o compromisso. |
---|
318 | */ |
---|
319 | public void saveAppointment() { |
---|
320 | this.save.click(); |
---|
321 | } |
---|
322 | |
---|
323 | /** |
---|
324 | * Salva o compromisso, mas este ira causar um conflito. |
---|
325 | * |
---|
326 | * @return Pagina para resolver conflito de agenda. |
---|
327 | */ |
---|
328 | public AppointmentConflictPage saveConflictAppointment() { |
---|
329 | this.saveAppointment(); |
---|
330 | return PageFactory.initElements(driver, AppointmentConflictPage.class); |
---|
331 | } |
---|
332 | } |
---|