Actions

TouchAction:

To perform a series of gestures, one after another. Gestures are chained together and only performed when perform() is called.

// to tap element
TouchAction action = new TouchActions(driver).singleTap(element).release();
action.perform();

// to click and hold
TouchAction action = new TouchActions(driver).clickandHold(element);
action.perform();

// to long press
TouchAction action = new TouchActions(driver).longPress(element).release();
action.perform();

// to swipe
TouchAction action = new TouchAction.new(driver).swipe(....);
action.perform();

# called `swipe(...).perform` in this method.
swipe(start_x: 75, start_y: 500, offset_x: 75, offset_y: 20, duration: 500)

MultiTouch:

MultiTouch actions allow for multiple touches to happen at the same time, to simulates multiple finger swipes.

action_1 = TouchAction.new.press(x: 45, y: 100).wait(5).release()
action_2 = TouchAction.new.tap(element: el, x: 50, y:5, count: 3)

multi_touch_action = MultiTouch.new
multi_touch_action.add action_1
multi_touch_action.add action_2
multi_touch_action.perform()

Last updated