diff --git a/src/main/java/io/appium/java_client/AppiumDriver.java b/src/main/java/io/appium/java_client/AppiumDriver.java index 2eacf2e1f..dd2b8063c 100644 --- a/src/main/java/io/appium/java_client/AppiumDriver.java +++ b/src/main/java/io/appium/java_client/AppiumDriver.java @@ -218,9 +218,9 @@ public List findElementsByXPath(String using) { } /** - * @see TouchShortcuts#tap(int, WebElement, int). + * @see TouchableElement#tap(int, WebElement, int). */ - @Override public void tap(int fingers, WebElement element, int duration) { + public void tap(int fingers, WebElement element, int duration) { MultiTouchAction multiTouch = new MultiTouchAction(this); for (int i = 0; i < fingers; i++) { @@ -231,9 +231,9 @@ public List findElementsByXPath(String using) { } /** - * @see TouchShortcuts#tap(int, int, int, int). + * @see TouchableElement#tap(int, int, int, int). */ - @Override public void tap(int fingers, int x, int y, int duration) { + public void tap(int fingers, int x, int y, int duration) { MultiTouchAction multiTouch = new MultiTouchAction(this); for (int i = 0; i < fingers; i++) { @@ -243,145 +243,45 @@ public List findElementsByXPath(String using) { multiTouch.perform(); } - protected void doSwipe(int startx, int starty, int endx, int endy, int duration) { - TouchAction touchAction = new TouchAction(this); - - // appium converts press-wait-moveto-release to a swipe action - touchAction.press(startx, starty).waitAction(duration).moveTo(endx, endy).release(); - - touchAction.perform(); - } - /** - * @see TouchShortcuts#swipe(int, int, int, int, int). + * @see TouchableElement#swipe(int, int, int, int, int). */ - @Override public abstract void swipe(int startx, int starty, int endx, int endy, int duration); + public abstract void swipe(int startx, int starty, int endx, int endy, int duration); /** - * Convenience method for pinching an element on the screen. - * "pinching" refers to the action of two appendages pressing the - * screen and sliding towards each other. - * NOTE: - * This convenience method places the initial touches around the element, if this would - * happen to place one of them off the screen, appium with return an outOfBounds error. - * In this case, revert to using the MultiTouchAction api instead of this method. - * - * @param el The element to pinch. + * @see TouchableElement#pinch(WebElement). */ public void pinch(WebElement el) { MultiTouchAction multiTouch = new MultiTouchAction(this); - Dimension dimensions = el.getSize(); - Point upperLeft = el.getLocation(); - Point center = new Point(upperLeft.getX() + dimensions.getWidth() / 2, - upperLeft.getY() + dimensions.getHeight() / 2); - int yOffset = center.getY() - upperLeft.getY(); - - TouchAction action0 = - new TouchAction(this).press(el, center.getX(), center.getY() - yOffset).moveTo(el) - .release(); - TouchAction action1 = - new TouchAction(this).press(el, center.getX(), center.getY() + yOffset).moveTo(el) - .release(); - - multiTouch.add(action0).add(action1); - - multiTouch.perform(); + multiTouch.pinch(el).perform(); } /** - * Convenience method for pinching an element on the screen. - * "pinching" refers to the action of two appendages pressing the screen and - * sliding towards each other. - * NOTE: - * This convenience method places the initial touches around the element at a distance, - * if this would happen to place one of them off the screen, appium will return an - * outOfBounds error. In this case, revert to using the MultiTouchAction api instead of this - * method. - * - * @param x x coordinate to terminate the pinch on. - * @param y y coordinate to terminate the pinch on. + * @see TouchableElement#pinch(int, int). */ public void pinch(int x, int y) { MultiTouchAction multiTouch = new MultiTouchAction(this); - int scrHeight = manage().window().getSize().getHeight(); - int yOffset = 100; - - if (y - 100 < 0) { - yOffset = y; - } else if (y + 100 > scrHeight) { - yOffset = scrHeight - y; - } - - TouchAction action0 = new TouchAction(this).press(x, y - yOffset).moveTo(x, y).release(); - TouchAction action1 = new TouchAction(this).press(x, y + yOffset).moveTo(x, y).release(); - - multiTouch.add(action0).add(action1); - - multiTouch.perform(); + multiTouch.pinch(x, y).perform(); } /** - * Convenience method for "zooming in" on an element on the screen. - * "zooming in" refers to the action of two appendages pressing the screen and sliding - * away from each other. - * NOTE: - * This convenience method slides touches away from the element, if this would happen - * to place one of them off the screen, appium will return an outOfBounds error. - * In this case, revert to using the MultiTouchAction api instead of this method. - * - * @param el The element to pinch. + * @see TouchableElement#zoom(WebElement). */ public void zoom(WebElement el) { MultiTouchAction multiTouch = new MultiTouchAction(this); - Dimension dimensions = el.getSize(); - Point upperLeft = el.getLocation(); - Point center = new Point(upperLeft.getX() + dimensions.getWidth() / 2, - upperLeft.getY() + dimensions.getHeight() / 2); - int yOffset = center.getY() - upperLeft.getY(); - - TouchAction action0 = new TouchAction(this).press(center.getX(), center.getY()) - .moveTo(el, center.getX(), center.getY() - yOffset).release(); - TouchAction action1 = new TouchAction(this).press(center.getX(), center.getY()) - .moveTo(el, center.getX(), center.getY() + yOffset).release(); - - multiTouch.add(action0).add(action1); - - multiTouch.perform(); + multiTouch.zoom(el).perform(); } /** - * Convenience method for "zooming in" on an element on the screen. - * "zooming in" refers to the action of two appendages pressing the screen - * and sliding away from each other. - * NOTE: - * This convenience method slides touches away from the element, if this would happen to - * place one of them off the screen, appium will return an outOfBounds error. In this case, - * revert to using the MultiTouchAction api instead of this method. - * - * @param x x coordinate to start zoom on. - * @param y y coordinate to start zoom on. + * @see TouchableElement#zoom(int, int). */ public void zoom(int x, int y) { MultiTouchAction multiTouch = new MultiTouchAction(this); - int scrHeight = manage().window().getSize().getHeight(); - int yOffset = 100; - - if (y - 100 < 0) { - yOffset = y; - } else if (y + 100 > scrHeight) { - yOffset = scrHeight - y; - } - - TouchAction action0 = new TouchAction(this).press(x, y).moveTo(0, -yOffset).release(); - TouchAction action1 = new TouchAction(this).press(x, y).moveTo(0, yOffset).release(); - - multiTouch.add(action0).add(action1); - - multiTouch.perform(); + multiTouch.zoom(x, y).perform(); } @Override public WebDriver context(String name) { diff --git a/src/main/java/io/appium/java_client/MobileDriver.java b/src/main/java/io/appium/java_client/MobileDriver.java index bdda35e23..d122a9e98 100644 --- a/src/main/java/io/appium/java_client/MobileDriver.java +++ b/src/main/java/io/appium/java_client/MobileDriver.java @@ -35,7 +35,7 @@ import java.util.Map; public interface MobileDriver extends WebDriver, PerformsTouchActions, ContextAware, Rotatable, - FindsByAccessibilityId, LocationContext, DeviceActionShortcuts, TouchShortcuts, + FindsByAccessibilityId, LocationContext, DeviceActionShortcuts, InteractsWithFiles, InteractsWithApps, HasAppStrings, FindsByClassName, FindsByCssSelector, FindsById, FindsByLinkText, FindsByName, FindsByTagName, FindsByXPath, FindsByFluentSelector, ExecutesMethod { diff --git a/src/main/java/io/appium/java_client/MobileElement.java b/src/main/java/io/appium/java_client/MobileElement.java index 958c409ed..05c3ab6fd 100644 --- a/src/main/java/io/appium/java_client/MobileElement.java +++ b/src/main/java/io/appium/java_client/MobileElement.java @@ -21,6 +21,7 @@ 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 java.util.List; @@ -42,18 +43,45 @@ public Point getCenter() { upperLeft.getY() + dimensions.getHeight() / 2); } + @Override public void tap(int fingers, int duration) { + ((AppiumDriver) parent).tap(fingers, this, duration); + } + + @Override public void tap(int fingers, int x, int y, int duration) { + ((AppiumDriver) parent).tap(fingers, x, y, duration); + } + + @Override public void tap(int fingers, WebElement element, int duration) { + ((AppiumDriver) parent).tap(fingers, element, duration); + } + @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 pinch(int x, int y) { + ((AppiumDriver) parent).pinch(x, y); + } + + @Override public void pinch(WebElement el) { + ((AppiumDriver) parent).pinch(el); } @Override public void zoom() { ((AppiumDriver) parent).zoom(this); } + @Override public void zoom(int x, int y) { + ((AppiumDriver) parent).zoom(x, y); + } + + @Override public void zoom(WebElement el) { + ((AppiumDriver) parent).zoom(el); + } + + @Override public void swipe(int startx, int starty, int endx, int endy, int duration) { + ((AppiumDriver) parent).swipe(startx, startx, endx, endy ,duration); + } @Override public void swipe(SwipeElementDirection direction, int duration) { direction.swipe((AppiumDriver) parent, this, 0, 0, duration); diff --git a/src/main/java/io/appium/java_client/MultiTouchAction.java b/src/main/java/io/appium/java_client/MultiTouchAction.java index 7bde2a05d..053a62307 100644 --- a/src/main/java/io/appium/java_client/MultiTouchAction.java +++ b/src/main/java/io/appium/java_client/MultiTouchAction.java @@ -20,6 +20,10 @@ import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; +import org.openqa.selenium.Dimension; +import org.openqa.selenium.Point; +import org.openqa.selenium.WebElement; + /** * Used for Webdriver 3 multi-touch gestures * See the Webriver 3 spec https://dvcs.w3.org/hg/webdriver/raw-file/default/webdriver-spec.html @@ -86,4 +90,88 @@ protected ImmutableMap getParameters() { } return ImmutableMap.of("actions", listOfActionChains.build()); } + + /** + * @see TouchableElement#pinch(WebElement). + */ + public MultiTouchAction pinch(WebElement el) { + MultiTouchAction multiTouch = new MultiTouchAction(driver); + + Dimension dimensions = el.getSize(); + Point upperLeft = el.getLocation(); + Point center = new Point(upperLeft.getX() + dimensions.getWidth() / 2, + upperLeft.getY() + dimensions.getHeight() / 2); + int yOffset = center.getY() - upperLeft.getY(); + + TouchAction action0 = + new TouchAction(driver).press(el, center.getX(), center.getY() - yOffset).moveTo(el) + .release(); + TouchAction action1 = + new TouchAction(driver).press(el, center.getX(), center.getY() + yOffset).moveTo(el) + .release(); + + return multiTouch.add(action0).add(action1); + } + + /** + * @see TouchableElement#pinch(int, int). + */ + public MultiTouchAction pinch(int x, int y) { + MultiTouchAction multiTouch = new MultiTouchAction(driver); + + int scrHeight = driver.manage().window().getSize().getHeight(); + int yOffset = 100; + + if (y - 100 < 0) { + yOffset = y; + } else if (y + 100 > scrHeight) { + yOffset = scrHeight - y; + } + + TouchAction action0 = new TouchAction(driver).press(x, y - yOffset).moveTo(x, y).release(); + TouchAction action1 = new TouchAction(driver).press(x, y + yOffset).moveTo(x, y).release(); + + return multiTouch.add(action0).add(action1); + } + + /** + * @see TouchableElement#zoom(WebElement). + */ + public MultiTouchAction zoom(WebElement el) { + MultiTouchAction multiTouch = new MultiTouchAction(driver); + + Dimension dimensions = el.getSize(); + Point upperLeft = el.getLocation(); + Point center = new Point(upperLeft.getX() + dimensions.getWidth() / 2, + upperLeft.getY() + dimensions.getHeight() / 2); + int yOffset = center.getY() - upperLeft.getY(); + + TouchAction action0 = new TouchAction(driver).press(center.getX(), center.getY()) + .moveTo(el, center.getX(), center.getY() - yOffset).release(); + TouchAction action1 = new TouchAction(driver).press(center.getX(), center.getY()) + .moveTo(el, center.getX(), center.getY() + yOffset).release(); + + return multiTouch.add(action0).add(action1); + } + + /** + * @see TouchableElement#zoom(int, int). + */ + public MultiTouchAction zoom(int x, int y) { + MultiTouchAction multiTouch = new MultiTouchAction(driver); + + int scrHeight = driver.manage().window().getSize().getHeight(); + int yOffset = 100; + + if (y - 100 < 0) { + yOffset = y; + } else if (y + 100 > scrHeight) { + yOffset = scrHeight - y; + } + + TouchAction action0 = new TouchAction(driver).press(x, y).moveTo(0, -yOffset).release(); + TouchAction action1 = new TouchAction(driver).press(x, y).moveTo(0, yOffset).release(); + + return multiTouch.add(action0).add(action1); + } } diff --git a/src/main/java/io/appium/java_client/TouchAction.java b/src/main/java/io/appium/java_client/TouchAction.java index 3d1ba66a2..c29e815e2 100644 --- a/src/main/java/io/appium/java_client/TouchAction.java +++ b/src/main/java/io/appium/java_client/TouchAction.java @@ -35,7 +35,7 @@ */ @SuppressWarnings({"rawtypes", "unchecked"}) public class TouchAction { - ImmutableList.Builder parameterBuilder; + protected ImmutableList.Builder parameterBuilder; private MobileDriver driver; public TouchAction(MobileDriver driver) { @@ -346,7 +346,7 @@ protected void clearParameters() { /** * Just holds values to eventually return the parameters required for the mjsonwp. */ - private class ActionParameter { + protected class ActionParameter { private String actionName; private ImmutableMap.Builder optionsBuilder; diff --git a/src/main/java/io/appium/java_client/TouchShortcuts.java b/src/main/java/io/appium/java_client/TouchShortcuts.java deleted file mode 100644 index ab8625ef2..000000000 --- a/src/main/java/io/appium/java_client/TouchShortcuts.java +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * See the NOTICE file distributed with this work for additional - * information regarding copyright ownership. - * 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.WebElement; - -public interface TouchShortcuts { - - /** - * Convenience method for "zooming in" on an element on the screen. - * "zooming in" refers to the action of two appendages pressing the - * screen and sliding away from each other. - * NOTE: - * This convenience method slides touches away from the element, - * if this would happen to place one of them off the screen, appium will return an - * outOfBounds error. In this case, revert to using the MultiTouchAction api - * instead of this method. - * - * @param x x coordinate to start zoom on. - * @param y y coordinate to start zoom on. - */ - void zoom(int x, int y); - - /** - * Convenience method for "zooming in" on an element on the screen. - * "zooming in" refers to the action of two appendages pressing the screen - * and sliding away from each other. - * NOTE: - * This convenience method slides touches away from the element, if this would - * happen to place one of them off the screen, appium will return an outOfBounds - * error. In this case, revert to using the MultiTouchAction api - * instead of this method. - * - * @param el The element to pinch. - */ - void zoom(WebElement el); - - /** - * Convenience method for tapping a position on the screen. - * - * @param fingers number of fingers/appendages to tap with. - * @param x x coordinate. - * @param y y coordinate. - * @param duration how long between pressing down, and lifting fingers/appendages. - */ - void tap(int fingers, int x, int y, int duration); - - /** - * Convenience method for tapping the center of an element on the screen. - * - * @param fingers number of fingers/appendages to tap with. - * @param element element to tap. - * @param duration how long between pressing down, and lifting fingers/appendages. - */ - void tap(int fingers, WebElement element, int duration); - - /** - * Convenience method for swiping across the screen. - * - * @param startx starting x coordinate. - * @param starty starting y coordinate. - * @param endx ending x coordinate. - * @param endy ending y coordinate. - * @param duration amount of time in milliseconds for the entire swipe action to take - */ - void swipe(int startx, int starty, int endx, int endy, int duration); - - /** - * Convenience method for pinching an element on the screen. - * "pinching" refers to the action of two appendages pressing the screen - * and sliding towards each other. - * NOTE: - * This convenience method places the initial touches around the element at a distance, - * if this would happen to place one of them off the screen, appium will return an - * outOfBounds error. In this case, revert to using the MultiTouchAction api - * instead of this method. - * - * @param x x coordinate to terminate the pinch on. - * @param y y coordinate to terminate the pinch on. - */ - void pinch(int x, int y); - - /** - * Convenience method for pinching an element on the screen. - * "pinching" refers to the action of two appendages pressing the screen and - * sliding towards each other. - * NOTE: - * This convenience method places the initial touches around the element, if this would - * happen to place one of them off the screen, appium with return an outOfBounds error. - * In this case, revert to using the MultiTouchAction api instead of this method. - * - * @param el The element to pinch. - */ - void pinch(WebElement el); - -} diff --git a/src/main/java/io/appium/java_client/TouchableElement.java b/src/main/java/io/appium/java_client/TouchableElement.java index bba550448..a66dbf028 100644 --- a/src/main/java/io/appium/java_client/TouchableElement.java +++ b/src/main/java/io/appium/java_client/TouchableElement.java @@ -73,6 +73,61 @@ public interface TouchableElement extends WebElement, Find List findElementsByXPath(String xPath); + /** + * Convenience method for tapping the center of the given element. + * + * @param fingers number of fingers/appendages to tap with. + * @param duration how long between pressing down, and lifting fingers/appendages. + */ + void tap(int fingers, int duration); + + /** + * Convenience method for tapping a position on the screen. + * + * @param fingers number of fingers/appendages to tap with. + * @param x x coordinate. + * @param y y coordinate. + * @param duration how long between pressing down, and lifting fingers/appendages. + */ + void tap(int fingers, int x, int y, int duration); + + /** + * Convenience method for tapping the center of an element on the screen. + * + * @param fingers number of fingers/appendages to tap with. + * @param element element to tap. + * @param duration how long between pressing down, and lifting fingers/appendages. + */ + void tap(int fingers, WebElement element, int duration); + + /** + * Convenience method for pinching an element on the screen. + * "pinching" refers to the action of two appendages pressing the screen + * and sliding towards each other. + * NOTE: + * This convenience method places the initial touches around the element at a distance, + * if this would happen to place one of them off the screen, appium will return an + * outOfBounds error. In this case, revert to using the MultiTouchAction api + * instead of this method. + * + * @param x x coordinate to terminate the pinch on. + * @param y y coordinate to terminate the pinch on. + */ + void pinch(int x, int y); + + /** + * Convenience method for pinching an element on the screen. + * "pinching" refers to the action of two appendages pressing the screen and + * sliding towards each other. + * NOTE: + * This convenience method places the initial touches around the element, if this would + * happen to place one of them off the screen, appium with return an outOfBounds error. + * In this case, revert to using the MultiTouchAction api instead of this method. + * + * @param el The element to pinch. + */ + void pinch(WebElement el); + /** * Convenience method for pinching the given element. * "pinching" refers to the action of two appendages pressing the screen @@ -86,12 +141,33 @@ public interface TouchableElement extends WebElement, Find void pinch(); /** - * Convenience method for tapping the center of the given element. + * Convenience method for "zooming in" on an element on the screen. + * "zooming in" refers to the action of two appendages pressing the + * screen and sliding away from each other. + * NOTE: + * This convenience method slides touches away from the element, + * if this would happen to place one of them off the screen, appium will return an + * outOfBounds error. In this case, revert to using the MultiTouchAction api + * instead of this method. * - * @param fingers number of fingers/appendages to tap with. - * @param duration how long between pressing down, and lifting fingers/appendages. + * @param x x coordinate to start zoom on. + * @param y y coordinate to start zoom on. */ - void tap(int fingers, int duration); + void zoom(int x, int y); + + /** + * Convenience method for "zooming in" on an element on the screen. + * "zooming in" refers to the action of two appendages pressing the screen + * and sliding away from each other. + * NOTE: + * This convenience method slides touches away from the element, if this would + * happen to place one of them off the screen, appium will return an outOfBounds + * error. In this case, revert to using the MultiTouchAction api + * instead of this method. + * + * @param el The element to pinch. + */ + void zoom(WebElement el); /** * Convenience method for "zooming in" on the given element. @@ -113,6 +189,16 @@ public interface TouchableElement extends WebElement, Find */ void swipe(SwipeElementDirection direction, int duration); + /** + * Convenience method for swiping across the screen. + * + * @param startx starting x coordinate. + * @param starty starting y coordinate. + * @param endx ending x coordinate. + * @param endy ending y coordinate. + * @param duration amount of time in milliseconds for the entire swipe action to take + */ + void swipe(int startx, int starty, int endx, int endy, int duration); /** * Convenience method for swiping on the given element to the given direction. diff --git a/src/main/java/io/appium/java_client/android/AndroidDriver.java b/src/main/java/io/appium/java_client/android/AndroidDriver.java index 7b92a2b81..5527971b7 100644 --- a/src/main/java/io/appium/java_client/android/AndroidDriver.java +++ b/src/main/java/io/appium/java_client/android/AndroidDriver.java @@ -161,10 +161,12 @@ public AndroidDriver(Capabilities desiredCapabilities) { } /** - * @see io.appium.java_client.TouchShortcuts#swipe(int, int, int, int, int) + * @see io.appium.java_client.TouchableElement#swipe(int, int, int, int, int) */ @Override public void swipe(int startx, int starty, int endx, int endy, int duration) { - doSwipe(startx, starty, endx, endy, duration); + AndroidTouchAction touchaction = new AndroidTouchAction(this); + + touchaction.swipe(startx, starty, endx, endy, duration).perform(); } /** diff --git a/src/main/java/io/appium/java_client/android/AndroidTouchAction.java b/src/main/java/io/appium/java_client/android/AndroidTouchAction.java new file mode 100644 index 000000000..94134ee72 --- /dev/null +++ b/src/main/java/io/appium/java_client/android/AndroidTouchAction.java @@ -0,0 +1,22 @@ +package io.appium.java_client.android; + +import io.appium.java_client.MobileDriver; +import io.appium.java_client.TouchAction; +import io.appium.java_client.TouchableElement; + +public class AndroidTouchAction extends TouchAction { + + public AndroidTouchAction(MobileDriver driver) { + super(driver); + } + + /** + * @see TouchableElement#swipe(int, int, int, int, int). + */ + @Deprecated protected TouchAction swipe(int startx, int starty, int endx, int endy, int duration) { + + // appium converts press-wait-moveto-release to a swipe action + return press(startx, starty).waitAction(duration).moveTo(endx, endy).release(); + + } +} diff --git a/src/main/java/io/appium/java_client/ios/IOSDriver.java b/src/main/java/io/appium/java_client/ios/IOSDriver.java index 518f186a1..59f1248c4 100644 --- a/src/main/java/io/appium/java_client/ios/IOSDriver.java +++ b/src/main/java/io/appium/java_client/ios/IOSDriver.java @@ -164,10 +164,12 @@ public IOSDriver(Capabilities desiredCapabilities) { } /** - * @see io.appium.java_client.TouchShortcuts#swipe(int, int, int, int, int). + * @see io.appium.java_client.TouchableElement#swipe(int, int, int, int, int). */ @Override public void swipe(int startx, int starty, int endx, int endy, int duration) { - doSwipe(startx, starty, endx - startx, endy - starty, duration); + IOSTouchAction touchaction = new IOSTouchAction(this); + + touchaction.swipe(startx, starty, endx, endy, duration).perform(); } @Override public TargetLocator switchTo() { diff --git a/src/main/java/io/appium/java_client/ios/IOSTouchAction.java b/src/main/java/io/appium/java_client/ios/IOSTouchAction.java new file mode 100644 index 000000000..dee46ae84 --- /dev/null +++ b/src/main/java/io/appium/java_client/ios/IOSTouchAction.java @@ -0,0 +1,24 @@ +package io.appium.java_client.ios; + +import io.appium.java_client.MobileDriver; +import io.appium.java_client.TouchAction; +import io.appium.java_client.TouchableElement; + + +public class IOSTouchAction extends TouchAction { + + public IOSTouchAction(MobileDriver driver) { + super(driver); + } + + /** + * @see TouchableElement#swipe(int, int, int, int, int). + */ + @Deprecated protected TouchAction swipe(int startx, int starty, int endx, int endy, int duration) { + int endX = endx - startx; + int endY = endy - starty; + + // appium converts press-wait-moveto-release to a swipe action + return press(startx, starty).waitAction(duration).moveTo(endX, endY).release(); + } +}