root / test / org / gss_project / gss / web / client / selenium / tests / FolderUtils.java @ 1205:fbeae20462e6
History | View | Annotate | Download (7 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 |
import java.awt.AWTException; |
22 |
import java.awt.Robot; |
23 |
import java.awt.event.KeyEvent; |
24 |
|
25 |
import org.junit.Test; |
26 |
import org.openqa.selenium.By; |
27 |
import org.openqa.selenium.Keys; |
28 |
import org.openqa.selenium.WebElement; |
29 |
|
30 |
|
31 |
public class FolderUtils extends GeneralPurposeUtils{ |
32 |
|
33 |
public String expandTree(){ |
34 |
WebElement element = driver.findElement(By.xpath("//span[@id='lakis@ebs.gr.hasta luego']/../../div[1]"));
|
35 |
String res = element.getAttribute("style"); |
36 |
return res;
|
37 |
} |
38 |
|
39 |
public void expandFolder(){ |
40 |
driver.findElement(By.xpath("//span[@id='lakis@ebs.gr.hasta luego']/../../div[1]")).click();
|
41 |
|
42 |
} |
43 |
|
44 |
/**
|
45 |
* Methods thats sends right click to the selected folder
|
46 |
* @param aUserName
|
47 |
* @param aFolderName
|
48 |
*/
|
49 |
|
50 |
public void rightClickOnFolder(String aUserName, String aFolderName){ |
51 |
System.out.println("userName = " +aUserName); |
52 |
System.out.println("folderName = " +aFolderName); |
53 |
action.sendRightClick(By.id(aUserName+ "." + aFolderName));
|
54 |
|
55 |
|
56 |
} |
57 |
|
58 |
public void selectFolderContextMenuOption(String anOption){ |
59 |
action.click(By.id("folderContextMenu." + anOption));
|
60 |
} |
61 |
|
62 |
/**
|
63 |
* Create a new folder under the root folder
|
64 |
* @param aFolderName
|
65 |
* @throws InterruptedException
|
66 |
*/
|
67 |
public void makeNewFolder(String aUserName, String aFolderName) throws InterruptedException{ |
68 |
//Click the home folder
|
69 |
selectHomeFolder(aUserName); |
70 |
|
71 |
//Click the top file menu
|
72 |
selectTopMenu("file");
|
73 |
|
74 |
Thread.sleep(1000); |
75 |
|
76 |
//Click the New Folder option from the file menu
|
77 |
selectAnOptionInTopMenu("file","newFolder"); |
78 |
|
79 |
Thread.sleep(1000); |
80 |
|
81 |
//In the popup dialog click on the Name textBox and type the folder name
|
82 |
//action.type(By.id("folderPropertiesDialog.textBox.name"), aFolderName);
|
83 |
typeInFolderPropertiesDialog("textBox.name", aFolderName);
|
84 |
|
85 |
//Submit
|
86 |
selectElementFromFolderPropertiesDialog("button.ok");
|
87 |
//action.click(By.id("folderPropertiesDialog.button.ok"));
|
88 |
|
89 |
} |
90 |
|
91 |
/**
|
92 |
* Delete a folder with the given folderName
|
93 |
* that lies below the root folder
|
94 |
*
|
95 |
* @param aFolderName
|
96 |
* @throws InterruptedException
|
97 |
*/
|
98 |
public void deleteFolder(String aUserName, String aFolderName) throws InterruptedException{ |
99 |
//Click the home folder
|
100 |
selectFolderBelowHome(aUserName, aFolderName); |
101 |
|
102 |
selectTopMenu("edit");
|
103 |
|
104 |
//Click move to trash option
|
105 |
selectAnOptionInTopMenu("edit","delete"); |
106 |
Thread.sleep(1000); |
107 |
|
108 |
//Click ok button in the confirmation dialog box
|
109 |
selectConfirmation("ok");
|
110 |
|
111 |
} |
112 |
/**
|
113 |
* Moving a folder which lies under the root folder to trash folder
|
114 |
*
|
115 |
* @param aFolderName
|
116 |
*/
|
117 |
public void moveToTrash(String aUserName, String aFolderName){ |
118 |
//Click the home folder
|
119 |
selectFolderBelowHome(aUserName, aFolderName); |
120 |
|
121 |
//Click top edit menu
|
122 |
selectTopMenu("edit");
|
123 |
|
124 |
//Click move to trash option
|
125 |
selectAnOptionInTopMenu("edit","moveToTrash"); |
126 |
|
127 |
} |
128 |
|
129 |
public void refresh(String aUserName, String aFolderName){ |
130 |
selectFolderBelowHome(aUserName, aFolderName); |
131 |
|
132 |
//Click top edit menu
|
133 |
selectTopMenu("file");
|
134 |
|
135 |
//Click move to trash option
|
136 |
selectAnOptionInTopMenu("file","refresh"); |
137 |
|
138 |
} |
139 |
|
140 |
//TODO: upload file to a folder
|
141 |
public void upload() throws AWTException{ |
142 |
action.click(By.id("fileUploadDiallog.uploadPanel"));
|
143 |
|
144 |
Robot robot = new Robot(); |
145 |
robot.keyPress(KeyEvent.VK_ALT);
|
146 |
robot.keyPress(KeyEvent.VK_S);
|
147 |
robot.keyRelease(KeyEvent.VK_ALT);
|
148 |
|
149 |
//<button type="button" class="gwt-Button">Browse...</button>
|
150 |
|
151 |
/**
|
152 |
* /home/Desktop/links.txt
|
153 |
*/
|
154 |
|
155 |
} |
156 |
@Test
|
157 |
public void testUpload() throws InterruptedException{ |
158 |
selectFolderBelowHome(userName, folderName); |
159 |
selectTopMenu("file");
|
160 |
Thread.sleep(1000); |
161 |
selectAnOptionInTopMenu("file","upload"); |
162 |
action.click(By.id("fileUploadDiallog.uploadPanel"));
|
163 |
Thread.sleep(5000); |
164 |
|
165 |
} |
166 |
|
167 |
/**
|
168 |
* Method that cuts a folder below home folder
|
169 |
* using the top Edit menu
|
170 |
* @param aUserName
|
171 |
*/
|
172 |
public void cutFolder(String aUserName, String aFolderName){ |
173 |
|
174 |
//Click a folder
|
175 |
selectFolderBelowHome(aUserName, aFolderName); |
176 |
|
177 |
//Click the top file menu
|
178 |
selectTopMenu("edit");
|
179 |
|
180 |
//Click the New Folder option from the file menu
|
181 |
selectAnOptionInTopMenu("edit","cut"); |
182 |
|
183 |
} |
184 |
|
185 |
/**
|
186 |
* Method that copies a folder name
|
187 |
* @param aUserName
|
188 |
* @param aFolderName
|
189 |
*/
|
190 |
public void copy(String aUserName, String aFolderName){ |
191 |
//Click a folder
|
192 |
selectFolderBelowHome(aUserName, aFolderName); |
193 |
|
194 |
//Click the top file menu
|
195 |
selectTopMenu("edit");
|
196 |
|
197 |
//Click the New Folder option from the file menu
|
198 |
selectAnOptionInTopMenu("edit","copy"); |
199 |
|
200 |
} |
201 |
|
202 |
/**
|
203 |
* Method that pastes a folder of a user using @param aUserName
|
204 |
* to a @param aFolderDestination
|
205 |
*/
|
206 |
public void paste(String aUserName, String aFolderDestination){ |
207 |
//Click on the folder destination which is below home folder
|
208 |
selectFolderBelowHome(aUserName, aFolderDestination); |
209 |
|
210 |
//Click the top file menu
|
211 |
selectTopMenu("edit");
|
212 |
|
213 |
//Click the New Folder option from the file menu
|
214 |
selectAnOptionInTopMenu("edit","paste"); |
215 |
|
216 |
} |
217 |
|
218 |
/**
|
219 |
* Method that clicks on the folder and the from the top menu File > Properties
|
220 |
*
|
221 |
* @param aUserName
|
222 |
* @param aFolderName
|
223 |
* @throws InterruptedException
|
224 |
*/
|
225 |
public void clickFolderProperties(String aUserName, String aFolderName) throws InterruptedException{ |
226 |
//Click on a folder
|
227 |
selectFolderBelowHome(aUserName, aFolderName); |
228 |
|
229 |
selectTopMenu("file");
|
230 |
|
231 |
Thread.sleep(1000); |
232 |
|
233 |
selectAnOptionInTopMenu("file","properties"); |
234 |
|
235 |
Thread.sleep(1000); |
236 |
} |
237 |
|
238 |
public void clickFolderSharing(String aUserName, String aFolderName) throws InterruptedException{ |
239 |
//Click on a folder
|
240 |
selectFolderBelowHome(aUserName, aFolderName); |
241 |
|
242 |
selectTopMenu("file");
|
243 |
|
244 |
Thread.sleep(1000); |
245 |
|
246 |
selectAnOptionInTopMenu("file","sharing"); |
247 |
Thread.sleep(1000); |
248 |
} |
249 |
|
250 |
|
251 |
|
252 |
// @Test
|
253 |
public void testRightClickOnFolder1() throws InterruptedException{ |
254 |
action.click(By.id(userName+ "." + folderName));
|
255 |
|
256 |
|
257 |
System.out.println("userName = " +userName); |
258 |
System.out.println("folderName = " +folderName); |
259 |
|
260 |
Thread.sleep(1000); |
261 |
|
262 |
WebElement element = driver.findElement(By.id(userName+ "." + folderName));
|
263 |
element.sendKeys(Keys.chord(Keys.SHIFT,Keys.F10)); |
264 |
Thread.sleep(2000); |
265 |
// action.sendRightClick(By.id(userName+ "." + folderName));
|
266 |
|
267 |
action.click(By.id("folderContextMenu.newFolder"));
|
268 |
|
269 |
Thread.sleep(1000); |
270 |
} |
271 |
|
272 |
|
273 |
|
274 |
} |