Revision 1016f160 test/gr/ebs/gss/client/selenium/tests/FileUtils.java

b/test/gr/ebs/gss/client/selenium/tests/FileUtils.java
19 19
package gr.ebs.gss.client.selenium.tests;
20 20

  
21 21

  
22
import java.awt.AWTException;
23
import java.awt.Robot;
24
import java.awt.event.KeyEvent;
25

  
22 26
import org.openqa.selenium.By;
23 27

  
24 28

  
25 29
public class FileUtils extends GeneralPurposeUtils{
26 30

  
27
	public void clickAFile(String aFileName){		
28
		action.click(By.id("fileList."+ aFileName));
29
	}
30

  
31 31
	public void rightClickOnFile(String aFileName){
32 32
		action.sendRightClick(By.id("fileList." + aFileName));
33 33
		
......
37 37
		action.click(By.id("fileContextMenu." + anOption));
38 38
	}
39 39
	
40
	/**
41
	 * TODO: Download a file below in a folder
42
	 * > select a file
43
	 * > select File > 'Download'
44
	 * > save file from the popup window to your hdd
45
	 * 	
46
	 */
47
	
48
	public void downloadFile() throws InterruptedException{
40

  
41
	public void downloadFile() throws InterruptedException, AWTException{
49 42
		selectTopMenu("file");
50 43
		
51 44
		Thread.sleep(1000);
52 45
		
53 46
		selectAnOptionInTopMenu("file","download");
54 47
		
55
		selectConfirmation("ok");
48
		/**
49
		 * TODO: Solve the problem of not opening the dialog boxes
50
		 */
51
		Thread.sleep(3000);
52
		Robot robot = new Robot();
53
		//Alt + S to select save 
54
		robot.keyPress(KeyEvent.VK_ALT);
55
		robot.keyPress(KeyEvent.VK_S);
56
		robot.keyRelease(KeyEvent.VK_ALT);
57
		System.out.println("window = " + driver.getWindowHandle());
58
		Thread.sleep(3000);
59
		//Then press enter
60
		robot.keyPress(KeyEvent.VK_ENTER);
61
			
62
		// and save the file in the indicated location 
63
		// using Alt + S
64
		robot.keyPress(KeyEvent.VK_ALT);
65
		robot.keyPress(KeyEvent.VK_S);
66
		robot.keyPress(KeyEvent.VK_S);
67
		robot.keyRelease(KeyEvent.VK_ALT); 
68
		
69
		
70
		
71
		Thread.sleep(3000);
72
		//TODO: confirm download - how??
56 73
	}
57 74

  
58 75
	
59
	/** TODO: Save As Assert
76
	/**
60 77
	 * This action performs the same results to the above 'Download' option
61 78
	 */
62 79
	
......
67 84
		
68 85
		selectAnOptionInTopMenu("file","saveAs");
69 86
		
87
		//TODO: confirm save As - how??
88
		
70 89
	}
71
	/**
72
	 * TODO: assert somehow
73
	 * @param aUserName
74
	 * @param aFolderName
75
	 * @param aFileName
76
	 */
90

  
77 91
	public void refreshFile(String aUserName, String aFolderName, String aFileName){		
78 92
		selectFolderBelowHome(aUserName, aFolderName);
79 93
		
80
		clickAFile(aFileName);
94
		selectFile(aFileName);
81 95
		
82 96
		//Click top edit menu
83 97
		selectTopMenu("file");
......
85 99
		//Click move to trash option
86 100
		selectAnOptionInTopMenu("file","refresh");
87 101
		
102
		//TODO: confirm refresh
103
		
88 104
	}
89 105

  
90
	/**
91
	 * TODO: . Cut file
92
	 * > select a file
93
	 * > select Edit > 'Cut'
94
	 * > select a destination folder
95
	 * > click Edit > Paste on the destination folder 
96
	 */
97 106
	public void cutFile(String aFileName){
98 107
		
99 108
		//Click a file
100
		clickAFile(aFileName);
109
		selectFile(aFileName);
101 110
				
102 111
		//Click the top file menu
103 112
		selectTopMenu("edit");		
......
107 116
				
108 117
	}
109 118
	
110
	/** TODO: . Copy file
111
	 * > select a file
112
	 * > select Edit > 'Copy'
113
	 * > select a destination folder
114
	 * > click Edit > 'Paste' on the destination folder
115
	 * 
116
	 */
117 119
	public void copyFile(String aFileName){
118 120
		
119 121
		//Click a file
120
		clickAFile(aFileName);
122
		selectFile(aFileName);
121 123
				
122 124
		//Click the top file menu
123 125
		selectTopMenu("edit");		
......
134 136
	 */
135 137
	public void pasteFile(String aUserName, String aFolderDestination, String aFileName){
136 138
		//Click a file
137
		clickAFile(aFileName);
139
		selectFile(aFileName);
138 140
		
139 141
		//Click on the folder destination which is below home folder
140 142
		selectFolderBelowHome(aUserName, aFolderDestination);
......
145 147
		//Click the New Folder option from the file menu
146 148
		selectAnOptionInTopMenu("edit","paste");
147 149
		
150
		/**
151
		 * TODO: expand the folder that paste option was performed
152
		 * and confirm the existence of the file
153
		 */
154
		
148 155
	}
149
	   
150
	/** TODO: . Move to Trash
151
	 * > select a file
152
	 * > select Edit > 'Move to Trash'
153
	 * > select Trash folder and your file is in the Trash
154
	 */
155
	
156
	   	
156 157
	public void moveToTrashFile(String aFileName){
157 158
		
158 159
		//Click a file
159
		clickAFile(aFileName);
160
		selectFile(aFileName);
160 161
				
161 162
		//Click the top file menu
162 163
		selectTopMenu("edit");		
163 164
		
164 165
		//Click the New Folder option from the file menu
165 166
		selectAnOptionInTopMenu("edit","moveToTrash");
167
		
168
		/**
169
		 * TODO: expand Trash and confirm the existence of the file
170
		 */
166 171
				
167 172
	}
168
	/**. Delete
169
	 * > select a file
170
	 * > select Edit > 'Move to Trash'
171
	 * > click Delete to confirm
172
	 * */
173 173
	
174 174
	public void deleteFile(String aFileName) throws InterruptedException{
175 175
		
176
		clickAFile(aFileName);
176
		selectFile(aFileName);
177 177
		
178 178
		selectTopMenu("edit");		
179 179
					
......
183 183
		
184 184
		//Click ok button in the confirmation dialog box
185 185
		selectConfirmation("ok");
186
		
187
		/**
188
		 * TODO: assert deletion
189
		 */	
186 190
	
187 191
	}
188

  
189
	/** TODO:. Select All
190
	 * > select a file
191
	 * > select Edit > 'Select All' this action results to select all files that are inside home folder
192
	 */
192
	
193 193
	public void selectAllFile(String aFileName) throws InterruptedException{
194 194
		
195
		clickAFile(aFileName);
195
		selectFile(aFileName);
196 196
		
197 197
		selectTopMenu("edit");		
198 198
					
......
200 200
		selectAnOptionInTopMenu("edit","selectAll");
201 201
		Thread.sleep(1000);
202 202
		
203
		/**
204
		 * TODO: assert 
205
		 */	
206
		
203 207
	}
204 208
	   
205
	/** TODO:. Unselect All
206
	 * > select a file
207
	 * > select Edit > 'Unselect All'     this action results to unselect all files that are inside home folder
208
	 */
209 209
	public void unSelectAllFile(String aFileName) throws InterruptedException{
210 210
		
211
		clickAFile(aFileName);
211
		selectFile(aFileName);
212 212
		
213 213
		selectTopMenu("edit");		
214 214
					
......
216 216
		selectAnOptionInTopMenu("edit","unSelectAll");
217 217
		Thread.sleep(1000);
218 218
		
219
		/**
220
		 * TODO: assert 
221
		 */			
219 222
	}
220 223

  
221 224
}

Also available in: Unified diff