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

Revision 4895, 3.1 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 tela para adicionar novo compromisso.
66         *
67         * @param date
68         *            Data do compromisso.
69         */
70        public void openAppointmentPage(String date) {
71                driver.get(Constants.URL
72                                + "/index.php?menuaction=calendar.uicalendar.add&date=" + date);
73        }
74
75        /**
76         * @param id
77         * @return
78         */
79        public AppointmentViewPage openAppointmentViewPage(String id) {
80                driver.get(Constants.URL
81                                + "/index.php?menuaction=calendar.uicalendar.view&cal_id=" + id);
82                return PageFactory.initElements(driver, AppointmentViewPage.class);
83        }
84
85        /**
86         * @param id
87         * @param date
88         * @return
89         */
90        public AppointmentViewPage openAppointmentViewPage(String id, String date) {
91                driver.get(Constants.URL
92                                + "/index.php?menuaction=calendar.uicalendar.view&cal_id=" + id
93                                + "&date=" + date);
94                return PageFactory.initElements(driver, AppointmentViewPage.class);
95        }
96
97        /**
98         * Coloca um texto para pesquisar na agenda.
99         *
100         * @param searchText
101         *            Texto a ser pesquisado.
102         */
103        public void setSearchText(String searchText) {
104                this.searchText.clear();
105                this.searchText.sendKeys(searchText);
106        }
107
108        /**
109         * Dispara a pesquisa na agenda.
110         *
111         * @return Pagina de resultados da pesquisa.
112         */
113        public AppointmentSearchResultPage searchAppointment() {
114                this.searchButton.click();
115                return PageFactory.initElements(driver,
116                                AppointmentSearchResultPage.class);
117        }
118
119}
Note: See TracBrowser for help on using the repository browser.