package org.expressolivre.cte.pages.calendar; import java.util.Set; import org.expressolivre.cte.pages.common.Page; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.support.FindBy; import org.openqa.selenium.support.PageFactory; import org.openqa.selenium.support.ui.ExpectedCondition; import org.openqa.selenium.support.ui.WebDriverWait; /** * Pagina popup aberta quando um compromisso eh aceito/rejeitado/marcado como * tentativa a partir do email. * * @author L.F.Estivalet (Serpro) * * Created on Aug 18, 2011 at 2:09:24 PM * */ public class AppointmentStatusPage extends Page { @FindBy(xpath = "/html/body/center[1]/table/tbody/tr[1]/td/b/font") private WebElement message; @FindBy(xpath = "/html/body/center[2]/table/tbody/tr/td/form/input") private WebElement okButton; public AppointmentStatusPage(WebDriver driver) { super(driver); // TODO Auto-generated constructor stub } public String getMessage() { super.waitForElement(By .xpath("/html/body/center[1]/table/tbody/tr[1]/td/b/font")); return this.message.getText(); } public AppointmentEmailPage close() { // // Get current windows final Set beforeHandles = driver.getWindowHandles(); // click action that cause new window to open this.okButton.click(); // wait for the new window to close new WebDriverWait(driver, 100) { }.until(new ExpectedCondition() { public Boolean apply(WebDriver driver) { return (driver.getWindowHandles().size() < beforeHandles.size()) ? true : false; } }); // Get after handles Set afterHandles = driver.getWindowHandles(); String newWindowHandle = afterHandles.iterator().next(); driver.switchTo().window(newWindowHandle); driver.switchTo().defaultContent(); return PageFactory.initElements(driver, AppointmentEmailPage.class); } }