root / test / org / gss_project / gss / web / client / selenium / tests / TestGroup.java @ 1206:292dec4eae08
History | View | Annotate | Download (5 kB)
1 |
/*
|
---|---|
2 |
* Copyright 2011 Electronic Business Systems Ltd.
|
3 |
*
|
4 |
* This file is part of GSS.
|
5 |
*
|
6 |
* GSS is free software: you can redistribute it and/or modify
|
7 |
* it under the terms of the GNU General Public License as published by
|
8 |
* the Free Software Foundation, either version 3 of the License, or
|
9 |
* (at your option) any later version.
|
10 |
*
|
11 |
* GSS is distributed in the hope that it will be useful,
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14 |
* GNU General Public License for more details.
|
15 |
*
|
16 |
* You should have received a copy of the GNU General Public License
|
17 |
* along with GSS. If not, see <http://www.gnu.org/licenses/>.
|
18 |
*/
|
19 |
package org.gss_project.gss.web.client.selenium.tests; |
20 |
|
21 |
|
22 |
|
23 |
import org.junit.After; |
24 |
import org.junit.Assert; |
25 |
import org.junit.Before; |
26 |
import org.junit.Test; |
27 |
import org.openqa.selenium.By; |
28 |
import org.openqa.selenium.WebDriver; |
29 |
import org.openqa.selenium.firefox.FirefoxDriver; |
30 |
|
31 |
public class TestGroup { |
32 |
|
33 |
ActionUtils action; |
34 |
|
35 |
WebDriver driver; |
36 |
|
37 |
String url = "http://127.0.0.1:8080/pithos/login?next=http://127.0.0.1:8080/pithos/"; |
38 |
|
39 |
String groupName = "Wookiees"; |
40 |
|
41 |
String userName = "lakis@ebs.gr"; |
42 |
|
43 |
String addUserName = "past@ebs.gr"; |
44 |
|
45 |
|
46 |
|
47 |
/**
|
48 |
* @throws java.lang.Exception
|
49 |
*/
|
50 |
@Before
|
51 |
public void setUp() throws Exception { |
52 |
driver = new FirefoxDriver();
|
53 |
|
54 |
action = new ActionUtils(driver);
|
55 |
|
56 |
action.getUrl(url); |
57 |
|
58 |
// Necessary delay in order all dom elements to be created
|
59 |
Thread.sleep(4000); |
60 |
} |
61 |
|
62 |
/**
|
63 |
* @throws java.lang.Exception
|
64 |
*/
|
65 |
@After
|
66 |
public void tearDown() throws Exception { |
67 |
action.quit(); |
68 |
} |
69 |
|
70 |
// @Test
|
71 |
public void createNewGroup() throws InterruptedException{ |
72 |
|
73 |
action.click(By.id(userName)); |
74 |
|
75 |
Thread.sleep(1000); |
76 |
|
77 |
//Select Group option from top menu
|
78 |
action.click(By.id("topMenu.group"));
|
79 |
|
80 |
Thread.sleep(1000); |
81 |
|
82 |
//Select New Group option
|
83 |
action.click(By.id("topMenu.group.newGroup"));
|
84 |
|
85 |
Thread.sleep(1000); |
86 |
|
87 |
//type the group name in the input box of the group dialog
|
88 |
action.type(By.id("groupDialog.textBox.name"), groupName);
|
89 |
|
90 |
//click ok button
|
91 |
action.click(By.id("groupDialog.button.ok"));
|
92 |
|
93 |
Thread.sleep(2000); |
94 |
|
95 |
//assert that the newly created group has been created
|
96 |
Assert.assertEquals(groupName, action.getText(By.id("groupsList."+groupName)));
|
97 |
// action.click(By.id("permissionsList."+groupName));
|
98 |
|
99 |
} |
100 |
|
101 |
public void selectGroupsTab(){ |
102 |
//select the Group tab
|
103 |
action.click(By.id("Groups"));
|
104 |
} |
105 |
|
106 |
public void selectOneGroup(String aGroupName){ |
107 |
selectGroupsTab(); |
108 |
|
109 |
action.click(By.id("groupsList." + aGroupName));
|
110 |
} |
111 |
|
112 |
public void deleteGroup(String aGroupName) throws InterruptedException{ |
113 |
|
114 |
selectOneGroup(aGroupName); |
115 |
|
116 |
//right click on the groupName
|
117 |
//TODO: Problem on displaying the context menu
|
118 |
/**
|
119 |
* NOTES: Context menu denies to be displayed
|
120 |
* Unsuccessful scenarios:
|
121 |
* id placed in:
|
122 |
*
|
123 |
* 1.addImageItem() method
|
124 |
* TreeItem item = new TreeItem();
|
125 |
* Widget aWidget = imageItemHTML(imageProto, title,item);
|
126 |
* aWidget.getElement().setId("groupsList."+title);
|
127 |
* item.setWidget(aWidget);
|
128 |
*
|
129 |
* 2.imageItemHTML either in <a id =""></a> or in <span id=""></span>
|
130 |
*
|
131 |
* 3. changed the HTML link to
|
132 |
* final HTML link = new HTML("<span id='groupsList."+title+"'>"+AbstractImagePrototype.create(imageProto).getHTML() + " " + title + "</span>"){
|
133 |
* or to
|
134 |
* final HTML link = new HTML(AbstractImagePrototype.create(imageProto).getHTML() +"<span id='groupsList."+title+"'>" + " " + title + "</span>"){
|
135 |
*
|
136 |
* 4. TODO: addKeyDown/keyUpHandler or catch the events the webDriver creates in the imageItemHTML
|
137 |
|
138 |
*/
|
139 |
|
140 |
action.sendRightClick(By.id("groupsList.tree"));
|
141 |
|
142 |
//select 'Delete' option from right click context menu
|
143 |
action.click(By.id("groupContextMenu.delete"));
|
144 |
|
145 |
//click ok
|
146 |
action.click(By.id("deleteGroup.button.ok"));
|
147 |
|
148 |
} |
149 |
|
150 |
@Test
|
151 |
// (expected=org.openqa.selenium.NoSuchElementException.class)
|
152 |
public void testDeleteGroup() throws InterruptedException{ |
153 |
|
154 |
deleteGroup(groupName); |
155 |
//TODO: test assertion
|
156 |
// Assert.assertEquals(groupName, action.getText(By.id("groupsList."+groupName)));
|
157 |
|
158 |
} |
159 |
|
160 |
public void addUserToGroup(String aGroupName, String aUserName) throws InterruptedException{ |
161 |
//select an existing group
|
162 |
action.click(By.id("groupsList." + aGroupName));
|
163 |
|
164 |
//right click on it
|
165 |
//TODO: Problem on displaying the context menu
|
166 |
action.sendRightClick(By.id("groupsList."+groupName));
|
167 |
|
168 |
Thread.sleep(1000); |
169 |
|
170 |
//select 'Add User' option from right click context menu
|
171 |
action.click(By.id("groupContextMenu.addUser"));
|
172 |
|
173 |
//type a username
|
174 |
action.type(By.id("addUser.textBox"), aUserName);
|
175 |
|
176 |
//click ok
|
177 |
action.click(By.id("deleteGroup.button.ok"));
|
178 |
} |
179 |
|
180 |
// @Test
|
181 |
public void testAddUserToGroup() throws InterruptedException{ |
182 |
selectGroupsTab(); |
183 |
|
184 |
Thread.sleep(1000); |
185 |
|
186 |
addUserToGroup(groupName, addUserName); |
187 |
|
188 |
//TODO: test assert addition
|
189 |
Assert.assertEquals(groupName, action.getText(By.id("groupsList."+groupName)));
|
190 |
} |
191 |
|
192 |
} |