Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions src/main/java/io/appium/java_client/TouchAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
*/
Expand Down