18
18
package org .openqa .selenium .interactions .touch ;
19
19
20
20
import org .junit .Test ;
21
- import org .openqa .selenium .By ;
22
- import org .openqa .selenium .NeedsFreshDriver ;
23
- import org .openqa .selenium .WebDriver ;
24
- import org .openqa .selenium .WebElement ;
21
+ import org .openqa .selenium .*;
25
22
import org .openqa .selenium .interactions .Action ;
26
23
import org .openqa .selenium .testing .Ignore ;
27
24
28
25
import static org .junit .Assert .assertTrue ;
29
- import static org .openqa .selenium .testing .Ignore .Driver .ANDROID ;
30
- import static org .openqa .selenium .testing .Ignore .Driver .OPERA ;
31
- import static org .openqa .selenium .testing .Ignore .Driver .OPERA_MOBILE ;
26
+ import static org .openqa .selenium .testing .Ignore .Driver .*;
32
27
33
28
/**
34
29
* Tests the basic flick operations on touch enabled devices.
@@ -40,6 +35,7 @@ private TouchActions getBuilder(WebDriver driver) {
40
35
return new TouchActions (driver );
41
36
}
42
37
38
+ @ Ignore (QTWEBKIT )
43
39
@ NeedsFreshDriver
44
40
@ Test
45
41
public void testCanFlickHorizontallyFromWebElement () {
@@ -61,6 +57,7 @@ public void testCanFlickHorizontallyFromWebElement() {
61
57
assertTrue ("Expected x < 1500, but got x = " + x , x < 1500 );
62
58
}
63
59
60
+ @ Ignore (QTWEBKIT )
64
61
@ NeedsFreshDriver
65
62
@ Test
66
63
public void testCanFlickHorizontallyFastFromWebElement () {
@@ -81,6 +78,7 @@ public void testCanFlickHorizontallyFastFromWebElement() {
81
78
assertTrue ("Expected x < 3500, but got: " + x , x < 3500 );
82
79
}
83
80
81
+ @ Ignore (QTWEBKIT )
84
82
@ NeedsFreshDriver
85
83
@ Test
86
84
public void testCanFlickHorizontally () {
@@ -100,7 +98,7 @@ public void testCanFlickHorizontally() {
100
98
assertTrue ("Expected x < 1500, but got x = " + x , x < 1500 );
101
99
}
102
100
103
- @ Ignore (value = {ANDROID },
101
+ @ Ignore (value = {ANDROID , QTWEBKIT },
104
102
reason = "Android flick's can result in different offsets" )
105
103
@ NeedsFreshDriver
106
104
@ Test
@@ -120,6 +118,7 @@ public void testCanFlickHorizontallyFast() {
120
118
assertTrue ("Got: " + x , x < 3000 );
121
119
}
122
120
121
+ @ Ignore (QTWEBKIT )
123
122
@ NeedsFreshDriver
124
123
@ Test
125
124
public void testCanFlickVerticallyFromWebElement () {
@@ -140,6 +139,7 @@ public void testCanFlickVerticallyFromWebElement() {
140
139
assertTrue ("Expected y < 4000, but got: " + y , y < 4000 );
141
140
}
142
141
142
+ @ Ignore (QTWEBKIT )
143
143
@ NeedsFreshDriver
144
144
@ Test
145
145
public void testCanFlickVerticallyFastFromWebElement () {
@@ -160,6 +160,7 @@ public void testCanFlickVerticallyFastFromWebElement() {
160
160
assertTrue ("Expected y < 8700, but got: " + y , y < 8700 );
161
161
}
162
162
163
+ @ Ignore (QTWEBKIT )
163
164
@ NeedsFreshDriver
164
165
@ Test
165
166
public void testCanFlickVertically () {
@@ -179,6 +180,7 @@ public void testCanFlickVertically() {
179
180
assertTrue ("Got: " + y , y < 4200 );
180
181
}
181
182
183
+ @ Ignore (QTWEBKIT )
182
184
@ NeedsFreshDriver
183
185
@ Test
184
186
public void testCanFlickVerticallyFast () {
@@ -197,4 +199,161 @@ public void testCanFlickVerticallyFast() {
197
199
assertTrue ("Got: " + y , y < 4000 );
198
200
}
199
201
202
+ @ NeedsFreshDriver
203
+ @ Test
204
+ public void testCanFlickHorizontallyFromWebElementQt () {
205
+ driver .get (pages .longContentPage );
206
+
207
+ WebElement toFlick = driver .findElement (By .id ("imagestart" ));
208
+ WebElement link = driver .findElement (By .id ("link1" ));
209
+ int x = link .getLocation ().x ;
210
+ // The element is located at the right of the page,
211
+ // so it is not initially visible on the screen.
212
+ assertTrue ("Expected x > 1500, but got x = " + x , x > 1500 );
213
+
214
+ Action flick = getBuilder (driver ).flick (toFlick , -1000 , 0 , FlickAction .SPEED_NORMAL )
215
+ .build ();
216
+ flick .perform ();
217
+
218
+ x = ((Long )((JavascriptExecutor ) driver ).executeScript ("return document.body.scrollLeft" )).intValue ();
219
+ //If speed normal we scroll xoffset pixel
220
+ assertTrue ("Expected x == 1000, but got x = " + x , x == 1000 );
221
+ }
222
+
223
+ @ NeedsFreshDriver
224
+ @ Test
225
+ public void testCanFlickHorizontallyFastFromWebElementQt () {
226
+ driver .get (pages .longContentPage );
227
+
228
+ WebElement toFlick = driver .findElement (By .id ("imagestart" ));
229
+ WebElement link = driver .findElement (By .id ("link2" ));
230
+ int x = link .getLocation ().x ;
231
+ // The element is located at the right of the page,
232
+ // so it is not initially visible on the screen.
233
+ assertTrue (x > 3500 );
234
+
235
+ Action flick = getBuilder (driver ).flick (toFlick , -400 , 0 , FlickAction .SPEED_FAST )
236
+ .build ();
237
+ flick .perform ();
238
+ x = ((Long )((JavascriptExecutor ) driver ).executeScript ("return document.body.scrollLeft" )).intValue ();
239
+ //If speed fast we scroll 2*xoffset pixel
240
+ assertTrue ("Expected x == 800, but got: " + x , x == 800 );
241
+ }
242
+
243
+ @ NeedsFreshDriver
244
+ @ Test
245
+ public void testCanFlickHorizontallyQt () {
246
+ driver .get (pages .clicksPage );
247
+ driver .get (pages .longContentPage );
248
+
249
+ WebElement link = driver .findElement (By .id ("link1" ));
250
+ int x = link .getLocation ().x ;
251
+ // The element is located at the right of the page,
252
+ // so it is not initially visible on the screen.
253
+ assertTrue ("Expected x == 1500, but got x = " + x , x > 1500 );
254
+
255
+ Action flick = getBuilder (driver ).flick (200 , 0 ).build ();
256
+ flick .perform ();
257
+ x = ((Long )((JavascriptExecutor ) driver ).executeScript ("return document.body.scrollLeft" )).intValue ();
258
+ //Scroll 3*xspeed pixel
259
+ assertTrue ("Expected x == 600, but got x = " + x , x == 600 );
260
+ }
261
+
262
+ @ Ignore (value = {ANDROID },
263
+ reason = "Android flick's can result in different offsets" )
264
+ @ NeedsFreshDriver
265
+ @ Test
266
+ public void testCanFlickHorizontallyFastQt () {
267
+ driver .get (pages .longContentPage );
268
+
269
+ WebElement link = driver .findElement (By .id ("link2" ));
270
+ int x = link .getLocation ().x ;
271
+ // The element is located at the right of the page,
272
+ // so it is not initially visible on the screen.
273
+ assertTrue (x > 3500 );
274
+
275
+ Action flick = getBuilder (driver ).flick (750 , 0 ).build ();
276
+ flick .perform ();
277
+ x = ((Long )((JavascriptExecutor ) driver ).executeScript ("return document.body.scrollLeft" )).intValue ();
278
+ //Scroll 3*xspeed pixel
279
+ assertTrue ("Got: " + x , x == 2250 );
280
+ }
281
+
282
+ @ NeedsFreshDriver
283
+ @ Test
284
+ public void testCanFlickVerticallyFromWebElementQt () {
285
+ driver .get (pages .longContentPage );
286
+
287
+ WebElement link = driver .findElement (By .id ("link3" ));
288
+ int y = link .getLocation ().y ;
289
+ // The element is located at the bottom of the page,
290
+ // so it is not initially visible on the screen.
291
+ assertTrue (y > 4200 );
292
+
293
+ WebElement toFlick = driver .findElement (By .id ("imagestart" ));
294
+ Action flick = getBuilder (driver ).flick (toFlick , 0 , -600 , FlickAction .SPEED_NORMAL )
295
+ .build ();
296
+ flick .perform ();
297
+ y = ((Long )((JavascriptExecutor ) driver ).executeScript ("return document.body.scrollTop" )).intValue ();
298
+ //If speed normal we scroll yoffset pixel
299
+ assertTrue ("Expected y == 600, but got: " + y , y == 600 );
300
+ }
301
+
302
+ @ NeedsFreshDriver
303
+ @ Test
304
+ public void testCanFlickVerticallyFastFromWebElementQt () {
305
+ driver .get (pages .longContentPage );
306
+
307
+ WebElement link = driver .findElement (By .id ("link4" ));
308
+ int y = link .getLocation ().y ;
309
+ // The element is located at the bottom of the page,
310
+ // so it is not initially visible on the screen.
311
+ assertTrue (y > 8700 );
312
+
313
+ WebElement toFlick = driver .findElement (By .id ("imagestart" ));
314
+ Action flick = getBuilder (driver ).flick (toFlick , 0 , -600 , FlickAction .SPEED_FAST )
315
+ .build ();
316
+ flick .perform ();
317
+ y = ((Long )((JavascriptExecutor ) driver ).executeScript ("return document.body.scrollTop" )).intValue ();
318
+ //If speed normal we scroll 2*yoffset pixel
319
+ assertTrue ("Expected y == 1200, but got: " + y , y == 1200 );
320
+ }
321
+
322
+ @ NeedsFreshDriver
323
+ @ Test
324
+ public void testCanFlickVerticallyQt () {
325
+ driver .get (pages .longContentPage );
326
+
327
+ WebElement link = driver .findElement (By .id ("link3" ));
328
+ int y = link .getLocation ().y ;
329
+ // The element is located at the bottom of the page,
330
+ // so it is not initially visible on the screen.
331
+ assertTrue (y > 4200 );
332
+
333
+ Action flick = getBuilder (driver ).flick (0 , 750 ).build ();
334
+ flick .perform ();
335
+ y = ((Long )((JavascriptExecutor ) driver ).executeScript ("return document.body.scrollTop" )).intValue ();
336
+
337
+ //Scroll 3*yspeed pixel
338
+ assertTrue ("Got: " + y , y == 2250 );
339
+ }
340
+
341
+ @ NeedsFreshDriver
342
+ @ Test
343
+ public void testCanFlickVerticallyFastQt () {
344
+ driver .get (pages .longContentPage );
345
+
346
+ WebElement link = driver .findElement (By .id ("link4" ));
347
+ int y = link .getLocation ().y ;
348
+ // The element is located at the bottom of the page,
349
+ // so it is not initially visible on the screen.
350
+ assertTrue (y > 8700 );
351
+
352
+ Action flick = getBuilder (driver ).flick (0 , 1500 ).build ();
353
+ flick .perform ();
354
+ y = ((Long )((JavascriptExecutor ) driver ).executeScript ("return document.body.scrollTop" )).intValue ();
355
+ //Scroll 3*yspeed pixel
356
+ assertTrue ("Got: " + y , y == 4500 );
357
+ }
358
+
200
359
}
0 commit comments