appium_lib 9.2.0 → 9.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +26 -0
- data/android_tests/lib/android/specs/common/device_touchaction.rb +1 -1
- data/android_tests/lib/android/specs/device/touch_actions.rb +40 -1
- data/android_tests/lib/android/specs/driver.rb +3 -1
- data/appium_lib.gemspec +1 -0
- data/docs/android_docs.md +361 -231
- data/docs/ios_docs.md +391 -251
- data/ios_tests/appium.txt +3 -1
- data/ios_tests/lib/ios/specs/common/helper.rb +1 -1
- data/ios_tests/lib/ios/specs/device/device.rb +1 -1
- data/ios_tests/lib/ios/specs/device/touch_actions.rb +53 -1
- data/ios_tests/lib/ios/specs/driver.rb +3 -1
- data/ios_tests/lib/ios/specs/ios/element/button.rb +1 -2
- data/ios_tests/lib/ios/specs/ios/element/text.rb +2 -2
- data/ios_tests/lib/ios/specs/ios/element/textfield.rb +3 -1
- data/ios_tests/lib/ios/specs/ios/patch.rb +1 -6
- data/lib/appium_lib/common/version.rb +2 -2
- data/lib/appium_lib/common/wait.rb +6 -6
- data/lib/appium_lib/device/device.rb +53 -49
- data/lib/appium_lib/device/multi_touch.rb +99 -27
- data/lib/appium_lib/device/touch_actions.rb +38 -20
- data/lib/appium_lib/driver.rb +58 -24
- data/lib/appium_lib/ios/element/button.rb +6 -6
- data/lib/appium_lib/ios/element/generic.rb +30 -10
- data/lib/appium_lib/ios/element/text.rb +8 -8
- data/lib/appium_lib/ios/element/textfield.rb +9 -6
- data/lib/appium_lib/ios/helper.rb +17 -18
- data/release_notes.md +15 -0
- metadata +22 -2
data/ios_tests/appium.txt
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
[caps]
|
2
2
|
platformName = "ios"
|
3
|
-
platformVersion = "10.
|
3
|
+
platformVersion = "10.2"
|
4
4
|
deviceName ="iPhone Simulator"
|
5
5
|
automationName = 'XCUITest'
|
6
6
|
app = "./UICatalog.app"
|
@@ -9,3 +9,5 @@ app = "./UICatalog.app"
|
|
9
9
|
sauce_username = ""
|
10
10
|
sauce_access_key = ""
|
11
11
|
wait = 30
|
12
|
+
wait_timeout = 20
|
13
|
+
wait_interval = 1
|
@@ -146,7 +146,7 @@ describe 'common/helper.rb' do
|
|
146
146
|
end
|
147
147
|
|
148
148
|
t 'last_ele' do
|
149
|
-
expected =
|
149
|
+
expected = 'Transitions'
|
150
150
|
|
151
151
|
el = last_ele(UI::Inventory.static_text)
|
152
152
|
el.text.must_equal expected
|
@@ -16,10 +16,62 @@ describe 'device/touch_actions' do
|
|
16
16
|
size = picker.size.to_h
|
17
17
|
start_x = loc[:x] + size[:width] / 2
|
18
18
|
start_y = loc[:y] + size[:height] / 2
|
19
|
-
|
19
|
+
# rubocop:disable Metrics/LineLength
|
20
|
+
# Example for iOS's log with XCUITest
|
21
|
+
# [0] pry(#<device/touch_actions>)> swipe start_x: start_x, start_y: start_y, offset_x: 0, offset_y: - 50
|
22
|
+
# [debug] [WebDriverAgent] Sim: Jan 14 16:35:05 rrcs-172-254-99-35 CoreSimulatorBridge[65868]: KEYMAP: Chose mode=en_US@hw=Automatic;sw=QWERTY from match=en_US@hw=Automatic;sw=QWERTY from language=en
|
23
|
+
# [HTTP] --> POST /wd/hub/session/cd65fa75-cbd7-4348-a7d6-60cbde28db47/touch/perform {"actions":[{"action":"press","options":{"x":187,"y":201}},{"action":"wait","options":{"ms":200}},{"action":"moveTo","options":{"x":0,"y":-50}},{"action":"release"}]}
|
24
|
+
# [debug] [MJSONWP] Calling AppiumDriver.performTouch() with args: [[{"action":"press","options":{"x":187,"y":201}},{"action":"wait","options":{"ms":200}},{"action":"moveTo","options":{"x":0,"y":-50}},{"action":"release"}],"cd65fa75-cbd7-4348-a7d6-60cbde28db47"]
|
25
|
+
# [debug] [XCUITest] Executing command 'performTouch'
|
26
|
+
# [debug] [XCUITest] Received the following touch action: press-wait-moveTo-release
|
27
|
+
# [debug] [JSONWP Proxy] Proxying [POST /uiaTarget/0/dragfromtoforduration] to [POST http://localhost:8100/session/0D2991FB-A997-4D6C-94FC-D65CC252EC4B/uiaTarget/0/dragfromtoforduration] with body: {"fromX":187,"fromY":201,"toX":187,"toY":151,"duration":0.2}
|
28
|
+
# [debug] [WebDriverAgent] Sim: Jan 14 16:35:05 rrcs-172-254-99-35 CoreSimulatorBridge[65868]: Switching to keyboard: en
|
29
|
+
#
|
30
|
+
# Example for iOS's log with Instruments
|
31
|
+
# [0] pry(#<device/touch_actions>)> swipe start_x: start_x, start_y: start_y, offset_x: 0, offset_y: - 50, duration: 1000
|
32
|
+
# [HTTP] <-- POST /wd/hub/session/8b651f03-0fbc-43f0-aaf2-243d0650f6aa/touch/perform 200 2048 ms - 74
|
33
|
+
# [HTTP] --> POST /wd/hub/session/8b651f03-0fbc-43f0-aaf2-243d0650f6aa/touch/perform {"actions":[{"action":"press","options":{"x":187,"y":201.078125}},{"action":"wait","options":{"ms":1000}},{"action":"moveTo","options":{"x":0,"y":-50}},{"action":"release"}]}
|
34
|
+
# [debug] [MJSONWP] Calling AppiumDriver.performTouch() with args: [[{"action":"press","options":{"x":187,"y":201.078125}},{"action":"wait","options":{"ms":1000}},{"action":"moveTo","options":{"x":0,"y":-50}},{"action":"release"}],"8b651f03-0fbc-43f0-aaf2-243d0650f6aa"]
|
35
|
+
# [debug] [iOS] Executing iOS command 'performTouch'
|
36
|
+
# [debug] [UIAuto] Sending command to instruments: au.dragApp(187, 201.078125, 187, 151.078125, 1)
|
37
|
+
# [debug] [Instruments] [INST] 2017-01-14 08:22:57 +0000 Debug: Got new command 12 from instruments: au.dragApp(187, 201.078125, 187, 151.078125, 1)
|
38
|
+
# [debug] [Instruments] [INST] 2017-01-14 08:22:57 +0000 Debug: evaluating au.dragApp(187, 201.078125, 187, 151.078125, 1)
|
39
|
+
# [debug] [Instruments] [INST] 2017-01-14 08:22:57 +0000 Debug: target.dragFromToForDuration({x:"187", y:"201.078125"}, {x:"187", y:"151.078125"}, "1")
|
40
|
+
# [debug] [Instruments] [INST] 2017-01-14 08:22:58 +0000 Debug: evaluation finished
|
41
|
+
# [debug] [Instruments] [INST] 2017-01-14 08:22:58 +0000 Debug: responding with:
|
42
|
+
# [debug] [UIAuto] Socket data received (25 bytes)
|
43
|
+
# [debug] [UIAuto] Got result from instruments: {"status":0,"value":""}
|
44
|
+
# [debug] [MJSONWP] Responding to client with driver.performTouch() result: ""
|
45
|
+
# [HTTP] <-- POST /wd/hub/session/8b651f03-0fbc-43f0-aaf2-243d0650f6aa/touch/perform 200 1895 ms - 74
|
46
|
+
# rubocop:enable Metrics/LineLength
|
47
|
+
swipe start_x: start_x, start_y: start_y, offset_x: 0, offset_y: - 50
|
20
48
|
ele_index(UI::Inventory.static_text, 2).text.must_equal 'Chris Armstrong - 0'
|
21
49
|
end
|
22
50
|
|
51
|
+
t 'swipe_coordinates_end_x_end_y' do
|
52
|
+
s = Appium::TouchAction.new.swipe_coordinates(offset_x: 1, offset_y: 2)
|
53
|
+
s[:offset_x].must_equal 1
|
54
|
+
s[:offset_y].must_equal 2
|
55
|
+
end
|
56
|
+
|
57
|
+
t 'swipe_coordinates_end_x' do
|
58
|
+
s = Appium::TouchAction.new.swipe_coordinates(offset_x: 1)
|
59
|
+
s[:offset_x].must_equal 1
|
60
|
+
s[:offset_y].must_equal 0
|
61
|
+
end
|
62
|
+
|
63
|
+
t 'swipe_coordinates_end_y' do
|
64
|
+
s = Appium::TouchAction.new.swipe_coordinates(offset_y: 1)
|
65
|
+
s[:offset_x].must_equal 0
|
66
|
+
s[:offset_y].must_equal 1
|
67
|
+
end
|
68
|
+
|
69
|
+
t 'swipe_coordinates_offset' do
|
70
|
+
s = Appium::TouchAction.new.swipe_coordinates
|
71
|
+
s[:offset_x].must_equal 0
|
72
|
+
s[:offset_y].must_equal 0
|
73
|
+
end
|
74
|
+
|
23
75
|
t 'after_last' do
|
24
76
|
after_last
|
25
77
|
end
|
@@ -50,7 +50,9 @@ describe 'driver' do
|
|
50
50
|
port: 4723,
|
51
51
|
device: :ios,
|
52
52
|
debug: true,
|
53
|
-
listener: nil
|
53
|
+
listener: nil,
|
54
|
+
wait_timeout: 20, # defined in appium.txt
|
55
|
+
wait_interval: 1 } # defined in appium.txt
|
54
56
|
|
55
57
|
if actual != expected
|
56
58
|
diff = HashDiff.diff expected, actual
|
@@ -29,7 +29,6 @@ describe 'ios/element/button' do
|
|
29
29
|
|
30
30
|
t 'buttons' do
|
31
31
|
exp = ['Back', 'Back', 'Gray', 'Right pointing arrow']
|
32
|
-
exp.concat ['Add contact'] if UI::Inventory.xcuitest?
|
33
32
|
|
34
33
|
target_buttons = buttons('a')
|
35
34
|
target_buttons.map(&:name).must_equal exp
|
@@ -41,7 +40,7 @@ describe 'ios/element/button' do
|
|
41
40
|
end
|
42
41
|
|
43
42
|
t 'last_button' do
|
44
|
-
expected =
|
43
|
+
expected = 'Rounded'
|
45
44
|
last_button.name.must_equal expected
|
46
45
|
end
|
47
46
|
|
@@ -23,7 +23,7 @@ describe 'ios/element/text' do
|
|
23
23
|
end
|
24
24
|
|
25
25
|
t 'last_text' do
|
26
|
-
expected =
|
26
|
+
expected = 'Transitions'
|
27
27
|
|
28
28
|
last_text.text.must_equal expected
|
29
29
|
last_text.name.must_equal expected
|
@@ -37,7 +37,7 @@ describe 'ios/element/text' do
|
|
37
37
|
|
38
38
|
t 'texts' do
|
39
39
|
exp = ['Controls', 'Various uses of UIControl', 'Various uses of UISegmentedControl']
|
40
|
-
texts.length.must_equal
|
40
|
+
texts.length.must_equal 24
|
41
41
|
texts('trol').map(&:name).must_equal exp
|
42
42
|
texts('uses').length.must_equal 7
|
43
43
|
end
|
@@ -71,9 +71,11 @@ describe 'ios/element/textfield' do
|
|
71
71
|
t 'textfield type' do
|
72
72
|
# Regular send keys triggers the keyboard and doesn't dismiss
|
73
73
|
keyboard_must_not_exist unless UI::Inventory.xcuitest? # xcuitest doesn't support JS command
|
74
|
-
textfield(1).send_keys '
|
74
|
+
textfield(1).send_keys "o'k"
|
75
75
|
keyboard_must_exist unless UI::Inventory.xcuitest? # xcuitest doesn't support JS command
|
76
76
|
|
77
|
+
find_exact("o'k").text.must_equal "o'k"
|
78
|
+
|
77
79
|
unless UI::Inventory.xcuitest?
|
78
80
|
# type should not dismiss the keyboard
|
79
81
|
message = 'type test type'
|
@@ -14,12 +14,7 @@ describe 'ios/patch' do
|
|
14
14
|
end
|
15
15
|
|
16
16
|
t 'label' do
|
17
|
-
|
18
|
-
# Order of the elements are: Normal, Rounded, Secure, Check
|
19
|
-
find_element(:name, '<enter text>').label.must_equal 'Normal'
|
20
|
-
else
|
21
|
-
textfield('<enter text>').label.must_equal 'Rounded'
|
22
|
-
end
|
17
|
+
textfield('<enter text>').label.must_equal 'Rounded'
|
23
18
|
end
|
24
19
|
|
25
20
|
t 'type' do
|
@@ -1,5 +1,5 @@
|
|
1
1
|
module Appium
|
2
2
|
# Version and Date are defined on the 'Appium' module, not 'Appium::Common'
|
3
|
-
VERSION = '9.
|
4
|
-
DATE = '2017-01-
|
3
|
+
VERSION = '9.3.0'.freeze unless defined? ::Appium::VERSION
|
4
|
+
DATE = '2017-01-22'.freeze unless defined? ::Appium::DATE
|
5
5
|
end
|
@@ -13,8 +13,8 @@ module Appium
|
|
13
13
|
# [:one, :two] => :one, :two
|
14
14
|
raise "Invalid keys #{invalid_keys.to_s[1..-2]}. Valid keys are #{valid_keys.to_s[1..-2]}" unless invalid_keys.empty?
|
15
15
|
|
16
|
-
timeout = opts.fetch(:timeout,
|
17
|
-
interval = opts.fetch(:interval,
|
16
|
+
timeout = opts.fetch(:timeout, @appium_wait_timeout)
|
17
|
+
interval = opts.fetch(:interval, @appium_wait_interval)
|
18
18
|
message = opts[:message]
|
19
19
|
ignored = Array(opts[:ignore] || ::Exception)
|
20
20
|
return_if_true = opts[:return_if_true]
|
@@ -62,8 +62,8 @@ module Appium
|
|
62
62
|
# If only a number is provided then it's treated as the timeout value.
|
63
63
|
#
|
64
64
|
# @param [Hash] opts Options
|
65
|
-
# @option opts [Numeric] :timeout
|
66
|
-
# @option opts [Numeric] :interval
|
65
|
+
# @option opts [Numeric] :timeout Seconds to wait before timing out. Set default by `appium_wait_timeout` (30).
|
66
|
+
# @option opts [Numeric] :interval Seconds to sleep between polls. Set default by `appium_wait_interval` (0.5).
|
67
67
|
# @option opts [String] :message Exception message if timed out.
|
68
68
|
# @option opts [Array, Exception] :ignore Exceptions to ignore while polling (default: Exception)
|
69
69
|
def wait_true(opts = {}, &block)
|
@@ -80,8 +80,8 @@ module Appium
|
|
80
80
|
# If only a number is provided then it's treated as the timeout value.
|
81
81
|
#
|
82
82
|
# @param [Hash] opts Options
|
83
|
-
# @option opts [Numeric] :timeout
|
84
|
-
# @option opts [Numeric] :interval
|
83
|
+
# @option opts [Numeric] :timeout Seconds to wait before timing out. Set default by `appium_wait_timeout` (30).
|
84
|
+
# @option opts [Numeric] :interval Seconds to sleep between polls. Set default by `appium_wait_interval` (0.5).
|
85
85
|
# @option opts [String] :message Exception message if timed out.
|
86
86
|
# @option opts [Array, Exception] :ignore Exceptions to ignore while polling (default: Exception)
|
87
87
|
def wait(opts = {}, &block)
|
@@ -33,7 +33,7 @@ module Appium
|
|
33
33
|
|
34
34
|
# @!method hide_keyboard
|
35
35
|
# Hide the onscreen keyboard
|
36
|
-
# @param close_key
|
36
|
+
# @param [String] close_key The name of the key which closes the keyboard.
|
37
37
|
# Defaults to 'Done'.
|
38
38
|
# ```ruby
|
39
39
|
# hide_keyboard # Close a keyboard with the 'Done' button
|
@@ -43,24 +43,24 @@ module Appium
|
|
43
43
|
# @!method press_keycode
|
44
44
|
# Press keycode on the device.
|
45
45
|
# http://developer.android.com/reference/android/view/KeyEvent.html
|
46
|
-
# @param key
|
47
|
-
# @param metastate
|
46
|
+
# @param [integer] key The key to press.
|
47
|
+
# @param [String] metastate The state the metakeys should be in when pressing the key.
|
48
48
|
|
49
49
|
# @!method long_press_keycode
|
50
50
|
# Long press keycode on the device.
|
51
51
|
# http://developer.android.com/reference/android/view/KeyEvent.html
|
52
|
-
# @param key
|
53
|
-
# @param metastate
|
52
|
+
# @param [integer] key The key to long press.
|
53
|
+
# @param [String] metastate The state the metakeys should be in when long pressing the key.
|
54
54
|
|
55
55
|
# @!method push_file
|
56
56
|
# Place a file in a specific location on the device.
|
57
|
-
# @param path
|
58
|
-
# @param data
|
57
|
+
# @param [String] path The absolute path on the device to store data at.
|
58
|
+
# @param [String] data Raw file data to be sent to the device.
|
59
59
|
|
60
60
|
# @!method pull_file
|
61
61
|
# Retrieve a file from the device. This can retrieve an absolute path or
|
62
62
|
# a path relative to the installed app (iOS only).
|
63
|
-
# @param path
|
63
|
+
# @param [String] path Either an absolute path OR, for iOS devices, a path relative to the app, as described.
|
64
64
|
#
|
65
65
|
# ```ruby
|
66
66
|
# pull_file '/local/data/some/path' #=> Get the file at that path
|
@@ -69,7 +69,7 @@ module Appium
|
|
69
69
|
|
70
70
|
# @!method pull_folder
|
71
71
|
# Retrieve a folder from the device.
|
72
|
-
# @param path
|
72
|
+
# @param [String] path absolute path to the folder
|
73
73
|
#
|
74
74
|
# ```ruby
|
75
75
|
# pull_folder '/data/local/tmp' #=> Get the folder at that path
|
@@ -77,7 +77,7 @@ module Appium
|
|
77
77
|
|
78
78
|
# @!method touch_id
|
79
79
|
# iOS only; Simulate Touch ID with either valid (match == true) or invalid (match == false) fingerprint.
|
80
|
-
# @param match
|
80
|
+
# @param [Boolean] match fingerprint validity
|
81
81
|
# Defaults to true.
|
82
82
|
# ```ruby
|
83
83
|
# touch_id true #=> Simulate valid fingerprint
|
@@ -86,15 +86,55 @@ module Appium
|
|
86
86
|
|
87
87
|
# @!method end_coverage
|
88
88
|
# Android only; Ends the test coverage and writes the results to the given path on device.
|
89
|
-
# @param path
|
90
|
-
# @param intent
|
89
|
+
# @param [String] path Path on the device to write too.
|
90
|
+
# @param [String] intent Intent to broadcast when ending coverage.
|
91
91
|
|
92
92
|
# @!method get_settings
|
93
93
|
# Get appium Settings for current test session
|
94
94
|
|
95
95
|
# @!method update_settings
|
96
96
|
# Update appium Settings for current test session
|
97
|
-
# @param settings
|
97
|
+
# @param [Hash] settings Settings to update, keys are settings, values to value to set each setting to
|
98
|
+
|
99
|
+
# @!method start_activity
|
100
|
+
# Start a new activity within the current app or launch a new app and start the target activity.
|
101
|
+
#
|
102
|
+
# Android only.
|
103
|
+
# @option [String] The package owning the activity [required]
|
104
|
+
# @option [String] The target activity [required]
|
105
|
+
# @option opts [String] The package to start before the target package [optional]
|
106
|
+
# @option opts [String] The activity to start before the target activity [optional]
|
107
|
+
#
|
108
|
+
# ```ruby
|
109
|
+
# start_activity app_package: 'io.appium.android.apis',
|
110
|
+
# app_activity: '.accessibility.AccessibilityNodeProviderActivity'
|
111
|
+
# ```
|
112
|
+
|
113
|
+
# @!method get_network_connection
|
114
|
+
# Get the device network connection current status
|
115
|
+
# See set_network_connection method for return value
|
116
|
+
|
117
|
+
# @!method set_network_connection
|
118
|
+
# Set the device network connection mode
|
119
|
+
# @param [String] path Bit mask that represent the network mode
|
120
|
+
#
|
121
|
+
# Value (Alias) | Data | Wifi | Airplane Mode
|
122
|
+
# -------------------------------------------------
|
123
|
+
# 1 (Airplane Mode) | 0 | 0 | 1
|
124
|
+
# 6 (All network on) | 1 | 1 | 0
|
125
|
+
# 4 (Data only) | 1 | 0 | 0
|
126
|
+
# 2 (Wifi only) | 0 | 1 | 0
|
127
|
+
# 0 (None) | 0 | 0 | 0
|
128
|
+
#
|
129
|
+
|
130
|
+
# @!method set_immediate_value
|
131
|
+
# Set the value to element directly
|
132
|
+
# for iOS; setValue is called in XCUITest instead because XCUITest doesn't provide set value directly.
|
133
|
+
# https://github.com/appium/appium-xcuitest-driver/blob/793cdc7d5e84bd553e375076e1c6dc7e242c9cde/lib/commands/element.js#L123
|
134
|
+
#
|
135
|
+
# ```ruby
|
136
|
+
# set_immediate_value element, 'hello'
|
137
|
+
# ```
|
98
138
|
class << self
|
99
139
|
def extended(_mod)
|
100
140
|
extend_webdriver_with_forwardable
|
@@ -147,19 +187,6 @@ module Appium
|
|
147
187
|
end
|
148
188
|
end
|
149
189
|
|
150
|
-
# @!method start_activity
|
151
|
-
# Start a new activity within the current app or launch a new app and start the target activity.
|
152
|
-
#
|
153
|
-
# Android only.
|
154
|
-
# @param [String] The package owning the activity [required]
|
155
|
-
# @param [String] The target activity [required]
|
156
|
-
# @param [String] The package to start before the target package [optional]
|
157
|
-
# @param [String] The activity to start before the target activity [optional]
|
158
|
-
#
|
159
|
-
# ```ruby
|
160
|
-
# start_activity app_package: 'io.appium.android.apis',
|
161
|
-
# app_activity: '.accessibility.AccessibilityNodeProviderActivity'
|
162
|
-
# ```
|
163
190
|
add_endpoint_method(:start_activity) do
|
164
191
|
def start_activity(opts)
|
165
192
|
raise 'opts must be a hash' unless opts.is_a? Hash
|
@@ -220,14 +247,6 @@ module Appium
|
|
220
247
|
end
|
221
248
|
end
|
222
249
|
|
223
|
-
# @!method set_immediate_value
|
224
|
-
# Set the value to element directly
|
225
|
-
# for iOS; setValue is called in XCUITest instead because XCUITest doesn't provide set value directly.
|
226
|
-
# https://github.com/appium/appium-xcuitest-driver/blob/793cdc7d5e84bd553e375076e1c6dc7e242c9cde/lib/commands/element.js#L123
|
227
|
-
#
|
228
|
-
# ```ruby
|
229
|
-
# set_immediate_value element, 'hello'
|
230
|
-
# ```
|
231
250
|
add_endpoint_method(:set_immediate_value) do
|
232
251
|
def set_immediate_value(element, *value)
|
233
252
|
keys = ::Selenium::WebDriver::Keys.encode(value)
|
@@ -283,21 +302,6 @@ module Appium
|
|
283
302
|
end
|
284
303
|
end
|
285
304
|
|
286
|
-
# @!method get_network_connection
|
287
|
-
# Get the device network connection current status
|
288
|
-
# See set_network_connection method for return value
|
289
|
-
|
290
|
-
# @!method set_network_connection
|
291
|
-
# Set the device network connection mode
|
292
|
-
# @param path (String) Bit mask that represent the network mode
|
293
|
-
# Value (Alias) | Data | Wifi | Airplane Mode
|
294
|
-
# -------------------------------------------------
|
295
|
-
# 1 (Airplane Mode) | 0 | 0 | 1
|
296
|
-
# 6 (All network on) | 1 | 1 | 0
|
297
|
-
# 4 (Data only) | 1 | 0 | 0
|
298
|
-
# 2 (Wifi only) | 0 | 1 | 0
|
299
|
-
# 0 (None) | 0 | 0 | 0
|
300
|
-
#
|
301
305
|
add_endpoint_method(:set_network_connection) do
|
302
306
|
def set_network_connection(mode)
|
303
307
|
execute :set_network_connection, {}, type: mode
|
@@ -28,21 +28,14 @@ module Appium
|
|
28
28
|
def pinch(percentage = 25, auto_perform = true)
|
29
29
|
raise ArgumentError("Can't pinch to greater than screen size.") if percentage > 100
|
30
30
|
|
31
|
-
|
31
|
+
rate = Float(percentage) / 100
|
32
32
|
|
33
33
|
if $driver.automation_name_is_xcuitest?
|
34
|
-
|
35
|
-
|
36
|
-
top
|
37
|
-
|
38
|
-
bottom = TouchAction.new
|
39
|
-
bottom.swipe({ start_x: 0.0, start_y: 1.0, delta_x: p, delta_y: -p }, ele)
|
34
|
+
top, bottom = pinch_for_xcuitest(rate)
|
35
|
+
elsif $driver.device_is_android?
|
36
|
+
top, bottom = pinch_android(rate)
|
40
37
|
else
|
41
|
-
top =
|
42
|
-
top.swipe start_x: 1.0, start_y: 0.0, delta_x: -p, delta_y: p, duration: 1
|
43
|
-
|
44
|
-
bottom = TouchAction.new
|
45
|
-
bottom.swipe start_x: 0.0, start_y: 1.0, delta_x: p, delta_y: -p, duration: 1
|
38
|
+
top, bottom = pinch_ios(rate)
|
46
39
|
end
|
47
40
|
|
48
41
|
pinch = MultiTouch.new
|
@@ -64,23 +57,14 @@ module Appium
|
|
64
57
|
def zoom(percentage = 200, auto_perform = true)
|
65
58
|
raise ArgumentError("Can't zoom to smaller then screen size.") if percentage < 100
|
66
59
|
|
67
|
-
|
68
|
-
i = 1 - p
|
60
|
+
rate = 100 / Float(percentage)
|
69
61
|
|
70
62
|
if $driver.automation_name_is_xcuitest?
|
71
|
-
|
72
|
-
|
73
|
-
top =
|
74
|
-
top.swipe({ start_x: p, start_y: i, delta_x: i, delta_y: -i }, ele)
|
75
|
-
|
76
|
-
bottom = TouchAction.new
|
77
|
-
bottom.swipe({ start_x: i, start_y: p, delta_x: -i, delta_y: i }, ele)
|
63
|
+
top, bottom = zoom_for_xcuitest(rate)
|
64
|
+
elsif $driver.device_is_android?
|
65
|
+
top, bottom = zoom_android(rate)
|
78
66
|
else
|
79
|
-
top =
|
80
|
-
top.swipe start_x: p, start_y: i, delta_x: i, delta_y: -i, duration: 1
|
81
|
-
|
82
|
-
bottom = TouchAction.new
|
83
|
-
bottom.swipe start_x: i, start_y: p, delta_x: -i, delta_y: i, duration: 1
|
67
|
+
top, bottom = zoom_ios(rate)
|
84
68
|
end
|
85
69
|
|
86
70
|
zoom = MultiTouch.new
|
@@ -89,7 +73,95 @@ module Appium
|
|
89
73
|
return zoom unless auto_perform
|
90
74
|
zoom.perform
|
91
75
|
end
|
92
|
-
|
76
|
+
|
77
|
+
private
|
78
|
+
|
79
|
+
def pinch_for_xcuitest(rate)
|
80
|
+
height = 100
|
81
|
+
|
82
|
+
ele = $driver.find_element :class, 'XCUIElementTypeApplication'
|
83
|
+
top = TouchAction.new
|
84
|
+
top.swipe({ start_x: 0.5, start_y: 0.0,
|
85
|
+
offset_x: 0.0, offset_y: (1 - rate) * height }, ele)
|
86
|
+
|
87
|
+
bottom = TouchAction.new
|
88
|
+
bottom.swipe({ start_x: 0.5, start_y: 1.0,
|
89
|
+
offset_x: 0.0, offset_y: rate * height }, ele)
|
90
|
+
|
91
|
+
[top, bottom]
|
92
|
+
end
|
93
|
+
|
94
|
+
def pinch_android(rate)
|
95
|
+
height = 100
|
96
|
+
|
97
|
+
top = TouchAction.new
|
98
|
+
top.swipe start_x: 0.5, start_y: 1.0 * height,
|
99
|
+
end_x: 0.5, end_y: rate * height, duration: 1_000
|
100
|
+
|
101
|
+
bottom = TouchAction.new
|
102
|
+
bottom.swipe start_x: 0.5, start_y: 0.0,
|
103
|
+
end_x: 0.5, end_y: (1 - rate) * height, duration: 1_000
|
104
|
+
|
105
|
+
[top, bottom]
|
106
|
+
end
|
107
|
+
|
108
|
+
def pinch_ios(rate)
|
109
|
+
height = 100
|
110
|
+
|
111
|
+
top = TouchAction.new
|
112
|
+
top.swipe start_x: 0.5, start_y: 0.0,
|
113
|
+
offset_x: 0.0, offset_y: (1 - rate) * height, duration: 1_000
|
114
|
+
|
115
|
+
bottom = TouchAction.new
|
116
|
+
bottom.swipe start_x: 0.5, start_y: 1.0,
|
117
|
+
offset_x: 0.0, offset_y: rate * height, duration: 1_000
|
118
|
+
|
119
|
+
[top, bottom]
|
120
|
+
end
|
121
|
+
|
122
|
+
def zoom_for_xcuitest(rate)
|
123
|
+
height = 100
|
124
|
+
|
125
|
+
ele = $driver.find_element :class, 'XCUIElementTypeApplication'
|
126
|
+
top = TouchAction.new
|
127
|
+
top.swipe({ start_x: 0.5, start_y: (1 - rate) * height,
|
128
|
+
offset_x: 0.0, offset_y: - (1 - rate) * height }, ele)
|
129
|
+
|
130
|
+
bottom = TouchAction.new
|
131
|
+
bottom.swipe({ start_x: 0.5, start_y: rate * height,
|
132
|
+
offset_x: 0.0, offset_y: (1 - rate) * height }, ele)
|
133
|
+
|
134
|
+
[top, bottom]
|
135
|
+
end
|
136
|
+
|
137
|
+
def zoom_android(rate)
|
138
|
+
height = 100
|
139
|
+
|
140
|
+
top = TouchAction.new
|
141
|
+
top.swipe start_x: 0.5, start_y: (1.0 - rate) * height,
|
142
|
+
end_x: 0.5, end_y: 0.0, duration: 1_000
|
143
|
+
|
144
|
+
bottom = TouchAction.new
|
145
|
+
bottom.swipe start_x: 0.5, start_y: rate * height,
|
146
|
+
end_x: 0.5, end_y: 1.0 * height, duration: 1_000
|
147
|
+
|
148
|
+
[top, bottom]
|
149
|
+
end
|
150
|
+
|
151
|
+
def zoom_ios(rate)
|
152
|
+
height = 100
|
153
|
+
|
154
|
+
top = TouchAction.new
|
155
|
+
top.swipe start_x: 0.5, start_y: (1 - rate) * height,
|
156
|
+
offset_x: 0.0, offset_y: - (1 - rate) * height, duration: 1_000
|
157
|
+
|
158
|
+
bottom = TouchAction.new
|
159
|
+
bottom.swipe start_x: 0.5, start_y: rate * height,
|
160
|
+
offset_x: 0.0, offset_y: (1 - rate) * height, duration: 1_000
|
161
|
+
|
162
|
+
[top, bottom]
|
163
|
+
end
|
164
|
+
end # self
|
93
165
|
|
94
166
|
# Create a new multi-action
|
95
167
|
def initialize
|