appium_lib 13.0.2 → 15.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/rubocop.yml +4 -2
- data/CHANGELOG.md +13 -1
- data/Rakefile +8 -0
- data/appium_lib.gemspec +4 -3
- data/docs/android_docs.md +198 -303
- data/docs/ios_docs.md +236 -341
- data/docs/w3c.md +5 -1
- data/lib/appium_lib/appium.rb +0 -2
- data/lib/appium_lib/common/device.rb +0 -24
- data/lib/appium_lib/driver.rb +3 -10
- data/lib/appium_lib/version.rb +2 -2
- data/release_notes.md +21 -0
- data/test/first_test.rb +29 -0
- metadata +28 -27
- data/lib/appium_lib/common/multi_touch.rb +0 -198
- data/lib/appium_lib/common/touch_actions.rb +0 -76
data/docs/w3c.md
CHANGED
@@ -11,11 +11,15 @@ dialect #=> :w3c
|
|
11
11
|
el = find_element(:name, 'Pickers')
|
12
12
|
driver.action.click(el).perform #=> work
|
13
13
|
|
14
|
+
|
15
|
+
# Scroll/Swipe
|
14
16
|
driver.action
|
15
17
|
.move_to_location(500, 500).pointer_down(:left)
|
16
18
|
.move_to_location(0, 700)
|
17
19
|
.release.perform
|
18
20
|
|
21
|
+
|
22
|
+
# Zoom in
|
19
23
|
# multiple action chains
|
20
24
|
f1 = driver.action.add_pointer_input(:touch, 'finger1')
|
21
25
|
f1.create_pointer_move(duration: 1, x: 200, y: 500,
|
@@ -48,4 +52,4 @@ driver.perform_actions [f1, f2]
|
|
48
52
|
## Limitations
|
49
53
|
- WebDriverAgent support only `touch` as a `pointer type`.
|
50
54
|
- By default, [ruby_lib_core](https://github.com/appium/ruby_lib_core/blob/ab5d7c5ed31f318a9395e5aeafe1d0d655d3cff4/lib/appium_lib_core/common/base/w3c_bridge.rb#L26) generate `touch` based actions.
|
51
|
-
- About `pointer type` => [W3C](https://www.w3.org/TR/webdriver/#perform-actions) and [Simple WD Spec](https://github.com/jlipps/simple-wd-spec#perform-actions)
|
55
|
+
- About `pointer type` => [W3C](https://www.w3.org/TR/webdriver/#perform-actions) and [Simple WD Spec](https://github.com/jlipps/simple-wd-spec#perform-actions)
|
data/lib/appium_lib/appium.rb
CHANGED
@@ -26,8 +26,6 @@ require_relative 'sauce_labs'
|
|
26
26
|
require_relative 'common/wait'
|
27
27
|
require_relative 'common/log'
|
28
28
|
require_relative 'common/helper'
|
29
|
-
require_relative 'common/multi_touch'
|
30
|
-
require_relative 'common/touch_actions'
|
31
29
|
require_relative 'common/http_client'
|
32
30
|
require_relative 'common/device'
|
33
31
|
require_relative 'common/command'
|
@@ -15,29 +15,5 @@
|
|
15
15
|
module Appium
|
16
16
|
module Device
|
17
17
|
extend Forwardable
|
18
|
-
|
19
|
-
class << self
|
20
|
-
def extended(_mod)
|
21
|
-
add_touch_actions
|
22
|
-
end
|
23
|
-
|
24
|
-
private
|
25
|
-
|
26
|
-
def add_touch_actions
|
27
|
-
actions = Appium::TouchAction::COMPLEX_ACTIONS
|
28
|
-
actions.each do |method|
|
29
|
-
delegate_from_appium_driver(method, Appium::TouchAction)
|
30
|
-
end
|
31
|
-
|
32
|
-
# To keep compatibility
|
33
|
-
# pinch and zoom are defined in Appium::MultiTouch.
|
34
|
-
delegate_from_appium_driver(:pinch, Appium::MultiTouch)
|
35
|
-
delegate_from_appium_driver(:zoom, Appium::MultiTouch)
|
36
|
-
end
|
37
|
-
|
38
|
-
def delegate_from_appium_driver(method, delegation_target)
|
39
|
-
def_delegator delegation_target, method
|
40
|
-
end
|
41
|
-
end # class << self
|
42
18
|
end # module Device
|
43
19
|
end # module Appium
|
data/lib/appium_lib/driver.rb
CHANGED
@@ -64,8 +64,6 @@ module Appium
|
|
64
64
|
# read http://www.rubydoc.info/github/appium/ruby_lib_core/Appium/Core/Driver
|
65
65
|
attr_reader :caps
|
66
66
|
attr_reader :custom_url
|
67
|
-
attr_reader :export_session
|
68
|
-
attr_reader :export_session_path
|
69
67
|
attr_reader :default_wait
|
70
68
|
attr_reader :appium_port
|
71
69
|
attr_reader :appium_device
|
@@ -168,8 +166,6 @@ module Appium
|
|
168
166
|
|
169
167
|
@caps = @core.caps
|
170
168
|
@custom_url = @core.custom_url
|
171
|
-
@export_session = @core.export_session
|
172
|
-
@export_session_path = @core.export_session_path
|
173
169
|
@default_wait = @core.default_wait || 0
|
174
170
|
@appium_port = @core.port
|
175
171
|
@appium_wait_timeout = @core.wait_timeout
|
@@ -279,8 +275,6 @@ module Appium
|
|
279
275
|
caps: @core.caps,
|
280
276
|
automation_name: @core.automation_name,
|
281
277
|
custom_url: @core.custom_url,
|
282
|
-
export_session: @core.export_session,
|
283
|
-
export_session_path: @core.export_session_path,
|
284
278
|
default_wait: @default_wait,
|
285
279
|
sauce_username: @sauce.username,
|
286
280
|
sauce_access_key: @sauce.access_key,
|
@@ -327,7 +321,7 @@ module Appium
|
|
327
321
|
# An entry point to chain W3C actions
|
328
322
|
# Read https://www.rubydoc.info/github/appium/ruby_lib_core/Appium/Core/Base/Bridge/W3C#action-instance_method
|
329
323
|
#
|
330
|
-
# @return [
|
324
|
+
# @return [Selenium::WebDriver::PointerActions]
|
331
325
|
#
|
332
326
|
# @example
|
333
327
|
#
|
@@ -364,7 +358,7 @@ module Appium
|
|
364
358
|
def platform_version
|
365
359
|
return [] if @driver.nil?
|
366
360
|
|
367
|
-
p_version = @driver.capabilities['platformVersion']
|
361
|
+
p_version = @driver.capabilities['platformVersion']
|
368
362
|
p_version.split('.').map(&:to_i)
|
369
363
|
end
|
370
364
|
|
@@ -785,8 +779,7 @@ module Appium
|
|
785
779
|
|
786
780
|
# @since Appium 1.16.0
|
787
781
|
#
|
788
|
-
# Logs a custom event. The event is available via {::Appium::Core::Events#get}
|
789
|
-
# <code>driver.session_capabilities['events']</code> with <code>eventTimings</code> capabilities.
|
782
|
+
# Logs a custom event. The event is available via {::Appium::Core::Events#get}.
|
790
783
|
#
|
791
784
|
# @param [String] vendor The vendor prefix for the event
|
792
785
|
# @param [String] event The name of event
|
data/lib/appium_lib/version.rb
CHANGED
@@ -14,6 +14,6 @@
|
|
14
14
|
|
15
15
|
module Appium
|
16
16
|
# Version and Date are defined on the 'Appium' module, not 'Appium::Common'
|
17
|
-
VERSION = '
|
18
|
-
DATE = '2024-
|
17
|
+
VERSION = '15.0.0' unless defined? ::Appium::VERSION
|
18
|
+
DATE = '2024-04-11' unless defined? ::Appium::DATE
|
19
19
|
end
|
data/release_notes.md
CHANGED
@@ -1,3 +1,24 @@
|
|
1
|
+
#### v15.0.0 2024-04-11
|
2
|
+
|
3
|
+
- [203a605](https://github.com/appium/ruby_lib/commit/203a6052db42039c89cd000f245f1534379bc86b) Release 15.0.0
|
4
|
+
- [7ab9f44](https://github.com/appium/ruby_lib/commit/7ab9f442ee9a9d22ad021316171e6824628eeb99) chore: Update rubocop requirement from = 1.62.1 to = 1.63.0 (#1023)
|
5
|
+
- [ad20d82](https://github.com/appium/ruby_lib/commit/ad20d828e8124f37c3ab3055c744c2c76c74f563) ci: add 3.3
|
6
|
+
- [df9752c](https://github.com/appium/ruby_lib/commit/df9752c5176db395e7a427a77c4755293ff75cee) feat: remove "spec" deps (#1022)
|
7
|
+
- [c5a7216](https://github.com/appium/ruby_lib/commit/c5a7216c005bb819ff7bc3fe313e7400777b9587) test: add empty test code (#1021)
|
8
|
+
- [c450c20](https://github.com/appium/ruby_lib/commit/c450c20bae801e2f9f9ce66a9df2e352a614f73f) feat: bump ruby lib core v8 (#1018)
|
9
|
+
- [9d40e0e](https://github.com/appium/ruby_lib/commit/9d40e0e2c2cbe571fd788c12565b3cb3d92f16a4) chore: Update rubocop requirement from = 1.62.0 to = 1.62.1 (#1020)
|
10
|
+
- [98861af](https://github.com/appium/ruby_lib/commit/98861af3d779ce288937344a63aec7cbefed9db1) chore: Update rubocop requirement from = 1.61.0 to = 1.62.0 (#1017)
|
11
|
+
- [1b385bc](https://github.com/appium/ruby_lib/commit/1b385bc2bab3f45d38a4f58e8c79ddbbe58d5596) chore: Update rubocop requirement from = 1.60.2 to = 1.61.0 (#1016)
|
12
|
+
- [612d944](https://github.com/appium/ruby_lib/commit/612d944fc60b202d3e24c7e052004cef1b69c8d0) chore: Update rubocop requirement from = 1.60.1 to = 1.60.2 (#1013)
|
13
|
+
|
14
|
+
|
15
|
+
#### v14.0.0 2024-01-25
|
16
|
+
|
17
|
+
- [50cf980](https://github.com/appium/ruby_lib/commit/50cf980b570acd7d2d95ea64d1d1b0225f96c73b) Release 14.0.0
|
18
|
+
- [978ed76](https://github.com/appium/ruby_lib/commit/978ed769120338d817fd69dadeb3894549021245) bump the major version as deprecation code removal
|
19
|
+
- [ea3cc5d](https://github.com/appium/ruby_lib/commit/ea3cc5d41653f1df4b8bdad1ec36f142c1430e47) feat: remove deprecated export_session (#1015)
|
20
|
+
|
21
|
+
|
1
22
|
#### v13.0.2 2024-01-25
|
2
23
|
|
3
24
|
- [9c52fd3](https://github.com/appium/ruby_lib/commit/9c52fd3a8f0ef88d7c4e83f210ab22f817a30632) Release 13.0.2
|
data/test/first_test.rb
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
#
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
#
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
|
15
|
+
require 'minitest/autorun'
|
16
|
+
require 'minitest/reporters'
|
17
|
+
require 'minitest'
|
18
|
+
|
19
|
+
begin
|
20
|
+
Minitest::Reporters.use! [Minitest::Reporters::ProgressReporter.new]
|
21
|
+
rescue Errno::ENOENT
|
22
|
+
# Ignore since Minitest::Reporters::JUnitReporter.new fails in deleting files, sometimes
|
23
|
+
end
|
24
|
+
|
25
|
+
class SampleTest < Minitest::Test
|
26
|
+
def test_test
|
27
|
+
assert(true)
|
28
|
+
end
|
29
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: appium_lib
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 15.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- code@bootstraponline.com
|
@@ -9,28 +9,22 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2024-
|
12
|
+
date: 2024-04-11 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: appium_lib_core
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
requirements:
|
18
|
-
- - "
|
19
|
-
- !ruby/object:Gem::Version
|
20
|
-
version: '6'
|
21
|
-
- - "<"
|
18
|
+
- - "~>"
|
22
19
|
- !ruby/object:Gem::Version
|
23
|
-
version:
|
20
|
+
version: 8.0.0
|
24
21
|
type: :runtime
|
25
22
|
prerelease: false
|
26
23
|
version_requirements: !ruby/object:Gem::Requirement
|
27
24
|
requirements:
|
28
|
-
- - "
|
29
|
-
- !ruby/object:Gem::Version
|
30
|
-
version: '6'
|
31
|
-
- - "<"
|
25
|
+
- - "~>"
|
32
26
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
27
|
+
version: 8.0.0
|
34
28
|
- !ruby/object:Gem::Dependency
|
35
29
|
name: nokogiri
|
36
30
|
requirement: !ruby/object:Gem::Requirement
|
@@ -167,48 +161,56 @@ dependencies:
|
|
167
161
|
requirements:
|
168
162
|
- - '='
|
169
163
|
- !ruby/object:Gem::Version
|
170
|
-
version: 1.
|
164
|
+
version: 1.63.0
|
171
165
|
type: :development
|
172
166
|
prerelease: false
|
173
167
|
version_requirements: !ruby/object:Gem::Requirement
|
174
168
|
requirements:
|
175
169
|
- - '='
|
176
170
|
- !ruby/object:Gem::Version
|
177
|
-
version: 1.
|
171
|
+
version: 1.63.0
|
178
172
|
- !ruby/object:Gem::Dependency
|
179
|
-
name:
|
173
|
+
name: yard
|
180
174
|
requirement: !ruby/object:Gem::Requirement
|
181
175
|
requirements:
|
182
176
|
- - "~>"
|
183
177
|
- !ruby/object:Gem::Version
|
184
|
-
version:
|
185
|
-
- - ">="
|
186
|
-
- !ruby/object:Gem::Version
|
187
|
-
version: 5.3.4
|
178
|
+
version: 0.9.11
|
188
179
|
type: :development
|
189
180
|
prerelease: false
|
190
181
|
version_requirements: !ruby/object:Gem::Requirement
|
191
182
|
requirements:
|
192
183
|
- - "~>"
|
193
184
|
- !ruby/object:Gem::Version
|
194
|
-
version:
|
195
|
-
|
185
|
+
version: 0.9.11
|
186
|
+
- !ruby/object:Gem::Dependency
|
187
|
+
name: minitest
|
188
|
+
requirement: !ruby/object:Gem::Requirement
|
189
|
+
requirements:
|
190
|
+
- - "~>"
|
191
|
+
- !ruby/object:Gem::Version
|
192
|
+
version: '5.0'
|
193
|
+
type: :development
|
194
|
+
prerelease: false
|
195
|
+
version_requirements: !ruby/object:Gem::Requirement
|
196
|
+
requirements:
|
197
|
+
- - "~>"
|
196
198
|
- !ruby/object:Gem::Version
|
197
|
-
version: 5.
|
199
|
+
version: '5.0'
|
198
200
|
- !ruby/object:Gem::Dependency
|
199
|
-
name:
|
201
|
+
name: minitest-reporters
|
200
202
|
requirement: !ruby/object:Gem::Requirement
|
201
203
|
requirements:
|
202
204
|
- - "~>"
|
203
205
|
- !ruby/object:Gem::Version
|
204
|
-
version:
|
206
|
+
version: '1.1'
|
205
207
|
type: :development
|
206
208
|
prerelease: false
|
207
209
|
version_requirements: !ruby/object:Gem::Requirement
|
208
210
|
requirements:
|
209
211
|
- - "~>"
|
210
212
|
- !ruby/object:Gem::Version
|
211
|
-
version:
|
213
|
+
version: '1.1'
|
212
214
|
description: Ruby library for Appium.
|
213
215
|
email:
|
214
216
|
- code@bootstraponline.com
|
@@ -265,8 +267,6 @@ files:
|
|
265
267
|
- lib/appium_lib/common/helper.rb
|
266
268
|
- lib/appium_lib/common/http_client.rb
|
267
269
|
- lib/appium_lib/common/log.rb
|
268
|
-
- lib/appium_lib/common/multi_touch.rb
|
269
|
-
- lib/appium_lib/common/touch_actions.rb
|
270
270
|
- lib/appium_lib/common/wait.rb
|
271
271
|
- lib/appium_lib/driver.rb
|
272
272
|
- lib/appium_lib/ios/common/errors.rb
|
@@ -296,6 +296,7 @@ files:
|
|
296
296
|
- lib/appium_lib/version.rb
|
297
297
|
- readme.md
|
298
298
|
- release_notes.md
|
299
|
+
- test/first_test.rb
|
299
300
|
homepage: https://github.com/appium/ruby_lib
|
300
301
|
licenses:
|
301
302
|
- Apache-2.0
|
@@ -1,198 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
-
# you may not use this file except in compliance with the License.
|
5
|
-
# You may obtain a copy of the License at
|
6
|
-
#
|
7
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
-
#
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
-
# See the License for the specific language governing permissions and
|
13
|
-
# limitations under the License.
|
14
|
-
|
15
|
-
module Appium
|
16
|
-
# MultiTouch actions allow for multiple touches to happen at the same time,
|
17
|
-
# for instance, to simulate multiple finger swipes.
|
18
|
-
#
|
19
|
-
# Create a series of touch actions by themselves (without a `prepare()`), then
|
20
|
-
# add to a new MultiTouch action. When ready, call `prepare()` and all
|
21
|
-
# actions will be executed simultaneously.
|
22
|
-
#
|
23
|
-
# @example
|
24
|
-
#
|
25
|
-
# action_1 = TouchAction.new.press(x: 45, y: 100).wait(5).release
|
26
|
-
# action_2 = TouchAction.new.tap(element: el, x: 50, y:5, count: 3)
|
27
|
-
#
|
28
|
-
# multi_touch_action = MultiTouch.new
|
29
|
-
# multi_touch_action.add action_1
|
30
|
-
# multi_touch_action.add action_2
|
31
|
-
# multi_touch_action.perform
|
32
|
-
#
|
33
|
-
# # with an arbitrary driver
|
34
|
-
# driver = Appium::Driver.new(opts, false).start_driver # return an Appium::Core::Base::Driver instance
|
35
|
-
# multi_touch_action = MultiTouch.new(driver)
|
36
|
-
# multi_touch_action.add action_1
|
37
|
-
# multi_touch_action.add action_2
|
38
|
-
# multi_touch_action.perform
|
39
|
-
#
|
40
|
-
class MultiTouch < Core::MultiTouch
|
41
|
-
class << self
|
42
|
-
# Convenience method for pinching the screen.
|
43
|
-
# Places two fingers at the edges of the screen and brings them together.
|
44
|
-
# @param percentage (int) The percent size by which to shrink the screen when pinched.
|
45
|
-
# @param auto_perform (boolean) Whether to perform the action immediately (default true)
|
46
|
-
# @param driver (Driver) Set a driver to conduct the action. DEfault is global driver($driver)
|
47
|
-
#
|
48
|
-
# @example
|
49
|
-
#
|
50
|
-
# pinch 75 #=> Pinch the screen from the top right and bottom left corners
|
51
|
-
#
|
52
|
-
# Without auto_perform
|
53
|
-
#
|
54
|
-
# @example
|
55
|
-
#
|
56
|
-
# action = pinch 75, false #=> Pinch the screen from the top right and bottom left corners
|
57
|
-
# action.perform #=> to 25% of its size.
|
58
|
-
#
|
59
|
-
# With driver
|
60
|
-
#
|
61
|
-
# @example
|
62
|
-
# driver = Appium::Driver.new(opts, false).start_driver
|
63
|
-
# pinch 75, true, driver #=> Pinch the screen from the top right and bottom left corners
|
64
|
-
#
|
65
|
-
def pinch(percentage = 25, auto_perform = true, driver = $driver)
|
66
|
-
raise ArgumentError("Can't pinch to greater than screen size.") if percentage > 100
|
67
|
-
|
68
|
-
rate = Float(percentage) / 100
|
69
|
-
pinch = MultiTouch.new(driver)
|
70
|
-
|
71
|
-
if driver.device_is_android?
|
72
|
-
top, bottom = pinch_android(rate, pinch.driver)
|
73
|
-
else
|
74
|
-
top, bottom = pinch_ios(rate, pinch.driver)
|
75
|
-
end
|
76
|
-
|
77
|
-
pinch.add top
|
78
|
-
pinch.add bottom
|
79
|
-
return pinch unless auto_perform
|
80
|
-
|
81
|
-
pinch.perform
|
82
|
-
end
|
83
|
-
|
84
|
-
# Convenience method for zooming the screen.
|
85
|
-
# Places two fingers at the edges of the screen and brings them together.
|
86
|
-
# @param percentage (int) The percent size by which to shrink the screen when pinched.
|
87
|
-
# @param auto_perform (boolean) Whether to perform the action immediately (default true)
|
88
|
-
# @param driver (Driver) Set a driver to conduct the action. DEfault is global driver($driver)
|
89
|
-
#
|
90
|
-
# @example
|
91
|
-
#
|
92
|
-
# action = zoom 200 #=> Zoom in the screen from the center until it doubles in size.
|
93
|
-
#
|
94
|
-
# Without auto_perform
|
95
|
-
#
|
96
|
-
# @example
|
97
|
-
#
|
98
|
-
# action = zoom 200, false #=> Zoom in the screen from the center until it doubles in size.
|
99
|
-
# action.perform #=> to 25% of its size.
|
100
|
-
#
|
101
|
-
# With driver
|
102
|
-
#
|
103
|
-
# @example
|
104
|
-
#
|
105
|
-
# driver = Appium::Driver.new(opts, false).start_driver
|
106
|
-
# pinch 200, true, driver #=> Zoom in the screen from the center until it doubles in size.
|
107
|
-
#
|
108
|
-
def zoom(percentage = 200, auto_perform = true, driver = $driver)
|
109
|
-
raise ArgumentError("Can't zoom to smaller then screen size.") if percentage < 100
|
110
|
-
|
111
|
-
rate = 100 / Float(percentage)
|
112
|
-
zoom = MultiTouch.new(driver)
|
113
|
-
|
114
|
-
if driver.device_is_android?
|
115
|
-
top, bottom = zoom_android(rate, zoom.driver)
|
116
|
-
else
|
117
|
-
top, bottom = zoom_ios(rate, zoom.driver)
|
118
|
-
end
|
119
|
-
|
120
|
-
zoom.add top
|
121
|
-
zoom.add bottom
|
122
|
-
return zoom unless auto_perform
|
123
|
-
|
124
|
-
zoom.perform
|
125
|
-
end
|
126
|
-
|
127
|
-
private
|
128
|
-
|
129
|
-
# @private
|
130
|
-
def pinch_android(rate, driver)
|
131
|
-
height = 100
|
132
|
-
offset = 100
|
133
|
-
|
134
|
-
top = ::Appium::Core::TouchAction.new(driver)
|
135
|
-
top.swipe start_x: offset, start_y: 1.0 * height + offset,
|
136
|
-
end_x: 0.0, end_y: (rate - 1) * height, duration: 1_000
|
137
|
-
|
138
|
-
bottom = ::Appium::Core::TouchAction.new(driver)
|
139
|
-
bottom.swipe start_x: offset, start_y: 0.0 + offset,
|
140
|
-
end_x: 0.0, end_y: (1 - rate) * height, duration: 1_000
|
141
|
-
|
142
|
-
[top, bottom]
|
143
|
-
end
|
144
|
-
|
145
|
-
# @private
|
146
|
-
def pinch_ios(rate, driver)
|
147
|
-
height = 100
|
148
|
-
offset = 100
|
149
|
-
|
150
|
-
top = ::Appium::Core::TouchAction.new(driver)
|
151
|
-
top.swipe start_x: 0.5, start_y: 0.0 + offset,
|
152
|
-
end_x: 0.0, end_y: (1 - rate) * height, duration: 1_000
|
153
|
-
|
154
|
-
bottom = ::Appium::Core::TouchAction.new(driver)
|
155
|
-
bottom.swipe start_x: 0.5, start_y: 1.0 + offset,
|
156
|
-
end_x: 0.0, end_y: rate * height, duration: 1_000
|
157
|
-
|
158
|
-
[top, bottom]
|
159
|
-
end
|
160
|
-
|
161
|
-
# @private
|
162
|
-
def zoom_android(rate, driver)
|
163
|
-
height = 100
|
164
|
-
offset = 100
|
165
|
-
|
166
|
-
top = ::Appium::Core::TouchAction.new(driver)
|
167
|
-
top.swipe start_x: offset, start_y: (1.0 - rate) * height + offset,
|
168
|
-
end_x: 0.0, end_y: (rate - 1.0) * height, duration: 1_000
|
169
|
-
|
170
|
-
bottom = ::Appium::Core::TouchAction.new(driver)
|
171
|
-
bottom.swipe start_x: offset, start_y: rate * height + offset,
|
172
|
-
end_x: 0.0, end_y: (1.0 - rate) * height, duration: 1_000
|
173
|
-
|
174
|
-
[top, bottom]
|
175
|
-
end
|
176
|
-
|
177
|
-
# @private
|
178
|
-
def zoom_ios(rate, driver)
|
179
|
-
height = 100
|
180
|
-
offset = 100
|
181
|
-
|
182
|
-
top = ::Appium::Core::TouchAction.new(driver)
|
183
|
-
top.swipe start_x: 0.5, start_y: (1 - rate) * height + offset,
|
184
|
-
end_x: 0.0, end_y: - (1 - rate) * height, duration: 1_000
|
185
|
-
|
186
|
-
bottom = ::Appium::Core::TouchAction.new(driver)
|
187
|
-
bottom.swipe start_x: 0.5, start_y: rate * height + offset,
|
188
|
-
end_x: 0.0, end_y: (1 - rate) * height, duration: 1_000
|
189
|
-
|
190
|
-
[top, bottom]
|
191
|
-
end
|
192
|
-
end # self
|
193
|
-
|
194
|
-
def initialize(driver = $driver)
|
195
|
-
super(driver)
|
196
|
-
end
|
197
|
-
end # class MultiTouch
|
198
|
-
end # module Appium
|
@@ -1,76 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
-
# you may not use this file except in compliance with the License.
|
5
|
-
# You may obtain a copy of the License at
|
6
|
-
#
|
7
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
-
#
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
-
# See the License for the specific language governing permissions and
|
13
|
-
# limitations under the License.
|
14
|
-
|
15
|
-
module Appium
|
16
|
-
# Perform a series of gestures, one after another. Gestures are chained
|
17
|
-
# together and only performed when `perform()` is called. Default is conducted by global driver.
|
18
|
-
#
|
19
|
-
# Each method returns the object itself, so calls can be chained.
|
20
|
-
#
|
21
|
-
# @example
|
22
|
-
#
|
23
|
-
# action = TouchAction.new.press(x: 45, y: 100).wait(5).release
|
24
|
-
# action.perform
|
25
|
-
# action = TouchAction.new.swipe(....)
|
26
|
-
# action.perform
|
27
|
-
#
|
28
|
-
# Or each methods can call without `TouchAction.new` as the following.
|
29
|
-
# In this case, `perform` is called automatically.
|
30
|
-
#
|
31
|
-
# @example
|
32
|
-
#
|
33
|
-
# # called `swipe(...).perform` in this method.
|
34
|
-
# swipe(start_x: 75, start_y: 500, end_x: 75, end_y: 20, duration: 500)
|
35
|
-
#
|
36
|
-
# If you'd like to perform the chain with an arbitrary driver:
|
37
|
-
#
|
38
|
-
# @example
|
39
|
-
#
|
40
|
-
# driver = Appium::Driver.new(opts, false).start_driver # return an Appium::Core::Base::Driver instance
|
41
|
-
# action = TouchAction.new(driver).press(x: 45, y: 100).wait(5).release
|
42
|
-
# action.perform
|
43
|
-
# action = TouchAction.new(driver).swipe(....)
|
44
|
-
# action.perform
|
45
|
-
#
|
46
|
-
class TouchAction < ::Appium::Core::TouchAction
|
47
|
-
COMPLEX_ACTIONS = ::Appium::Core::TouchAction::COMPLEX_ACTIONS
|
48
|
-
|
49
|
-
class << self
|
50
|
-
COMPLEX_ACTIONS.each do |action|
|
51
|
-
define_method(action) do |opts|
|
52
|
-
auto_perform = opts.delete(:auto_perform) { |_k| true }
|
53
|
-
ta = ::Appium::TouchAction.new($driver)
|
54
|
-
ta.send(action, opts)
|
55
|
-
return ta unless auto_perform
|
56
|
-
|
57
|
-
ta.perform
|
58
|
-
end
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
def initialize(driver = $driver)
|
63
|
-
super driver
|
64
|
-
end
|
65
|
-
|
66
|
-
def swipe(opts)
|
67
|
-
start_x = opts.fetch :start_x, 0
|
68
|
-
start_y = opts.fetch :start_y, 0
|
69
|
-
end_x = opts.fetch :end_x, 0
|
70
|
-
end_y = opts.fetch :end_y, 0
|
71
|
-
duration = opts.fetch :duration, 200
|
72
|
-
|
73
|
-
super(start_x: start_x, start_y: start_y, end_x: end_x, end_y: end_y, duration: duration)
|
74
|
-
end
|
75
|
-
end # class TouchAction
|
76
|
-
end # module Appium
|