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