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

Revision 4962, 4.2 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.Set;
4
5import org.expressolivre.cte.pages.email.MailPage;
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;
11import org.openqa.selenium.support.ui.ExpectedCondition;
12import org.openqa.selenium.support.ui.WebDriverWait;
13
14/**
15 * @author L.F.Estivalet (Serpro)
16 *
17 *         Created on Aug 18, 2011 at 1:55:51 PM
18 *
19 */
20public class AppointmentEmailPage extends MailPage {
21
22        @FindBy(xpath = "//div[@id='exmail_main_body']/div[2]/table/tbody/tr[2]/td/div[1]/div[1]/span/table[2]/tbody/tr[2]/td[5]/form/input")
23        private WebElement delegateAppointmentButton;
24
25        @FindBy(xpath = "//div[@id='exmail_main_body']/div[2]/table/tbody/tr[2]/td/div[1]/div[1]/span/table[2]/tbody/tr[2]/td[6]/form/input")
26        private WebElement appointmentAlarmManagerButton;
27
28        public AppointmentEmailPage(WebDriver driver) {
29                super(driver);
30                // TODO Auto-generated constructor stub
31        }
32
33        public AppointmentStatusPage accept(String id) {
34                // Get current windows
35                final Set<String> beforeHandles = driver.getWindowHandles();
36
37                // click action that cause new window to open
38                driver.findElement(
39                                By.xpath("//div[@id='body_" + id
40                                                + "_r']/span/table[2]/tbody/tr[2]/td[2]/input"))
41                                .click();
42
43                // wait for the new window to open
44                new WebDriverWait(driver, 30) {
45                }.until(new ExpectedCondition<Boolean>() {
46                        public Boolean apply(WebDriver driver) {
47                                return (driver.getWindowHandles().size() > beforeHandles.size()) ? true
48                                                : false;
49                        }
50                });
51
52                // Get after handles
53                Set<String> afterHandles = driver.getWindowHandles();
54                // remove all before handles from after. Leaves you with new window
55                // handle
56                afterHandles.removeAll(beforeHandles);
57                // Switch to the new window
58                String newWindowHandle = afterHandles.iterator().next();
59                driver.switchTo().window(newWindowHandle);
60
61                return PageFactory.initElements(driver, AppointmentStatusPage.class);
62        }
63
64        public AppointmentStatusPage reject(String id) {
65                // Get current windows
66                final Set<String> beforeHandles = driver.getWindowHandles();
67
68                // click action that cause new window to open
69                driver.findElement(
70                                By.xpath("//div[@id='body_" + id
71                                                + "_r']/span/table[2]/tbody/tr[2]/td[3]/input"))
72                                .click();
73
74                // wait for the new window to open
75                new WebDriverWait(driver, 30) {
76                }.until(new ExpectedCondition<Boolean>() {
77                        public Boolean apply(WebDriver driver) {
78                                return (driver.getWindowHandles().size() > beforeHandles.size()) ? true
79                                                : false;
80                        }
81                });
82
83                // Get after handles
84                Set<String> afterHandles = driver.getWindowHandles();
85                // remove all before handles from after. Leaves you with new window
86                // handle
87                afterHandles.removeAll(beforeHandles);
88                // Switch to the new window
89                String newWindowHandle = afterHandles.iterator().next();
90                driver.switchTo().window(newWindowHandle);
91
92                return PageFactory.initElements(driver, AppointmentStatusPage.class);
93        }
94
95        public AppointmentStatusPage tentative(String id) {
96                // Get current windows
97                final Set<String> beforeHandles = driver.getWindowHandles();
98
99                // click action that cause new window to open
100                driver.findElement(
101                                By.xpath("//div[@id='body_" + id
102                                                + "_r']/span/table[2]/tbody/tr[2]/td[4]/input"))
103                                .click();
104
105                // wait for the new window to open
106                new WebDriverWait(driver, 30) {
107                }.until(new ExpectedCondition<Boolean>() {
108                        public Boolean apply(WebDriver driver) {
109                                return (driver.getWindowHandles().size() > beforeHandles.size()) ? true
110                                                : false;
111                        }
112                });
113
114                // Get after handles
115                Set<String> afterHandles = driver.getWindowHandles();
116                // remove all before handles from after. Leaves you with new window
117                // handle
118                afterHandles.removeAll(beforeHandles);
119                // Switch to the new window
120                String newWindowHandle = afterHandles.iterator().next();
121                driver.switchTo().window(newWindowHandle);
122
123                return PageFactory.initElements(driver, AppointmentStatusPage.class);
124        }
125
126        public AppointmentViewPage viewAppointment(String id) {
127                driver.findElement(
128                                By.xpath("//div[@id='body_" + id
129                                                + "_r']/span/table[2]/tbody/tr[2]/td[1]/form/input"))
130                                .click();
131                return PageFactory.initElements(driver, AppointmentViewPage.class);
132        }
133
134}
Note: See TracBrowser for help on using the repository browser.