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

Revision 4962, 1.9 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.common.Page;
6import org.openqa.selenium.WebDriver;
7import org.openqa.selenium.WebElement;
8import org.openqa.selenium.support.FindBy;
9import org.openqa.selenium.support.PageFactory;
10import org.openqa.selenium.support.ui.ExpectedCondition;
11import org.openqa.selenium.support.ui.WebDriverWait;
12
13/**
14 * Pagina popup aberta quando um compromisso eh aceito/rejeitado/marcado como
15 * tentativa a partir do email.
16 *
17 * @author L.F.Estivalet (Serpro)
18 *
19 *         Created on Aug 18, 2011 at 2:09:24 PM
20 *
21 */
22public class AppointmentStatusPage extends Page {
23
24        @FindBy(xpath = "/html/body/center[1]/table/tbody/tr[1]/td/b/font")
25        private WebElement message;
26
27        @FindBy(xpath = "/html/body/center[2]/table/tbody/tr/td/form/input")
28        private WebElement okButton;
29
30        public AppointmentStatusPage(WebDriver driver) {
31                super(driver);
32                // TODO Auto-generated constructor stub
33        }
34
35        public String getMessage() {
36                return this.message.getText();
37        }
38
39        public AppointmentEmailPage close() {
40                // // Get current windows
41                final Set<String> beforeHandles = driver.getWindowHandles();
42
43                System.out.println("1)handles-->" + driver.getWindowHandles().size());
44
45                // click action that cause new window to open
46                this.okButton.click();
47
48                System.out.println("2)handles-->" + driver.getWindowHandles().size());
49
50                // wait for the new window to close
51                new WebDriverWait(driver, 30) {
52                }.until(new ExpectedCondition<Boolean>() {
53                        public Boolean apply(WebDriver driver) {
54                                return (driver.getWindowHandles().size() < beforeHandles.size()) ? true
55                                                : false;
56                        }
57                });
58
59                // Get after handles
60                Set<String> afterHandles = driver.getWindowHandles();
61                String newWindowHandle = afterHandles.iterator().next();
62                driver.switchTo().window(newWindowHandle);
63
64                return PageFactory.initElements(driver, AppointmentEmailPage.class);
65
66        }
67
68}
Note: See TracBrowser for help on using the repository browser.