Skip to content

Commit ce2ca86

Browse files
committed
Merge pull request #163 from TikhomirovSergey/swipeEnhancement
#160 fix
2 parents 7d3dc11 + 3a07643 commit ce2ca86

File tree

6 files changed

+598
-395
lines changed

6 files changed

+598
-395
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package io.appium.java_client;
2+
3+
import org.openqa.selenium.WebDriverException;
4+
5+
public class IllegalCoordinatesException extends WebDriverException {
6+
private static final long serialVersionUID = 1L;
7+
8+
public IllegalCoordinatesException(String message) {
9+
super(message);
10+
}
11+
12+
}
Original file line numberDiff line numberDiff line change
@@ -1,75 +1,82 @@
1-
/*
2-
+Copyright 2014 Appium contributors
3-
+Copyright 2014 Software Freedom Conservancy
4-
+
5-
+Licensed under the Apache License, Version 2.0 (the "License");
6-
+you may not use this file except in compliance with the License.
7-
+You may obtain a copy of the License at
8-
+
9-
+ http://www.apache.org/licenses/LICENSE-2.0
10-
+
11-
+Unless required by applicable law or agreed to in writing, software
12-
+distributed under the License is distributed on an "AS IS" BASIS,
13-
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14-
+See the License for the specific language governing permissions and
15-
+limitations under the License.
16-
+ */
17-
18-
package io.appium.java_client;
19-
20-
import org.openqa.selenium.By;
21-
import org.openqa.selenium.Dimension;
22-
import org.openqa.selenium.Point;
23-
import org.openqa.selenium.WebElement;
24-
import org.openqa.selenium.remote.FileDetector;
25-
import org.openqa.selenium.remote.RemoteWebElement;
26-
27-
import java.util.List;
28-
29-
public abstract class MobileElement extends RemoteWebElement implements FindsByAccessibilityId, TouchableElement {
30-
31-
protected FileDetector fileDetector;
32-
33-
public List<WebElement> findElements(By by) {
34-
return by.findElements(this);
35-
}
36-
37-
public WebElement findElement(By by) {
38-
return by.findElement(this);
39-
}
40-
41-
public WebElement findElementByAccessibilityId(String using) {
42-
return findElement("accessibility id", using);
43-
}
44-
45-
public List<WebElement> findElementsByAccessibilityId(String using) {
46-
return findElements("accessibility id", using);
47-
}
48-
49-
public Point getCenter() {
50-
Point upperLeft = this.getLocation();
51-
Dimension dimensions = this.getSize();
52-
return new Point(upperLeft.getX() + dimensions.getWidth() / 2, upperLeft.getY() + dimensions.getHeight() / 2);
53-
}
54-
55-
@Override
56-
public void pinch() {
57-
((AppiumDriver) parent).pinch(this);
58-
}
59-
60-
@Override
61-
public void tap(int fingers, int duration) {
62-
((AppiumDriver) parent).tap(fingers, this, duration);
63-
}
64-
65-
@Override
66-
public void zoom() {
67-
((AppiumDriver) parent).zoom(this);
68-
}
69-
70-
71-
@Override
72-
public void swipe(SwipeElementDirection direction, int duration) {
73-
direction.swipe((AppiumDriver) parent, this, duration);
74-
}
75-
}
1+
/*
2+
+Copyright 2014 Appium contributors
3+
+Copyright 2014 Software Freedom Conservancy
4+
+
5+
+Licensed under the Apache License, Version 2.0 (the "License");
6+
+you may not use this file except in compliance with the License.
7+
+You may obtain a copy of the License at
8+
+
9+
+ http://www.apache.org/licenses/LICENSE-2.0
10+
+
11+
+Unless required by applicable law or agreed to in writing, software
12+
+distributed under the License is distributed on an "AS IS" BASIS,
13+
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
+See the License for the specific language governing permissions and
15+
+limitations under the License.
16+
+ */
17+
18+
package io.appium.java_client;
19+
20+
import org.openqa.selenium.By;
21+
import org.openqa.selenium.Dimension;
22+
import org.openqa.selenium.Point;
23+
import org.openqa.selenium.WebElement;
24+
import org.openqa.selenium.remote.FileDetector;
25+
import org.openqa.selenium.remote.RemoteWebElement;
26+
27+
import java.util.List;
28+
29+
public abstract class MobileElement extends RemoteWebElement implements FindsByAccessibilityId, TouchableElement {
30+
31+
protected FileDetector fileDetector;
32+
33+
public List<WebElement> findElements(By by) {
34+
return by.findElements(this);
35+
}
36+
37+
public WebElement findElement(By by) {
38+
return by.findElement(this);
39+
}
40+
41+
public WebElement findElementByAccessibilityId(String using) {
42+
return findElement("accessibility id", using);
43+
}
44+
45+
public List<WebElement> findElementsByAccessibilityId(String using) {
46+
return findElements("accessibility id", using);
47+
}
48+
49+
public Point getCenter() {
50+
Point upperLeft = this.getLocation();
51+
Dimension dimensions = this.getSize();
52+
return new Point(upperLeft.getX() + dimensions.getWidth() / 2, upperLeft.getY() + dimensions.getHeight() / 2);
53+
}
54+
55+
@Override
56+
public void pinch() {
57+
((AppiumDriver) parent).pinch(this);
58+
}
59+
60+
@Override
61+
public void tap(int fingers, int duration) {
62+
((AppiumDriver) parent).tap(fingers, this, duration);
63+
}
64+
65+
@Override
66+
public void zoom() {
67+
((AppiumDriver) parent).zoom(this);
68+
}
69+
70+
71+
@Override
72+
public void swipe(SwipeElementDirection direction, int duration) {
73+
direction.swipe((AppiumDriver) parent, this, 0, 0, duration);
74+
}
75+
76+
@Override
77+
public void swipe(SwipeElementDirection direction, int offsetFromStartBorder,
78+
int offsetFromEndBorder, int duration) throws IllegalCoordinatesException {
79+
direction.swipe((AppiumDriver) parent, this, offsetFromStartBorder,
80+
offsetFromEndBorder, duration);
81+
}
82+
}

0 commit comments

Comments
 (0)