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.WebDriver; |
---|
7 | import org.openqa.selenium.WebElement; |
---|
8 | import org.openqa.selenium.support.FindBy; |
---|
9 | import org.openqa.selenium.support.PageFactory; |
---|
10 | import org.openqa.selenium.support.ui.ExpectedCondition; |
---|
11 | import org.openqa.selenium.support.ui.WebDriverWait; |
---|
12 | |
---|
13 | /** |
---|
14 | * @author L.F.Estivalet (Serpro) |
---|
15 | * |
---|
16 | * Created on Aug 17, 2011 at 9:16:01 AM |
---|
17 | * |
---|
18 | */ |
---|
19 | public class AgendaPermissionPage extends Page { |
---|
20 | |
---|
21 | /** Permitir acesso para ler compromissos da agenda. */ |
---|
22 | @FindBy(id = "user_list") |
---|
23 | private WebElement userList; |
---|
24 | |
---|
25 | /** Permitir acesso para ler compromissos da agenda. */ |
---|
26 | @FindBy(xpath = "//table[@id='tableDivAppbox']/tbody/tr/td/form/center/table/tbody/tr[2]/td[3]/table/tbody/tr[1]/td[1]/input") |
---|
27 | private WebElement read; |
---|
28 | |
---|
29 | /** Permitir acesso para adicionar compromissos da agenda. */ |
---|
30 | @FindBy(xpath = "//table[@id='tableDivAppbox']/tbody/tr/td/form/center/table/tbody/tr[2]/td[3]/table/tbody/tr[2]/td[1]/input") |
---|
31 | private WebElement add; |
---|
32 | |
---|
33 | /** Permitir acesso para editar compromissos da agenda. */ |
---|
34 | @FindBy(xpath = "//table[@id='tableDivAppbox']/tbody/tr/td/form/center/table/tbody/tr[2]/td[3]/table/tbody/tr[3]/td[1]/input") |
---|
35 | private WebElement edit; |
---|
36 | |
---|
37 | /** Permitir acesso para remover compromissos da agenda. */ |
---|
38 | @FindBy(xpath = "//table[@id='tableDivAppbox']/tbody/tr/td/form/center/table/tbody/tr[2]/td[3]/table/tbody/tr[4]/td[1]/input") |
---|
39 | private WebElement remove; |
---|
40 | |
---|
41 | @FindBy(xpath = "//table[@id='tableDivAppbox']/tbody/tr/td/form/center/table/tbody/tr[2]/td[3]/table/tbody/tr[5]/td[1]/input") |
---|
42 | private WebElement restrict; |
---|
43 | |
---|
44 | @FindBy(xpath = "//table[@id='tableDivAppbox']/tbody/tr/td/form/center/table/tbody/tr[4]/td[2]/center/input[1]") |
---|
45 | private WebElement okButton; |
---|
46 | |
---|
47 | @FindBy(xpath = "//table[@id='tableDivAppbox']/tbody/tr/td/form/center/table/tbody/tr[4]/td[2]/center/input[2]") |
---|
48 | private WebElement addButton; |
---|
49 | |
---|
50 | @FindBy(xpath = "//table[@id='tableDivAppbox']/tbody/tr/td/form/center/table/tbody/tr[4]/td[2]/center/input[3]") |
---|
51 | private WebElement removeButton; |
---|
52 | |
---|
53 | @FindBy(xpath = "//table[@id='tableDivAppbox']/tbody/tr/td/form/center/table/tbody/tr[4]/td[2]/center/input[4]") |
---|
54 | private WebElement cancelButton; |
---|
55 | |
---|
56 | public AgendaPermissionPage(WebDriver driver) { |
---|
57 | super(driver); |
---|
58 | // TODO Auto-generated constructor stub |
---|
59 | } |
---|
60 | |
---|
61 | /** |
---|
62 | * Adaptacao da solucao para lidar com janelas popups obtida em <a |
---|
63 | * href="http://groups.google.com/group |
---|
64 | * /webdriver/browse_thread/thread/038a911803f26dcd">link</a> |
---|
65 | * |
---|
66 | * @return |
---|
67 | */ |
---|
68 | public AgendaAddACLUserPage addUserACL() { |
---|
69 | // Get current windows |
---|
70 | final Set<String> beforeHandles = driver.getWindowHandles(); |
---|
71 | // click action that cause new window to open |
---|
72 | this.addButton.click(); |
---|
73 | // wait for the new window to open |
---|
74 | new WebDriverWait(driver, 30) { |
---|
75 | }.until(new ExpectedCondition<Boolean>() { |
---|
76 | public Boolean apply(WebDriver driver) { |
---|
77 | return (driver.getWindowHandles().size() > beforeHandles.size()) ? true |
---|
78 | : false; |
---|
79 | } |
---|
80 | }); |
---|
81 | |
---|
82 | // Get after handles |
---|
83 | Set<String> afterHandles = driver.getWindowHandles(); |
---|
84 | // remove all before handles from after. Leaves you with new window |
---|
85 | // handle |
---|
86 | afterHandles.removeAll(beforeHandles); |
---|
87 | // Switch to the new window |
---|
88 | String newWindowHandle = afterHandles.iterator().next(); |
---|
89 | driver.switchTo().window(newWindowHandle); |
---|
90 | |
---|
91 | return PageFactory.initElements(driver, AgendaAddACLUserPage.class); |
---|
92 | } |
---|
93 | |
---|
94 | public void setReadPermission() { |
---|
95 | this.read.click(); |
---|
96 | } |
---|
97 | |
---|
98 | public void cancel() { |
---|
99 | this.cancelButton.click(); |
---|
100 | } |
---|
101 | } |
---|