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

Revision 4962, 3.5 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.WebDriver;
7import org.openqa.selenium.WebElement;
8import org.openqa.selenium.support.FindBy;
9import org.openqa.selenium.support.PageFactory;
10import org.openqa.selenium.support.ui.ExpectedCondition;
11import 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 */
19public 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}
Note: See TracBrowser for help on using the repository browser.