Class: Appium::Core::MultiTouch

Inherits:
Object
  • Object
show all
Defined in:
lib/appium_lib_core/common/touch_action/multi_touch.rb

Overview

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

Create a series of touch actions by themselves (without a `prepare()`), then add to a new MultiTouch action. When ready, call `prepare()` and all actions will be executed simultaneously.

Examples:


@driver = Appium::Core.for(opts).start_driver
action_1 = TouchAction.new(@driver).press(x: 45, y: 100).wait(600).release
action_2 = TouchAction.new(@driver).tap(element: el, x: 50, y:5, count: 3)

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(driver) ⇒ MultiTouch


38
39
40
41
# File 'lib/appium_lib_core/common/touch_action/multi_touch.rb', line 38

def initialize(driver)
  @actions = []
  @driver = driver
end

Instance Attribute Details

#driverObject (readonly)

Returns the value of attribute driver


36
37
38
# File 'lib/appium_lib_core/common/touch_action/multi_touch.rb', line 36

def driver
  @driver
end

Instance Method Details

#add(chain) ⇒ Object

Add a touch_action to be performed


45
46
47
# File 'lib/appium_lib_core/common/touch_action/multi_touch.rb', line 45

def add(chain)
  @actions << chain.actions
end

#performObject

Ask Appium to perform the actions


50
51
52
53
# File 'lib/appium_lib_core/common/touch_action/multi_touch.rb', line 50

def perform
  @driver.multi_touch @actions
  @actions.clear
end