Sha256: 4c674cd83dd8e502bb5436f328b92c07a250930ce930d2f2c7a4938f3615b820

Contents?: true

Size: 1.46 KB

Versions: 4

Compression:

Stored size: 1.46 KB

Contents

module Appium
  module Core
    # 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.
    #
    # @example
    #
    #   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
    #
    #   # with an arbitrary driver
    #   driver = Appium::Driver.new(opts, false).start_driver
    #   multi_touch_action = MultiTouch.new(driver)
    #   multi_touch_action.add action_1
    #   multi_touch_action.add action_2
    #   multi_touch_action.perform
    #
    class MultiTouch
      attr_reader :driver

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

      # Add a touch_action to be performed
      # @param chain (TouchAction) The action to add to the chain
      def add(chain)
        @actions << chain.actions
      end

      # Ask Appium to perform the actions
      def perform
        @driver.multi_touch @actions
        @actions.clear
      end
    end # class MultiTouch
  end # module Core
end # module Appium

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
appium_lib_core-0.1.1 lib/appium_lib_core/device/multi_touch.rb
appium_lib_core-0.1.0 lib/appium_lib_core/device/multi_touch.rb
appium_lib-9.7.5 lib/appium_lib/core/device/multi_touch.rb
appium_lib-9.7.4 lib/appium_lib/core/device/multi_touch.rb