Class: Appium::Core::MultiTouch Deprecated

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

Overview

Deprecated.

Use W3C actions instead

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.

Consider to use W3C spec touch action like the followings. www.selenium.dev/selenium/docs/api/rb/Selenium/WebDriver/PointerActions.html github.com/appium/ruby_lib_core/blob/master/test/functional/android/webdriver/w3c_actions_test.rb github.com/appium/ruby_lib_core/blob/master/test/functional/ios/webdriver/w3c_actions_test.rb

About W3C actions www.youtube.com/watch?v=oAJ7jwMNFVU appiumpro.com/editions/30-ios-specific-touch-action-methods appiumpro.com/editions/29-automating-complex-gestures-with-the-w3c-actions-api

Functional test code in ruby_lib_core repository also helps.

Examples:


@driver = Appium::Core.for(opts).start_driver
action_1 = Appium::Core::TouchAction.new(@driver).press(x: 45, y: 100).wait(600).release
action_2 = Appium::Core::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

Returns a new instance of MultiTouch.



53
54
55
56
57
58
59
60
# File 'lib/appium_lib_core/common/touch_action/multi_touch.rb', line 53

def initialize(driver)
  ::Appium::Logger.warn(
    '[DEPRECATION] Appium::Core::MultiTouch is deprecated in W3C spec. Use W3C actions instead'
  )

  @actions = []
  @driver = driver
end

Instance Attribute Details

#driverObject (readonly)

Returns the value of attribute driver.



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

def driver
  @driver
end

Instance Method Details

#add(chain) ⇒ Object

Add a touch_action to be performed

Parameters:

  • chain (TouchAction)

    The action to add to the chain



64
65
66
# File 'lib/appium_lib_core/common/touch_action/multi_touch.rb', line 64

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

#performObject

Ask Appium to perform the actions



69
70
71
72
# File 'lib/appium_lib_core/common/touch_action/multi_touch.rb', line 69

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