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

Revision 5099, 1.9 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.Set;
4
5import org.expressolivre.cte.pages.common.Page;
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 * 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 */
23public 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                // click action that cause new window to open
47                this.okButton.click();
48
49                // wait for the new window to close
50                new WebDriverWait(driver, 100) {
51                }.until(new ExpectedCondition<Boolean>() {
52                        public Boolean apply(WebDriver driver) {
53                                return (driver.getWindowHandles().size() < beforeHandles.size()) ? true
54                                                : false;
55                        }
56                });
57
58                // Get after handles
59                Set<String> afterHandles = driver.getWindowHandles();
60                String newWindowHandle = afterHandles.iterator().next();
61                driver.switchTo().window(newWindowHandle);
62                driver.switchTo().defaultContent();
63
64                return PageFactory.initElements(driver, AppointmentEmailPage.class);
65
66        }
67
68}
Note: See TracBrowser for help on using the repository browser.