diff --git a/src/main/java/io/appium/java_client/TouchAction.java b/src/main/java/io/appium/java_client/TouchAction.java index f32bc3c35..3fd791991 100644 --- a/src/main/java/io/appium/java_client/TouchAction.java +++ b/src/main/java/io/appium/java_client/TouchAction.java @@ -209,6 +209,19 @@ public TouchAction longPress(WebElement el) { return this; } + /** + * Press and hold the at the center of an element until the contextmenu event has fired. + * @param el element to long-press + * @param duration of the long-press, in milliseconds + * @return this TouchAction, for chaining + */ + public TouchAction longPress(WebElement el, int duration) { + ActionParameter action = new ActionParameter("longPress", (RemoteWebElement)el); + action.addParameter("duration", duration); + parameterBuilder.add(action); + return this; + } + /** * Press and hold the at an absolute position on the screen until the contextmenu event has fired. * @param x x coordinate @@ -223,6 +236,22 @@ public TouchAction longPress(int x, int y) { return this; } + /** + * Press and hold the at an absolute position on the screen until the contextmenu event has fired. + * @param x x coordinate + * @param y y coordinate + * @param duration of the long-press, in milliseconds + * @return this TouchAction, for chaining + */ + public TouchAction longPress(int x, int y, int duration) { + ActionParameter action = new ActionParameter("longPress"); + action.addParameter("x", x); + action.addParameter("y", y); + action.addParameter("duration", duration); + parameterBuilder.add(action); + return this; + } + /** * Press and hold the at an elements upper-left corner, offset by the given amount, until the contextmenu event has fired. * @param el element to long-press @@ -238,6 +267,23 @@ public TouchAction longPress(WebElement el, int x, int y) { return this; } + /** + * Press and hold the at an elements upper-left corner, offset by the given amount, until the contextmenu event has fired. + * @param el element to long-press + * @param x x offset + * @param y y offset + * @param duration of the long-press, in milliseconds + * @return this TouchAction, for chaining + */ + public TouchAction longPress(WebElement el, int x, int y, int duration) { + ActionParameter action = new ActionParameter("longPress", (RemoteWebElement)el); + action.addParameter("x", x); + action.addParameter("y", y); + action.addParameter("duration", duration); + parameterBuilder.add(action); + return this; + } + /** * Cancel this action, if it was partially completed by the driver */