appium_lib 9.7.5 → 9.8.1
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 +25 -0
- data/appium_lib.gemspec +1 -3
- data/contributing.md +2 -0
- data/docs/android_docs.md +186 -180
- data/docs/ios_docs.md +238 -234
- data/docs/ios_xcuitest.md +1 -1
- data/lib/appium_lib/android/common/helper.rb +0 -30
- data/lib/appium_lib/appium.rb +3 -4
- data/lib/appium_lib/common/helper.rb +0 -1
- data/lib/appium_lib/common/http_client.rb +1 -1
- data/lib/appium_lib/common/touch_actions.rb +4 -4
- data/lib/appium_lib/common/wait.rb +1 -1
- data/lib/appium_lib/driver.rb +7 -8
- data/lib/appium_lib/ios/common/helper.rb +1 -8
- data/lib/appium_lib/version.rb +2 -2
- data/readme.md +29 -8
- data/release_notes.md +6 -0
- metadata +5 -77
- data/lib/appium_lib/core/android.rb +0 -5
- data/lib/appium_lib/core/android/device.rb +0 -142
- data/lib/appium_lib/core/android/espresso/bridge.rb +0 -18
- data/lib/appium_lib/core/android/search_context.rb +0 -17
- data/lib/appium_lib/core/android/touch.rb +0 -15
- data/lib/appium_lib/core/android/uiautomator1/bridge.rb +0 -18
- data/lib/appium_lib/core/android/uiautomator2/bridge.rb +0 -18
- data/lib/appium_lib/core/android_espresso.rb +0 -5
- data/lib/appium_lib/core/android_uiautomator2.rb +0 -5
- data/lib/appium_lib/core/common.rb +0 -6
- data/lib/appium_lib/core/common/base.rb +0 -8
- data/lib/appium_lib/core/common/base/bridge.rb +0 -47
- data/lib/appium_lib/core/common/base/capabilities.rb +0 -16
- data/lib/appium_lib/core/common/base/command.rb +0 -10
- data/lib/appium_lib/core/common/base/driver.rb +0 -40
- data/lib/appium_lib/core/common/base/http_default.rb +0 -12
- data/lib/appium_lib/core/common/base/search_context.rb +0 -89
- data/lib/appium_lib/core/common/base/wait.rb +0 -56
- data/lib/appium_lib/core/common/command.rb +0 -75
- data/lib/appium_lib/core/common/device.rb +0 -462
- data/lib/appium_lib/core/common/error.rb +0 -18
- data/lib/appium_lib/core/common/log.rb +0 -30
- data/lib/appium_lib/core/common/logger.rb +0 -35
- data/lib/appium_lib/core/core.rb +0 -67
- data/lib/appium_lib/core/device/multi_touch.rb +0 -48
- data/lib/appium_lib/core/device/touch_actions.rb +0 -191
- data/lib/appium_lib/core/driver.rb +0 -417
- data/lib/appium_lib/core/ios.rb +0 -7
- data/lib/appium_lib/core/ios/device.rb +0 -44
- data/lib/appium_lib/core/ios/search_context.rb +0 -27
- data/lib/appium_lib/core/ios/touch.rb +0 -16
- data/lib/appium_lib/core/ios/uiautomation/bridge.rb +0 -20
- data/lib/appium_lib/core/ios/uiautomation/patch.rb +0 -20
- data/lib/appium_lib/core/ios/xcuitest/bridge.rb +0 -20
- data/lib/appium_lib/core/ios/xcuitest/device.rb +0 -59
- data/lib/appium_lib/core/ios/xcuitest/search_context.rb +0 -40
- data/lib/appium_lib/core/ios_xcuitest.rb +0 -8
- data/lib/appium_lib/core/patch.rb +0 -56
@@ -1,462 +0,0 @@
|
|
1
|
-
require 'base64'
|
2
|
-
|
3
|
-
module Appium
|
4
|
-
module Core
|
5
|
-
module Device
|
6
|
-
extend Forwardable
|
7
|
-
|
8
|
-
# @!method app_strings
|
9
|
-
# Return the hash of all localization strings.
|
10
|
-
# ```ruby
|
11
|
-
# app_strings #=> "TransitionsTitle"=>"Transitions", "WebTitle"=>"Web"
|
12
|
-
# ```
|
13
|
-
|
14
|
-
# @!method background_app
|
15
|
-
# Backgrounds the app for a set number of seconds.
|
16
|
-
# This is a blocking application
|
17
|
-
# @param [Integer] seconds How many seconds to background the app for.
|
18
|
-
#
|
19
|
-
# ```ruby
|
20
|
-
# background_app
|
21
|
-
# background_app(5)
|
22
|
-
# background_app(-1) #=> the app never come back. https://github.com/appium/appium/issues/7741
|
23
|
-
# ```
|
24
|
-
|
25
|
-
# @!method current_activity
|
26
|
-
# Get current activity name
|
27
|
-
# @return [String] An activity name
|
28
|
-
#
|
29
|
-
# ```ruby
|
30
|
-
# current_activity # '.ApiDemos'
|
31
|
-
# ```
|
32
|
-
|
33
|
-
# @!method current_package
|
34
|
-
# Get current package name
|
35
|
-
# @return [String] A package name
|
36
|
-
#
|
37
|
-
# ```ruby
|
38
|
-
# current_package # 'com.example.android.apis'
|
39
|
-
# ```
|
40
|
-
|
41
|
-
# @!method get_system_bars
|
42
|
-
# Get system bar's information
|
43
|
-
# @return [String] System bar
|
44
|
-
#
|
45
|
-
# ```ruby
|
46
|
-
# get_system_bars
|
47
|
-
# ```
|
48
|
-
|
49
|
-
# @!method get_display_density
|
50
|
-
# Get connected device's density.
|
51
|
-
# @return [Integer] The size of density
|
52
|
-
#
|
53
|
-
# ```ruby
|
54
|
-
# get_display_density # 320
|
55
|
-
# ```
|
56
|
-
|
57
|
-
# @!method is_keyboard_shown
|
58
|
-
# Get whether keyboard is displayed or not.
|
59
|
-
# @return [Bool] Return true if keyboard is shown. Return false if keyboard is hidden.
|
60
|
-
#
|
61
|
-
# ```ruby
|
62
|
-
# is_keyboard_shown # false
|
63
|
-
# ```
|
64
|
-
|
65
|
-
# @!method launch_app
|
66
|
-
# Start the simulator and application configured with desired capabilities
|
67
|
-
|
68
|
-
# @!method reset
|
69
|
-
# Reset the device, relaunching the application.
|
70
|
-
|
71
|
-
# @!method shake
|
72
|
-
# Cause the device to shake
|
73
|
-
|
74
|
-
# @!method toggle_flight_mode
|
75
|
-
# Toggle flight mode on or off
|
76
|
-
|
77
|
-
# @!method device_locked?
|
78
|
-
|
79
|
-
# @!method hide_keyboard
|
80
|
-
# Hide the onscreen keyboard
|
81
|
-
# @param [String] close_key The name of the key which closes the keyboard.
|
82
|
-
# Defaults to 'Done' for iOS(except for XCUITest).
|
83
|
-
# @param [Symbol] strategy The symbol of the strategy which closes the keyboard.
|
84
|
-
# XCUITest ignore this argument.
|
85
|
-
# Default for iOS is `:pressKey`. Default for Android is `:tapOutside`.
|
86
|
-
# ```ruby
|
87
|
-
# hide_keyboard # Close a keyboard with the 'Done' button
|
88
|
-
# hide_keyboard('Finished') # Close a keyboard with the 'Finished' button
|
89
|
-
# hide_keyboard(nil, :tapOutside) # Close a keyboard with tapping out side of keyboard
|
90
|
-
# ```
|
91
|
-
|
92
|
-
# @!method press_keycode
|
93
|
-
# Press keycode on the device.
|
94
|
-
# http://developer.android.com/reference/android/view/KeyEvent.html
|
95
|
-
# @param [integer] key The key to press.
|
96
|
-
# @param [String] metastate The state the metakeys should be in when pressing the key.
|
97
|
-
|
98
|
-
# @!method long_press_keycode
|
99
|
-
# Long press keycode on the device.
|
100
|
-
# http://developer.android.com/reference/android/view/KeyEvent.html
|
101
|
-
# @param [integer] key The key to long press.
|
102
|
-
# @param [String] metastate The state the metakeys should be in when long pressing the key.
|
103
|
-
|
104
|
-
# @!method push_file
|
105
|
-
# Place a file in a specific location on the device.
|
106
|
-
# @param [String] path The absolute path on the device to store data at.
|
107
|
-
# @param [String] data Raw file data to be sent to the device.
|
108
|
-
|
109
|
-
# @!method pull_file
|
110
|
-
# Retrieve a file from the device. This can retrieve an absolute path or
|
111
|
-
# a path relative to the installed app (iOS only).
|
112
|
-
# @param [String] path Either an absolute path OR, for iOS devices, a path relative to the app, as described.
|
113
|
-
#
|
114
|
-
# ```ruby
|
115
|
-
# pull_file '/local/data/some/path' #=> Get the file at that path
|
116
|
-
# pull_file 'Shenanigans.app/some/file' #=> Get 'some/file' from the install location of Shenanigans.app
|
117
|
-
# ```
|
118
|
-
|
119
|
-
# @!method pull_folder
|
120
|
-
# Retrieve a folder from the device.
|
121
|
-
# @param [String] path absolute path to the folder
|
122
|
-
#
|
123
|
-
# ```ruby
|
124
|
-
# pull_folder '/data/local/tmp' #=> Get the folder at that path
|
125
|
-
# ```
|
126
|
-
|
127
|
-
# @!method get_settings
|
128
|
-
# Get appium Settings for current test session
|
129
|
-
|
130
|
-
# @!method update_settings
|
131
|
-
# Update appium Settings for current test session
|
132
|
-
# @param [Hash] settings Settings to update, keys are settings, values to value to set each setting to
|
133
|
-
|
134
|
-
# @!method set_immediate_value
|
135
|
-
# Set the value to element directly
|
136
|
-
# for iOS; setValue is called in XCUITest instead because XCUITest doesn't provide set value directly.
|
137
|
-
# https://github.com/appium/appium-xcuitest-driver/blob/793cdc7d5e84bd553e375076e1c6dc7e242c9cde/lib/commands/element.js#L123
|
138
|
-
#
|
139
|
-
# ```ruby
|
140
|
-
# set_immediate_value element, 'hello'
|
141
|
-
# ```
|
142
|
-
|
143
|
-
# @!method get_network_connection
|
144
|
-
# Get the device network connection current status
|
145
|
-
# See set_network_connection method for return value
|
146
|
-
|
147
|
-
class << self
|
148
|
-
def extended(_mod)
|
149
|
-
extend_webdriver_with_forwardable
|
150
|
-
|
151
|
-
::Appium::Core::Commands::COMMAND_NO_ARG.each_key do |method|
|
152
|
-
add_endpoint_method method
|
153
|
-
end
|
154
|
-
|
155
|
-
# call http://www.rubydoc.info/gems/selenium-webdriver/Selenium/WebDriver/DriverExtensions/HasRemoteStatus#remote_status-instance_method
|
156
|
-
add_endpoint_method(:remote_status) do
|
157
|
-
def remote_status
|
158
|
-
execute(:status, {}) || []
|
159
|
-
end
|
160
|
-
end
|
161
|
-
|
162
|
-
# TODO: Don't define selenium-side methods. We pick up from them.
|
163
|
-
# ::Appium::Core::Base::Commands::OSS.each_key do |method|
|
164
|
-
# add_endpoint_method method
|
165
|
-
# end
|
166
|
-
|
167
|
-
add_endpoint_method(:available_contexts) do
|
168
|
-
def available_contexts
|
169
|
-
# return empty array instead of nil on failure
|
170
|
-
execute(:available_contexts, {}) || []
|
171
|
-
end
|
172
|
-
end
|
173
|
-
|
174
|
-
add_endpoint_method(:app_strings) do
|
175
|
-
def app_strings(language = nil)
|
176
|
-
opts = language ? { language: language } : {}
|
177
|
-
execute :app_strings, {}, opts
|
178
|
-
end
|
179
|
-
end
|
180
|
-
|
181
|
-
add_endpoint_method(:lock) do
|
182
|
-
def lock(duration)
|
183
|
-
execute :lock, {}, seconds: duration
|
184
|
-
end
|
185
|
-
end
|
186
|
-
|
187
|
-
add_endpoint_method(:install_app) do
|
188
|
-
def install_app(path)
|
189
|
-
execute :install_app, {}, appPath: path
|
190
|
-
end
|
191
|
-
end
|
192
|
-
|
193
|
-
add_endpoint_method(:remove_app) do
|
194
|
-
def remove_app(id)
|
195
|
-
execute :remove_app, {}, appId: id
|
196
|
-
end
|
197
|
-
end
|
198
|
-
|
199
|
-
add_endpoint_method(:app_installed?) do
|
200
|
-
def app_installed?(app_id)
|
201
|
-
execute :app_installed?, {}, bundleId: app_id
|
202
|
-
end
|
203
|
-
end
|
204
|
-
|
205
|
-
add_endpoint_method(:background_app) do
|
206
|
-
def background_app(duration = 0)
|
207
|
-
execute :background_app, {}, seconds: duration
|
208
|
-
end
|
209
|
-
end
|
210
|
-
|
211
|
-
add_endpoint_method(:set_context) do
|
212
|
-
def set_context(context = null)
|
213
|
-
execute :set_context, {}, name: context
|
214
|
-
end
|
215
|
-
end
|
216
|
-
|
217
|
-
add_endpoint_method(:hide_keyboard) do
|
218
|
-
def hide_keyboard(close_key = nil, strategy = nil)
|
219
|
-
option = {}
|
220
|
-
|
221
|
-
option[:key] = close_key || 'Done' # default to Done key.
|
222
|
-
option[:strategy] = strategy || :pressKey # default to pressKey
|
223
|
-
|
224
|
-
execute :hide_keyboard, {}, option
|
225
|
-
end
|
226
|
-
end
|
227
|
-
|
228
|
-
add_endpoint_method(:press_keycode) do
|
229
|
-
def press_keycode(key, metastate = nil)
|
230
|
-
args = { keycode: key }
|
231
|
-
args[:metastate] = metastate if metastate
|
232
|
-
execute :press_keycode, {}, args
|
233
|
-
end
|
234
|
-
end
|
235
|
-
|
236
|
-
add_endpoint_method(:long_press_keycode) do
|
237
|
-
def long_press_keycode(key, metastate = nil)
|
238
|
-
args = { keycode: key }
|
239
|
-
args[:metastate] = metastate if metastate
|
240
|
-
execute :long_press_keycode, {}, args
|
241
|
-
end
|
242
|
-
end
|
243
|
-
|
244
|
-
add_endpoint_method(:set_immediate_value) do
|
245
|
-
def set_immediate_value(element, *value)
|
246
|
-
keys = ::Selenium::WebDriver::Keys.encode(value)
|
247
|
-
execute :set_immediate_value, { id: element.ref }, value: Array(keys)
|
248
|
-
end
|
249
|
-
end
|
250
|
-
|
251
|
-
add_endpoint_method(:push_file) do
|
252
|
-
def push_file(path, filedata)
|
253
|
-
encoded_data = Base64.encode64 filedata
|
254
|
-
execute :push_file, {}, path: path, data: encoded_data
|
255
|
-
end
|
256
|
-
end
|
257
|
-
|
258
|
-
add_endpoint_method(:pull_file) do
|
259
|
-
def pull_file(path)
|
260
|
-
data = execute :pull_file, {}, path: path
|
261
|
-
Base64.decode64 data
|
262
|
-
end
|
263
|
-
end
|
264
|
-
|
265
|
-
# TODO: TEST ME
|
266
|
-
add_endpoint_method(:pull_folder) do
|
267
|
-
def pull_folder(path)
|
268
|
-
data = execute :pull_folder, {}, path: path
|
269
|
-
Base64.decode64 data
|
270
|
-
end
|
271
|
-
end
|
272
|
-
|
273
|
-
add_endpoint_method(:get_settings) do
|
274
|
-
def get_settings
|
275
|
-
execute :get_settings, {}
|
276
|
-
end
|
277
|
-
end
|
278
|
-
|
279
|
-
add_endpoint_method(:update_settings) do
|
280
|
-
def update_settings(settings)
|
281
|
-
execute :update_settings, {}, settings: settings
|
282
|
-
end
|
283
|
-
end
|
284
|
-
|
285
|
-
add_touch_actions
|
286
|
-
add_ime_actions
|
287
|
-
end
|
288
|
-
|
289
|
-
# def extended
|
290
|
-
|
291
|
-
# @private
|
292
|
-
def add_endpoint_method(method)
|
293
|
-
block_given? ? create_bridge_command(method, &Proc.new) : create_bridge_command(method)
|
294
|
-
|
295
|
-
delegate_driver_method method
|
296
|
-
delegate_from_appium_driver method
|
297
|
-
end
|
298
|
-
|
299
|
-
# @private CoreBridge
|
300
|
-
def extend_webdriver_with_forwardable
|
301
|
-
return if ::Appium::Core::Base::Driver.is_a? Forwardable
|
302
|
-
::Appium::Core::Base::Driver.class_eval do
|
303
|
-
extend Forwardable
|
304
|
-
end
|
305
|
-
end
|
306
|
-
|
307
|
-
# @private
|
308
|
-
def delegate_driver_method(method)
|
309
|
-
return if ::Appium::Core::Base::Driver.method_defined? method
|
310
|
-
::Appium::Core::Base::Driver.class_eval { def_delegator :@bridge, method }
|
311
|
-
end
|
312
|
-
|
313
|
-
# @private
|
314
|
-
def delegate_from_appium_driver(method, delegation_target = :driver)
|
315
|
-
def_delegator delegation_target, method
|
316
|
-
end
|
317
|
-
|
318
|
-
# @private
|
319
|
-
def create_bridge_command(method)
|
320
|
-
::Appium::Core::Base::CoreBridgeOSS.class_eval do
|
321
|
-
block_given? ? class_eval(&Proc.new) : define_method(method) { execute method }
|
322
|
-
end
|
323
|
-
::Appium::Core::Base::CoreBridgeW3C.class_eval do
|
324
|
-
block_given? ? class_eval(&Proc.new) : define_method(method) { execute method }
|
325
|
-
end
|
326
|
-
end
|
327
|
-
|
328
|
-
def add_touch_actions
|
329
|
-
add_endpoint_method(:touch_actions) do
|
330
|
-
def touch_actions(actions)
|
331
|
-
actions = { actions: [actions].flatten }
|
332
|
-
execute :touch_actions, {}, actions
|
333
|
-
end
|
334
|
-
end
|
335
|
-
|
336
|
-
add_endpoint_method(:multi_touch) do
|
337
|
-
def multi_touch(actions)
|
338
|
-
execute :multi_touch, {}, actions: actions
|
339
|
-
end
|
340
|
-
end
|
341
|
-
end
|
342
|
-
|
343
|
-
def add_ime_actions
|
344
|
-
# Commands for IME are defined in the following commands.rb, but the driver have no bridge.
|
345
|
-
# So, appium_lib define just bridge here.
|
346
|
-
# https://github.com/SeleniumHQ/selenium/blob/selenium-3.0.1/rb/lib/selenium/webdriver/remote/commands.rb#L184-L192
|
347
|
-
|
348
|
-
# @!method ime_activate
|
349
|
-
# Make an engine that is available active.
|
350
|
-
#
|
351
|
-
# Android only.
|
352
|
-
# @param [String] The IME owning the activity [required]
|
353
|
-
#
|
354
|
-
# ```ruby
|
355
|
-
# ime_activate engine: 'com.android.inputmethod.latin/.LatinIME'
|
356
|
-
# ```
|
357
|
-
add_endpoint_method(:ime_activate) do
|
358
|
-
def ime_activate(ime_name)
|
359
|
-
# from Selenium::WebDriver::Remote::OSS
|
360
|
-
execute :ime_activate_engine, {}, engine: ime_name
|
361
|
-
end
|
362
|
-
end
|
363
|
-
|
364
|
-
# @!method ime_available_engines
|
365
|
-
# List all available input engines on the machine.
|
366
|
-
# Android only.
|
367
|
-
#
|
368
|
-
# ```ruby
|
369
|
-
# ime_available_engines #=> Get the list of IME installed in the target device
|
370
|
-
# ```
|
371
|
-
add_endpoint_method(:ime_available_engines) do
|
372
|
-
def ime_available_engines
|
373
|
-
execute :ime_get_available_engines
|
374
|
-
end
|
375
|
-
end
|
376
|
-
|
377
|
-
# @!method ime_active_engine
|
378
|
-
# Get the name of the active IME engine.
|
379
|
-
# Android only.
|
380
|
-
#
|
381
|
-
# ```ruby
|
382
|
-
# ime_active_engine #=> Get the current active IME such as 'com.android.inputmethod.latin/.LatinIME'
|
383
|
-
# ```
|
384
|
-
add_endpoint_method(:ime_active_engine) do
|
385
|
-
# from Selenium::WebDriver::Remote::OSS
|
386
|
-
def ime_active_engine
|
387
|
-
execute :ime_get_active_engine
|
388
|
-
end
|
389
|
-
end
|
390
|
-
|
391
|
-
# @!method ime_activated
|
392
|
-
# Indicates whether IME input is active at the moment (not if it is available).
|
393
|
-
# Android only.
|
394
|
-
#
|
395
|
-
# ```ruby
|
396
|
-
# ime_activated #=> True if IME is activated
|
397
|
-
# ```
|
398
|
-
add_endpoint_method(:ime_activated) do
|
399
|
-
# from Selenium::WebDriver::Remote::OSS
|
400
|
-
def ime_activated
|
401
|
-
execute :ime_is_activated
|
402
|
-
end
|
403
|
-
end
|
404
|
-
|
405
|
-
# @!method ime_deactivate
|
406
|
-
# De-activates the currently-active IME engine.
|
407
|
-
#
|
408
|
-
# Android only.
|
409
|
-
#
|
410
|
-
# ```ruby
|
411
|
-
# ime_deactivate #=> Deactivate current IME engine
|
412
|
-
# ```
|
413
|
-
add_endpoint_method(:ime_deactivate) do
|
414
|
-
# from Selenium::WebDriver::Remote::OSS
|
415
|
-
def ime_deactivate
|
416
|
-
execute :ime_deactivate, {}
|
417
|
-
end
|
418
|
-
end
|
419
|
-
end
|
420
|
-
end # class << self
|
421
|
-
|
422
|
-
# @!method set_context
|
423
|
-
# Change the context to the given context.
|
424
|
-
# @param [String] The context to change to
|
425
|
-
#
|
426
|
-
# ```ruby
|
427
|
-
# set_context "NATIVE_APP"
|
428
|
-
# ```
|
429
|
-
|
430
|
-
# @!method current_context
|
431
|
-
# @return [String] The context currently being used.
|
432
|
-
|
433
|
-
# @!method available_contexts
|
434
|
-
# @return [Array<String>] All usable contexts, as an array of strings.
|
435
|
-
|
436
|
-
# Perform a block within the given context, then switch back to the starting context.
|
437
|
-
# @param context (String) The context to switch to for the duration of the block.
|
438
|
-
#
|
439
|
-
# ```ruby
|
440
|
-
# result = within_context('NATIVE_APP') do
|
441
|
-
# find_element :tag, "button"
|
442
|
-
# end # The result of `find_element :tag, "button"`
|
443
|
-
# ```
|
444
|
-
def within_context(context)
|
445
|
-
existing_context = current_context
|
446
|
-
set_context context
|
447
|
-
if block_given?
|
448
|
-
result = yield
|
449
|
-
set_context existing_context
|
450
|
-
result
|
451
|
-
else
|
452
|
-
set_context existing_context
|
453
|
-
end
|
454
|
-
end
|
455
|
-
|
456
|
-
# Change to the default context. This is equivalent to `set_context nil`.
|
457
|
-
def switch_to_default_context
|
458
|
-
set_context nil
|
459
|
-
end
|
460
|
-
end # module Device
|
461
|
-
end # Core
|
462
|
-
end # module Appium
|