Class: Appium::MultiTouch
- Inherits:
-
Core::MultiTouch
- Object
- Core::MultiTouch
- Appium::MultiTouch
- Defined in:
- lib/appium_lib/common/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.
Class Method Summary collapse
-
.pinch(percentage = 25, auto_perform = true, driver = $driver) ⇒ Object
Convenience method for pinching the screen.
-
.zoom(percentage = 200, auto_perform = true, driver = $driver) ⇒ Object
Convenience method for zooming the screen.
Instance Method Summary collapse
-
#initialize(driver = $driver) ⇒ MultiTouch
constructor
self.
Constructor Details
#initialize(driver = $driver) ⇒ MultiTouch
self
194 195 196 |
# File 'lib/appium_lib/common/multi_touch.rb', line 194 def initialize(driver = $driver) super(driver) end |
Class Method Details
.pinch(percentage = 25, auto_perform = true, driver = $driver) ⇒ Object
Convenience method for pinching the screen. Places two fingers at the edges of the screen and brings them together. Without auto_perform
With driver
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/appium_lib/common/multi_touch.rb', line 65 def pinch(percentage = 25, auto_perform = true, driver = $driver) raise ArgumentError("Can't pinch to greater than screen size.") if percentage > 100 rate = Float(percentage) / 100 pinch = MultiTouch.new(driver) if driver.device_is_android? top, bottom = pinch_android(rate, pinch.driver) else top, bottom = pinch_ios(rate, pinch.driver) end pinch.add top pinch.add bottom return pinch unless auto_perform pinch.perform end |
.zoom(percentage = 200, auto_perform = true, driver = $driver) ⇒ Object
Convenience method for zooming the screen. Places two fingers at the edges of the screen and brings them together. Without auto_perform
With driver
108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 |
# File 'lib/appium_lib/common/multi_touch.rb', line 108 def zoom(percentage = 200, auto_perform = true, driver = $driver) raise ArgumentError("Can't zoom to smaller then screen size.") if percentage < 100 rate = 100 / Float(percentage) zoom = MultiTouch.new(driver) if driver.device_is_android? top, bottom = zoom_android(rate, zoom.driver) else top, bottom = zoom_ios(rate, zoom.driver) end zoom.add top zoom.add bottom return zoom unless auto_perform zoom.perform end |