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

Revision 5099, 2.3 KB checked in by luiz-fernando, 13 years ago (diff)

Ticket #1771 - Novas alteracoes nos metodos basicos para evitar timeouts

Line 
1package org.expressolivre.cte.pages.calendar;
2
3import java.util.List;
4
5import org.openqa.selenium.By;
6import org.openqa.selenium.WebDriver;
7import org.openqa.selenium.WebElement;
8
9/**
10 * @author L.F.Estivalet (Serpro)
11 *
12 *         Created on Feb 9, 2011 at 9:58:16 AM
13 *
14 */
15public class CalendarTodayViewPage extends CalendarPage {
16
17        public CalendarTodayViewPage(WebDriver driver) {
18                super(driver);
19                // TODO Auto-generated constructor stub
20        }
21
22        /**
23         * Procura o "id" do compromisso baseado no titulo do mesmo.
24         *
25         * @param title
26         *            Titulo do compromisso.
27         * @return "id" do compromisso.
28         */
29        public String getAppointmentId(String title) {
30                String source = driver.getPageSource();
31                int i = source.indexOf("\"title\":\"" + title);
32                int j = source.indexOf("\"id\":", i);
33                return source.substring(j + 5, source.indexOf(",", j));
34        }
35
36        /**
37         * Verifica se o horario do compromisso aparece na lista.
38         *
39         * @param startTime
40         * @return
41         */
42        public boolean isStartTimePresent(String startTime) {
43                // Lista todos os horarios.
44                boolean foundTime = false;
45                List<WebElement> hours = driver.findElements(By
46                                .className("dhx_scale_hour"));
47                for (WebElement h : hours) {
48                        if (h.getText().equals(startTime)) {
49                                foundTime = true;
50                                break;
51                        }
52                }
53                return foundTime;
54        }
55
56        /**
57         * Procura o compromisso pelo titulo.
58         *
59         * @param title
60         * @return
61         */
62        public WebElement findAppointment(String title) {
63                List<WebElement> elements = driver.findElements(By
64                                .className("dhx_title"));
65                for (WebElement e : elements) {
66                        if (title.equals(e.getText())) {
67                                return e;
68                        }
69                }
70                return null;
71        }
72
73        /**
74         * Verifica se o compromisso contido no elemento e eh do tipo individual.
75         *
76         * @param e
77         * @return
78         */
79        public boolean isSingle(WebElement e) {
80                // Recupera o icone referente ao compromisso
81                WebElement image = e.findElement(By.xpath("img"));
82                return image.getAttribute("src").contains("single.png");
83        }
84
85        /**
86         * Verifica se o compromisso contido no elemento e eh do tipo restrito.
87         *
88         * @param e
89         * @return
90         */
91        public boolean isRestrict(WebElement e) {
92                // Recupera o icone referente ao compromisso
93                List<WebElement> images = e.findElements(By.xpath("img"));
94                boolean restrictAppointment = false;
95                for (WebElement ele : images) {
96                        if (ele.getAttribute("src").contains("private.png")) {
97                                return true;
98                        }
99                }
100                return restrictAppointment;
101        }
102}
Note: See TracBrowser for help on using the repository browser.