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

Revision 4917, 3.4 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 org.expressolivre.cte.common.Constants;
4import org.expressolivre.cte.pages.common.Page;
5import org.openqa.selenium.By;
6import org.openqa.selenium.WebDriver;
7import org.openqa.selenium.WebElement;
8import org.openqa.selenium.support.FindBy;
9import 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 */
17public 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(name = "date")
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 o visao diaria para uma data especifica.
66         *
67         * @param data
68         *            Data no formato yyyyMMdd.
69         * @return
70         */
71        public CalendarTodayViewPage openTodayView(String data) {
72                driver.get(Constants.URL
73                                + "/index.php?menuaction=calendar.uicalendar.day&date=" + data);
74                return PageFactory.initElements(driver, CalendarTodayViewPage.class);
75        }
76
77        /**
78         * Abre tela para adicionar novo compromisso.
79         *
80         * @param date
81         *            Data do compromisso.
82         */
83        public void openAppointmentPage(String date) {
84                driver.get(Constants.URL
85                                + "/index.php?menuaction=calendar.uicalendar.add&date=" + date);
86        }
87
88        /**
89         * @param id
90         * @return
91         */
92        public AppointmentViewPage openAppointmentViewPage(String id) {
93                driver.get(Constants.URL
94                                + "/index.php?menuaction=calendar.uicalendar.view&cal_id=" + id);
95                return PageFactory.initElements(driver, AppointmentViewPage.class);
96        }
97
98        /**
99         * @param id
100         * @param date
101         * @return
102         */
103        public AppointmentViewPage openAppointmentViewPage(String id, String date) {
104                driver.get(Constants.URL
105                                + "/index.php?menuaction=calendar.uicalendar.view&cal_id=" + id
106                                + "&date=" + date);
107                return PageFactory.initElements(driver, AppointmentViewPage.class);
108        }
109
110        /**
111         * Coloca um texto para pesquisar na agenda.
112         *
113         * @param searchText
114         *            Texto a ser pesquisado.
115         */
116        public void setSearchText(String searchText) {
117                this.searchText.clear();
118                this.searchText.sendKeys(searchText);
119        }
120
121        /**
122         * Dispara a pesquisa na agenda.
123         *
124         * @return Pagina de resultados da pesquisa.
125         */
126        public AppointmentSearchResultPage searchAppointment() {
127                this.searchButton.click();
128                return PageFactory.initElements(driver,
129                                AppointmentSearchResultPage.class);
130        }
131
132}
Note: See TracBrowser for help on using the repository browser.