-
-
Notifications
You must be signed in to change notification settings - Fork 761
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #163 from TikhomirovSergey/swipeEnhancement
#160 fix
- Loading branch information
Showing
6 changed files
with
598 additions
and
395 deletions.
There are no files selected for viewing
12 changes: 12 additions & 0 deletions
12
src/main/java/io/appium/java_client/IllegalCoordinatesException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package io.appium.java_client; | ||
|
||
import org.openqa.selenium.WebDriverException; | ||
|
||
public class IllegalCoordinatesException extends WebDriverException { | ||
private static final long serialVersionUID = 1L; | ||
|
||
public IllegalCoordinatesException(String message) { | ||
super(message); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,75 +1,82 @@ | ||
/* | ||
+Copyright 2014 Appium contributors | ||
+Copyright 2014 Software Freedom Conservancy | ||
+ | ||
+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 io.appium.java_client; | ||
|
||
import org.openqa.selenium.By; | ||
import org.openqa.selenium.Dimension; | ||
import org.openqa.selenium.Point; | ||
import org.openqa.selenium.WebElement; | ||
import org.openqa.selenium.remote.FileDetector; | ||
import org.openqa.selenium.remote.RemoteWebElement; | ||
|
||
import java.util.List; | ||
|
||
public abstract class MobileElement extends RemoteWebElement implements FindsByAccessibilityId, TouchableElement { | ||
|
||
protected FileDetector fileDetector; | ||
|
||
public List<WebElement> findElements(By by) { | ||
return by.findElements(this); | ||
} | ||
|
||
public WebElement findElement(By by) { | ||
return by.findElement(this); | ||
} | ||
|
||
public WebElement findElementByAccessibilityId(String using) { | ||
return findElement("accessibility id", using); | ||
} | ||
|
||
public List<WebElement> findElementsByAccessibilityId(String using) { | ||
return findElements("accessibility id", using); | ||
} | ||
|
||
public Point getCenter() { | ||
Point upperLeft = this.getLocation(); | ||
Dimension dimensions = this.getSize(); | ||
return new Point(upperLeft.getX() + dimensions.getWidth() / 2, upperLeft.getY() + dimensions.getHeight() / 2); | ||
} | ||
|
||
@Override | ||
public void pinch() { | ||
((AppiumDriver) parent).pinch(this); | ||
} | ||
|
||
@Override | ||
public void tap(int fingers, int duration) { | ||
((AppiumDriver) parent).tap(fingers, this, duration); | ||
} | ||
|
||
@Override | ||
public void zoom() { | ||
((AppiumDriver) parent).zoom(this); | ||
} | ||
|
||
|
||
@Override | ||
public void swipe(SwipeElementDirection direction, int duration) { | ||
direction.swipe((AppiumDriver) parent, this, duration); | ||
} | ||
} | ||
/* | ||
+Copyright 2014 Appium contributors | ||
+Copyright 2014 Software Freedom Conservancy | ||
+ | ||
+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 io.appium.java_client; | ||
|
||
import org.openqa.selenium.By; | ||
import org.openqa.selenium.Dimension; | ||
import org.openqa.selenium.Point; | ||
import org.openqa.selenium.WebElement; | ||
import org.openqa.selenium.remote.FileDetector; | ||
import org.openqa.selenium.remote.RemoteWebElement; | ||
|
||
import java.util.List; | ||
|
||
public abstract class MobileElement extends RemoteWebElement implements FindsByAccessibilityId, TouchableElement { | ||
|
||
protected FileDetector fileDetector; | ||
|
||
public List<WebElement> findElements(By by) { | ||
return by.findElements(this); | ||
} | ||
|
||
public WebElement findElement(By by) { | ||
return by.findElement(this); | ||
} | ||
|
||
public WebElement findElementByAccessibilityId(String using) { | ||
return findElement("accessibility id", using); | ||
} | ||
|
||
public List<WebElement> findElementsByAccessibilityId(String using) { | ||
return findElements("accessibility id", using); | ||
} | ||
|
||
public Point getCenter() { | ||
Point upperLeft = this.getLocation(); | ||
Dimension dimensions = this.getSize(); | ||
return new Point(upperLeft.getX() + dimensions.getWidth() / 2, upperLeft.getY() + dimensions.getHeight() / 2); | ||
} | ||
|
||
@Override | ||
public void pinch() { | ||
((AppiumDriver) parent).pinch(this); | ||
} | ||
|
||
@Override | ||
public void tap(int fingers, int duration) { | ||
((AppiumDriver) parent).tap(fingers, this, duration); | ||
} | ||
|
||
@Override | ||
public void zoom() { | ||
((AppiumDriver) parent).zoom(this); | ||
} | ||
|
||
|
||
@Override | ||
public void swipe(SwipeElementDirection direction, int duration) { | ||
direction.swipe((AppiumDriver) parent, this, 0, 0, duration); | ||
} | ||
|
||
@Override | ||
public void swipe(SwipeElementDirection direction, int offsetFromStartBorder, | ||
int offsetFromEndBorder, int duration) throws IllegalCoordinatesException { | ||
direction.swipe((AppiumDriver) parent, this, offsetFromStartBorder, | ||
offsetFromEndBorder, duration); | ||
} | ||
} |
Oops, something went wrong.