Thursday, 3 September 2015

Multi Touch Using Selendroid

Single Finger Example:
TouchAction ta = new TouchActionBuilder().pointerDown().
pointerMove(x, y).pointerUp().build();
ta.perform(driver);

Multi Finger Example (these will be executed in parallel):
TouchAction finger1 = new TouchActionBuilder().pointerDown().pause(100).
  pointerMove(x, y).pointerUp().build();
TouchAction finger2 = new   TouchActionBuilder().pointerDown().pause(100).
  pointerMove(x, y).pointerUp().build();
MultiTouchAction multiAction = new MultiTouchAction(finger1, finger2);
multiAction.perform(driver);

Flick the page using selendroid.

#Please import: org.openqa.selenium.interactions.touch.TouchActions
WebElement pages = driver.findElement(By.id("vp_pages"));
TouchActions flick = new TouchActions(driver).flick(pages, -100, 0, 0);
flick.perform();