diff --git a/appium-provider/src/main/java/com/paypal/selion/appium/platform/grid/SeLionAppiumAndroidDriver.java b/appium-provider/src/main/java/com/paypal/selion/appium/platform/grid/SeLionAppiumAndroidDriver.java index 26d0ec52a..2ada2bc69 100644 --- a/appium-provider/src/main/java/com/paypal/selion/appium/platform/grid/SeLionAppiumAndroidDriver.java +++ b/appium-provider/src/main/java/com/paypal/selion/appium/platform/grid/SeLionAppiumAndroidDriver.java @@ -15,13 +15,14 @@ package com.paypal.selion.appium.platform.grid; +import io.appium.java_client.MultiTouchAction; import io.appium.java_client.TouchAction; import io.appium.java_client.android.AndroidDriver; import java.net.URL; +import java.time.Duration; import org.openqa.selenium.Capabilities; -import org.openqa.selenium.DeviceRotation; import org.openqa.selenium.Dimension; import org.openqa.selenium.Point; import org.openqa.selenium.WebElement; @@ -34,8 +35,8 @@ /** * SeLionAppiumAndroidDriver provides facility to add custom {@link CommandExecutor} to - * {@link AndroidDriver}. This class also implements the {@link SeLionAndroidBridgeDriver} interface to expose - * methods for {@link UiObject} and its subclasses. + * {@link AndroidDriver}. This class also implements the {@link SeLionAndroidBridgeDriver} interface to expose methods + * for {@link UiObject} and its subclasses. */ public class SeLionAppiumAndroidDriver extends AndroidDriver implements SeLionAndroidBridgeDriver { @@ -54,7 +55,7 @@ public SeLionAppiumAndroidDriver(CommandExecutor commandExecutor, Capabilities c @Override public void click(WebElement webElement) { logger.entering(webElement); - this.tap(1, webElement, 1); + tap(1, webElement, 1); logger.exiting(); } @@ -162,7 +163,7 @@ public boolean isSelected(WebElement webElement) { @Override public void longClick(WebElement webElement) { logger.entering(webElement); - this.tap(1, webElement, OPERATION_DURATION_MILLI_SECONDS); + tap(1, webElement, OPERATION_DURATION_MILLI_SECONDS); logger.exiting(); } @@ -192,10 +193,10 @@ public void swipeLeft(WebElement webElement) { logger.entering(webElement); Point currentLocation = webElement.getLocation(); Dimension elementSize = webElement.getSize(); - int x = currentLocation.getX() + elementSize.getWidth() - 1; + int x = currentLocation.getX() + elementSize.getWidth() - 1; int y = currentLocation.getY(); int endx = currentLocation.getX(); - this.swipe(x, y, endx, y, OPERATION_DURATION_MILLI_SECONDS); + swipe(x, y, endx, y); logger.exiting(); } @@ -207,7 +208,7 @@ public void swipeRight(WebElement webElement) { int x = currentLocation.getX(); int y = currentLocation.getY(); int endx = x + elementSize.getWidth() - 1; - this.swipe(x,y,endx, y, OPERATION_DURATION_MILLI_SECONDS); + swipe(x, y, endx, y); logger.exiting(); } @@ -219,7 +220,7 @@ public void swipeUp(WebElement webElement) { int x = currentLocation.getX(); int y = currentLocation.getY() + elementSize.getHeight() - 1; int endy = currentLocation.getY(); - this.swipe(x, y, x, endy, OPERATION_DURATION_MILLI_SECONDS); + swipe(x, y, x, endy); logger.exiting(); } @@ -231,7 +232,7 @@ public void swipeDown(WebElement webElement) { int x = currentLocation.getX(); int y = currentLocation.getY(); int endy = y + elementSize.getHeight() - 1; - this.swipe(x, y, x, endy, OPERATION_DURATION_MILLI_SECONDS); + swipe(x, y, x, endy); logger.exiting(); } @@ -245,7 +246,7 @@ public void clearText(WebElement webElement) { @Override public void setText(WebElement webElement, String text) { logger.entering(webElement); - //As per the UI Object API doc a text field will be cleared before setting value + // As per the UI Object API doc a text field will be cleared before setting value webElement.clear(); webElement.sendKeys(text); logger.exiting(); @@ -253,19 +254,32 @@ public void setText(WebElement webElement, String text) { @Override public void swipe(int startx, int starty, int endx, int endy) { - //super.swipe(startx, starty, endx, endy, OPERATION_DURATION_MILLI_SECONDS ); + swipe(startx, starty, endx, endy, OPERATION_DURATION_MILLI_SECONDS); + } - // On Appium Android we mimic swipe via one finger tap - this.tap(1, starty, endx, OPERATION_DURATION_MILLI_SECONDS); + public void swipe(int startx, int starty, int endx, int endy, int duration) { + new TouchAction(this).press(startx, starty).waitAction(Duration.ofMillis(duration)).moveTo(endx, endy).release().perform(); } - @Override - public void rotate(DeviceRotation rotation) { - // TODO + public void tap(int fingers, WebElement element, int duration) { + MultiTouchAction multiTouch = new MultiTouchAction(this); + + for (int i = 0; i < fingers; i++) { + TouchAction tap = new TouchAction(this); + multiTouch.add(tap.press(element).waitAction(Duration.ofMillis(duration)).release()); + } + + multiTouch.perform(); } - @Override - public DeviceRotation rotation() { - return null; + public void tap(int fingers, int x, int y, int duration) { + MultiTouchAction multiTouch = new MultiTouchAction(this); + + for (int i = 0; i < fingers; i++) { + TouchAction tap = new TouchAction(this); + multiTouch.add(tap.press(x, y).waitAction(Duration.ofMillis(duration)).release()); + } + multiTouch.perform(); } + } diff --git a/appium-provider/src/main/java/com/paypal/selion/appium/platform/grid/SeLionAppiumIOSDriver.java b/appium-provider/src/main/java/com/paypal/selion/appium/platform/grid/SeLionAppiumIOSDriver.java index da3516538..2d5127180 100644 --- a/appium-provider/src/main/java/com/paypal/selion/appium/platform/grid/SeLionAppiumIOSDriver.java +++ b/appium-provider/src/main/java/com/paypal/selion/appium/platform/grid/SeLionAppiumIOSDriver.java @@ -18,11 +18,11 @@ import io.appium.java_client.ios.IOSDriver; import java.net.URL; +import java.time.Duration; import java.util.EnumMap; import org.openqa.selenium.By; import org.openqa.selenium.Capabilities; -import org.openqa.selenium.DeviceRotation; import org.openqa.selenium.Dimension; import org.openqa.selenium.WebElement; import org.openqa.selenium.remote.CommandExecutor; @@ -32,6 +32,8 @@ import com.paypal.selion.platform.mobile.ios.SeLionIOSBridgeDriver; import com.paypal.selion.platform.mobile.ios.UIAElement; import com.paypal.test.utilities.logging.SimpleLogger; + +import io.appium.java_client.MultiTouchAction; import io.appium.java_client.TouchAction; /** @@ -68,11 +70,8 @@ public WebElement findElementBy(By by) { @Override public void doubleTap(WebElement webElement) { logger.entering(webElement); - new TouchAction(this) - .tap(webElement).release() - .waitAction(DOUBLE_TAP_WAIT_TIME) - .tap(webElement).release() - .perform(); + new TouchAction(this).tap(webElement).release().waitAction(Duration.ofMillis(DOUBLE_TAP_WAIT_TIME)) + .tap(webElement).release().perform(); logger.exiting(); } @@ -88,7 +87,7 @@ public void scrollToVisible(WebElement webElement) { found = true; break; } - this.swipe(startx, height, startx, SWIPE_EDGE_OFFSET - height, SWIPE_DURATION); + swipe(startx, height, startx, SWIPE_EDGE_OFFSET - height, SWIPE_DURATION); } if (!found && !webElement.isDisplayed()) { // giving up scrolling for element to be displayed after MAX_SCROLL_COUNT reached. @@ -100,7 +99,7 @@ public void scrollToVisible(WebElement webElement) { @Override public void tap(WebElement webElement) { logger.entering(webElement); - super.tap(1, webElement, TAP_DURATION); + tap(1, webElement, TAP_DURATION); logger.exiting(); } @@ -112,14 +111,14 @@ public void tapWithOptions(WebElement webElement, EnumMap3.5.3 0.6.5 0.17.0 - 5.0.0-BETA6 + 5.0.3 6.9.10 1.15 2.27