io.appium.java_client
Class TouchAction

java.lang.Object
  extended by io.appium.java_client.TouchAction

public class TouchAction
extends Object

Used for Webdriver 3 touch actions See the Webriver 3 spec https://dvcs.w3.org/hg/webdriver/raw-file/default/webdriver-spec.html The flow is to chain individual touch actions into an entire gesture. e.g. TouchAction action = new TouchAction(driver); action.press(element).waitAction(300).moveTo(element1).release().perform(); Calling perform() sends the action command to the Mobile Driver. Otherwise, more and more actions can be chained.


Constructor Summary
TouchAction(MobileDriver driver)
           
 
Method Summary
 void cancel()
          Cancel this action, if it was partially completed by the driver
protected  void clearParameters()
           
protected  com.google.common.collect.ImmutableMap<String,com.google.common.collect.ImmutableList> getParameters()
          Get the mjsonwp parameters for this Action
 TouchAction longPress(int x, int y)
          Press and hold the at an absolute position on the screen until the contextmenu event has fired.
 TouchAction longPress(org.openqa.selenium.WebElement el)
          Press and hold the at the center of an element until the contextmenu event has fired.
 TouchAction longPress(org.openqa.selenium.WebElement el, int x, int y)
          Press and hold the at an elements upper-left corner, offset by the given amount, until the contextmenu event has fired.
 TouchAction moveTo(int x, int y)
          Move current touch to an absolute position on the screen
 TouchAction moveTo(org.openqa.selenium.WebElement el)
          Move current touch to center of an element.
 TouchAction moveTo(org.openqa.selenium.WebElement el, int x, int y)
          Move current touch to an element, offset from upper left corner
 TouchAction perform()
          Perform this chain of actions on the driver.
 TouchAction press(int x, int y)
          Press on an absolute position on the screen
 TouchAction press(org.openqa.selenium.WebElement el)
          Press on the center of an element.
 TouchAction press(org.openqa.selenium.WebElement el, int x, int y)
          Press on an element, offset from upper left corner by a number of pixels
 TouchAction release()
          Remove the current touching implement from the screen (withdraw your touch)
 TouchAction tap(int x, int y)
          Tap an absolute position on the screen
 TouchAction tap(org.openqa.selenium.WebElement el)
          Tap the center of an element.
 TouchAction tap(org.openqa.selenium.WebElement el, int x, int y)
          Tap an element, offset from upper left corner
 TouchAction waitAction()
          A wait action, used as a NOP in multi-chaining
 TouchAction waitAction(int ms)
          Waits for specified amount of time to pass before continue to next touch action
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TouchAction

public TouchAction(MobileDriver driver)
Method Detail

press

public TouchAction press(org.openqa.selenium.WebElement el)
Press on the center of an element.

Parameters:
el - element to press on
Returns:
this TouchAction, for chaining

press

public TouchAction press(int x,
                         int y)
Press on an absolute position on the screen

Parameters:
x - x coordinate
y - y coordinate
Returns:
this TouchAction, for chaining

press

public TouchAction press(org.openqa.selenium.WebElement el,
                         int x,
                         int y)
Press on an element, offset from upper left corner by a number of pixels

Parameters:
el - element to press on
x - x offset
y - y offset
Returns:
this TouchAction, for chaining

release

public TouchAction release()
Remove the current touching implement from the screen (withdraw your touch)

Returns:
this TouchAction, for chaining

moveTo

public TouchAction moveTo(org.openqa.selenium.WebElement el)
Move current touch to center of an element.

Parameters:
el - element to move to
Returns:
this TouchAction, for chaining

moveTo

public TouchAction moveTo(int x,
                          int y)
Move current touch to an absolute position on the screen

Parameters:
x - x coordinate
y - y coordinate
Returns:
this TouchAction, for chaining

moveTo

public TouchAction moveTo(org.openqa.selenium.WebElement el,
                          int x,
                          int y)
Move current touch to an element, offset from upper left corner

Parameters:
el - element to move current touch to
x - x offset
y - y offset
Returns:
this TouchAction, for chaining

tap

public TouchAction tap(org.openqa.selenium.WebElement el)
Tap the center of an element.

Parameters:
el - element to tap
Returns:
this TouchAction, for chaining

tap

public TouchAction tap(int x,
                       int y)
Tap an absolute position on the screen

Parameters:
x - x coordinate
y - y coordinate
Returns:
this TouchAction, for chaining

tap

public TouchAction tap(org.openqa.selenium.WebElement el,
                       int x,
                       int y)
Tap an element, offset from upper left corner

Parameters:
el - element to tap
x - x offset
y - y offset
Returns:
this TouchAction, for chaining

waitAction

public TouchAction waitAction()
A wait action, used as a NOP in multi-chaining

Returns:
this TouchAction, for chaining

waitAction

public TouchAction waitAction(int ms)
Waits for specified amount of time to pass before continue to next touch action

Parameters:
ms - time in milliseconds to wait
Returns:
this TouchAction, for chaining

longPress

public TouchAction longPress(org.openqa.selenium.WebElement el)
Press and hold the at the center of an element until the contextmenu event has fired.

Parameters:
el - element to long-press
Returns:
this TouchAction, for chaining

longPress

public TouchAction longPress(int x,
                             int y)
Press and hold the at an absolute position on the screen until the contextmenu event has fired.

Parameters:
x - x coordinate
y - y coordinate
Returns:
this TouchAction, for chaining

longPress

public TouchAction longPress(org.openqa.selenium.WebElement el,
                             int x,
                             int y)
Press and hold the at an elements upper-left corner, offset by the given amount, until the contextmenu event has fired.

Parameters:
el - element to long-press
x - x offset
y - y offset
Returns:
this TouchAction, for chaining

cancel

public void cancel()
Cancel this action, if it was partially completed by the driver


perform

public TouchAction perform()
Perform this chain of actions on the driver.

Returns:
this TouchAction, for possible segmented-touches.

getParameters

protected com.google.common.collect.ImmutableMap<String,com.google.common.collect.ImmutableList> getParameters()
Get the mjsonwp parameters for this Action

Returns:
A map of parameters for this touch action to pass as part of mjsonwp

clearParameters

protected void clearParameters()


Copyright © 2014. All rights reserved.