source: devel/testlink/automation2.0/src/test/java/org/expressolivre/cte/pages/calendar/AppointmentPage.java @ 4902

Revision 4902, 6.3 KB checked in by luiz-fernando, 13 years ago (diff)

Ticket #1771 - Adicionado testes automatizados para modulo da agenda

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