My favorites | Sign in
Project Home Downloads Wiki Issues Source
Checkout   Browse   Changes    
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
/*
Copyright 2011 Selenium committers

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package org.openqa.selenium.interactions.touch;

import org.openqa.selenium.HasInputDevices;
import org.openqa.selenium.HasTouchScreen;
import org.openqa.selenium.Keyboard;
import org.openqa.selenium.TouchScreen;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.interactions.Actions;
import org.openqa.selenium.internal.Locatable;

/**
* Implements actions for touch enabled devices, reusing the available composite and builder design
* patterns from Actions.
*/
public class TouchActions extends Actions {

protected TouchScreen touchScreen;

public TouchActions(WebDriver driver) {
this(((HasInputDevices) driver).getKeyboard(),
((HasTouchScreen) driver).getTouch());
}

public TouchActions(Keyboard keyboard, TouchScreen touchScreen) {
super(keyboard);
this.touchScreen = touchScreen;
}

public TouchActions singleTap(WebElement onElement) {
action.addAction(new SingleTapAction(touchScreen, (Locatable) onElement));
return this;
}

public TouchActions down(int x, int y) {
action.addAction(new DownAction(touchScreen, x, y));
return this;
}

public TouchActions up(int x, int y) {
action.addAction(new UpAction(touchScreen, x, y));
return this;
}

public TouchActions move(int x, int y) {
action.addAction(new MoveAction(touchScreen, x, y));
return this;
}

public TouchActions scroll(WebElement onElement, int xOffset, int yOffset) {
action.addAction(new ScrollAction(touchScreen, (Locatable) onElement, xOffset, yOffset));
return this;
}

public TouchActions doubleTap(WebElement onElement) {
action.addAction(new DoubleTapAction(touchScreen, (Locatable) onElement));
return this;
}

public TouchActions longPress(WebElement onElement) {
action.addAction(new LongPressAction(touchScreen, (Locatable) onElement));
return this;
}

public TouchActions scroll(int xOffset, int yOffset) {
action.addAction(new ScrollAction(touchScreen, xOffset, yOffset));
return this;
}

public TouchActions flick(int xSpeed, int ySpeed) {
action.addAction(new FlickAction(touchScreen, xSpeed, ySpeed));
return this;
}

public TouchActions flick(WebElement onElement, int xOffset, int yOffset, int speed) {
action.addAction(new FlickAction(touchScreen, (Locatable) onElement, xOffset, yOffset, speed));
return this;
}
}

Change log

r16915 by simon.m.stewart on May 14, 2012   Diff
SimonStewart: We haven't been just the
webdriver project for a long time. We are
now the selenium project. No logical
changes.
Go to: 
Sign in to write a code review

Older revisions

r16908 by simon.m.stewart on May 14, 2012   Diff
SimonStewart: After a code grant, the
code is copyright the SFC and the
selenium committers. Starting to
update the copyright headers
r13565 by dawagner on Aug 24, 2011   Diff
DanielWagnerHall: Bulk reformatting.
Some changes may not be perfect; feel
free to update if you disagree.
r13474 by berr...@google.com on Aug 19, 2011   Diff
DouniaBerrada: On behalf of
JuanTrujillo, submitting flick for
touch enabled deviced and its android
implementation.
All revisions of this file

File info

Size: 2982 bytes, 95 lines
Powered by Google Project Hosting