1 | package org.expressolivre.cte.pages.calendar; |
---|
2 | |
---|
3 | import org.expressolivre.cte.common.Constants; |
---|
4 | import org.expressolivre.cte.pages.common.Page; |
---|
5 | import org.openqa.selenium.By; |
---|
6 | import org.openqa.selenium.WebDriver; |
---|
7 | import org.openqa.selenium.WebElement; |
---|
8 | import org.openqa.selenium.support.FindBy; |
---|
9 | import org.openqa.selenium.support.PageFactory; |
---|
10 | |
---|
11 | /** |
---|
12 | * @author L.F.Estivalet (Serpro) |
---|
13 | * |
---|
14 | * Created on Feb 8, 2011 at 9:13:50 AM |
---|
15 | * |
---|
16 | */ |
---|
17 | public class CalendarPage extends Page { |
---|
18 | |
---|
19 | /** Combo para selecionar categoria. */ |
---|
20 | @FindBy(name = "cat_id") |
---|
21 | private WebElement category; |
---|
22 | |
---|
23 | @FindBy(name = "filter") |
---|
24 | private WebElement filter; |
---|
25 | |
---|
26 | @FindBy(name = "owner") |
---|
27 | private WebElement owner; |
---|
28 | |
---|
29 | /** Campo para pesquisar agenda. */ |
---|
30 | @FindBy(xpath = "/html/body/div[@id='divSubContainer']/table/tbody/tr/td[@id='tdAppbox']/div[@id='divAppbox']/table[@id='tableDivAppbox']/tbody/tr/td/table[@id='calendar_head_table']/tbody/tr/td[4]/nobr/form/div/input[9]") |
---|
31 | private WebElement searchText; |
---|
32 | |
---|
33 | /** Botao para acionar a pesquisa na agenda. */ |
---|
34 | @FindBy(xpath = "//table[@id='calendar_head_table']/tbody/tr/td[4]/nobr/form/div/input[@id='']") |
---|
35 | private WebElement searchButton; |
---|
36 | |
---|
37 | /** Combo para selecionar mes. */ |
---|
38 | @FindBy(xpath = "//table[@id='tableDivAppbox']/tbody/tr/td/font/table/tbody/tr/td[2]/font[1]/form/select") |
---|
39 | private WebElement date; |
---|
40 | |
---|
41 | /** Combo para selecionar ano. */ |
---|
42 | @FindBy(name = "year") |
---|
43 | private WebElement year; |
---|
44 | |
---|
45 | /** |
---|
46 | * @param driver |
---|
47 | */ |
---|
48 | public CalendarPage(WebDriver driver) { |
---|
49 | super(driver); |
---|
50 | // TODO Auto-generated constructor stub |
---|
51 | } |
---|
52 | |
---|
53 | /** |
---|
54 | * Abre a visao diaria da agenda. |
---|
55 | * |
---|
56 | * @return Pagina da visao diaria da agenda. |
---|
57 | */ |
---|
58 | public CalendarTodayViewPage openTodayView() { |
---|
59 | super.clickElement(By |
---|
60 | .xpath("//table[@id='calendar_head_table']/tbody/tr/td[2]/a/img")); |
---|
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); |
---|
95 | } |
---|
96 | |
---|
97 | /** |
---|
98 | * Abre o visao diaria para uma data especifica. |
---|
99 | * |
---|
100 | * @param data |
---|
101 | * Data no formato yyyyMMdd. |
---|
102 | * @return |
---|
103 | */ |
---|
104 | public CalendarTodayViewPage openTodayView(String data) { |
---|
105 | driver.get(Constants.URL |
---|
106 | + "/index.php?menuaction=calendar.uicalendar.day&date=" + data); |
---|
107 | return PageFactory.initElements(driver, CalendarTodayViewPage.class); |
---|
108 | } |
---|
109 | |
---|
110 | /** |
---|
111 | * Abre tela para adicionar novo compromisso. |
---|
112 | * |
---|
113 | * @param date |
---|
114 | * Data do compromisso. |
---|
115 | */ |
---|
116 | public void openAppointmentPage(String date) { |
---|
117 | driver.get(Constants.URL |
---|
118 | + "/index.php?menuaction=calendar.uicalendar.add&date=" + date); |
---|
119 | } |
---|
120 | |
---|
121 | /** |
---|
122 | * @param id |
---|
123 | * @return |
---|
124 | */ |
---|
125 | public AppointmentViewPage openAppointmentViewPage(String id) { |
---|
126 | driver.get(Constants.URL |
---|
127 | + "/index.php?menuaction=calendar.uicalendar.view&cal_id=" + id); |
---|
128 | return PageFactory.initElements(driver, AppointmentViewPage.class); |
---|
129 | } |
---|
130 | |
---|
131 | /** |
---|
132 | * @param id |
---|
133 | * @param date |
---|
134 | * @return |
---|
135 | */ |
---|
136 | public AppointmentViewPage openAppointmentViewPage(String id, String date) { |
---|
137 | driver.get(Constants.URL |
---|
138 | + "/index.php?menuaction=calendar.uicalendar.view&cal_id=" + id |
---|
139 | + "&date=" + date); |
---|
140 | return PageFactory.initElements(driver, AppointmentViewPage.class); |
---|
141 | } |
---|
142 | |
---|
143 | /** |
---|
144 | * Coloca um texto para pesquisar na agenda. |
---|
145 | * |
---|
146 | * @param searchText |
---|
147 | * Texto a ser pesquisado. |
---|
148 | */ |
---|
149 | public void setSearchText(String searchText) { |
---|
150 | this.searchText.clear(); |
---|
151 | this.searchText.sendKeys(searchText); |
---|
152 | } |
---|
153 | |
---|
154 | /** |
---|
155 | * Dispara a pesquisa na agenda. |
---|
156 | * |
---|
157 | * @return Pagina de resultados da pesquisa. |
---|
158 | */ |
---|
159 | public AppointmentSearchResultPage searchAppointment() { |
---|
160 | this.searchButton.click(); |
---|
161 | return PageFactory.initElements(driver, |
---|
162 | AppointmentSearchResultPage.class); |
---|
163 | } |
---|
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 | |
---|
187 | } |
---|