Skip to content

Commit

Permalink
Merge pull request #166 from imurchie/isaac-longpress-duration
Browse files Browse the repository at this point in the history
Add longPress methods with duration
  • Loading branch information
Jonahss committed Mar 13, 2015
2 parents ce2ca86 + db61e47 commit da6c311
Showing 1 changed file with 46 additions and 0 deletions.
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

0 comments on commit da6c311

Please sign in to comment.