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

Revision 5025, 2.0 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.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                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}
Note: See TracBrowser for help on using the repository browser.