14
14
15
15
require_relative 'device/emulator'
16
16
require_relative 'device/clipboard'
17
- require_relative 'device/network'
18
17
require_relative 'device/performance'
19
18
require_relative 'device/screen'
20
19
require_relative 'device/auth_finger_print'
@@ -27,7 +26,6 @@ module Device
27
26
28
27
# rubocop:disable Layout/LineLength
29
28
30
- # @deprecated Use 'mobile: openNotifications' extension instead.
31
29
# @!method open_notifications
32
30
# Open Android notifications
33
31
#
@@ -36,7 +34,6 @@ module Device
36
34
# @driver.open_notifications
37
35
#
38
36
39
- # @deprecated Use 'mobile: getCurrentActivity' extension instead.
40
37
# @!method current_activity
41
38
# Get current activity name
42
39
# @return [String] An activity name
@@ -46,7 +43,6 @@ module Device
46
43
# @driver.current_activity # '.ApiDemos'
47
44
#
48
45
49
- # @deprecated Use 'mobile: getCurrentPackage' extension instead.
50
46
# @!method current_package
51
47
# Get current package name
52
48
# @return [String] A package name
@@ -56,7 +52,6 @@ module Device
56
52
# @driver.current_package # 'com.example.android.apis'
57
53
#
58
54
59
- # @deprecated Use 'mobile: getSystemBars' extension instead.
60
55
# @!method get_system_bars
61
56
# Get system bar's information
62
57
# @return [String]
@@ -67,7 +62,6 @@ module Device
67
62
# @driver.system_bars
68
63
#
69
64
70
- # @deprecated Use 'mobile: getDisplayDensity' extension instead.
71
65
# @!method get_display_density
72
66
# Get connected device's density.
73
67
# @return [Integer] The size of density
@@ -77,44 +71,6 @@ module Device
77
71
# @driver.get_display_density # 320
78
72
#
79
73
80
- # @deprecated Use 'mobile: getConnectivity' extension instead.
81
- # @!method get_network_connection
82
- # Get the device network connection current status
83
- # See set_network_connection method for return value
84
- # Same as #network_connection_type in selenium-webdriver.
85
- #
86
- # Returns a key of <code>{:airplane_mode: 1, wifi: 2, data: 4, all: 6, none: 0}</code> in #network_connection_type
87
- # Returns a number of the mode in +#get_network_connection+
88
- #
89
- # @example
90
- #
91
- # @driver.network_connection_type #=> :all
92
- # @driver.get_network_connection #=> 6
93
- #
94
-
95
- # @deprecated Use 'mobile: getConnectivity' extension instead.
96
- # @!method toggle_wifi
97
- # Switch the state of the wifi service only for Android
98
- #
99
- # @return [String]
100
- #
101
- # @example
102
- #
103
- # @driver.toggle_wifi
104
- #
105
-
106
- # @deprecated Use 'mobile: getConnectivity' extension instead.
107
- # @!method toggle_data
108
- # Switch the state of data service only for Android, and the device should be rooted
109
- #
110
- # @return [String]
111
- #
112
- # @example
113
- #
114
- # @driver.toggle_data
115
- #
116
-
117
- # @deprecated Use 'mobile: getConnectivity' extension instead.
118
74
# @!method location
119
75
# Get the location of the device.
120
76
#
@@ -124,7 +80,6 @@ module Device
124
80
#
125
81
# driver.location #=> ::Appium::Location.new(10, 10, 10)
126
82
#
127
-
128
83
# @!method location=
129
84
# Set the [::Appium::Location] of the device.
130
85
#
@@ -149,7 +104,6 @@ module Device
149
104
# driver.set_location 10, 10, 0
150
105
#
151
106
152
- # @deprecated Use 'mobile: toggleGps' extension instead.
153
107
# @!method toggle_location_services
154
108
# Switch the state of the location service
155
109
#
@@ -160,80 +114,17 @@ module Device
160
114
# @driver.toggle_location_services
161
115
#
162
116
163
- # @deprecated Use 'mobile: getConnectivity' extension instead.
164
- # @!method toggle_airplane_mode
165
- # Toggle flight mode on or off
166
- #
167
- # @example
168
- #
169
- # @driver.toggle_airplane_mode
170
- #
171
-
172
- # @deprecated Use 'mobile: hideKeyboard' extension instead.
173
- # @!method hide_keyboard(close_key = nil, strategy = nil)
117
+ # @!method hide_keyboard(close_key = nil)
174
118
# Hide the onscreen keyboard
175
119
# @param [String] close_key The name of the key which closes the keyboard.
176
120
# Defaults to 'Done' for iOS(except for XCUITest).
177
- # @param [Symbol] strategy The symbol of the strategy which closes the keyboard.
178
- # XCUITest ignore this argument.
179
- # Default for iOS is +:pressKey+. Default for Android is +:tapOutside+.
180
121
#
181
122
# @example
182
123
#
183
124
# @driver.hide_keyboard # Close a keyboard with the 'Done' button
184
125
# @driver.hide_keyboard('Finished') # Close a keyboard with the 'Finished' button
185
- # @driver.hide_keyboard(nil, :tapOutside) # Close a keyboard with tapping out side of keyboard
186
- #
187
-
188
- # @deprecated Use 'mobile: startActivity' extension instead.
189
- # @!method start_activity(opts)
190
- # Android only. Start a new activity within the current app or launch a new app and start the target activity.
191
- #
192
- # Read https://developer.android.com/studio/command-line/adb#IntentSpec for each flags.
193
- #
194
- # @param opts [Hash] Options
195
- # @option opts [String] :app_package The package owning the activity [required]
196
- # @option opts [String] :app_activity The target activity [required]
197
- # @option opts [String] :app_wait_package The package to start before the target package [optional]
198
- # @option opts [String] :app_wait_activity The activity to start before the target activity [optional]
199
- # @option opts [String] :intent_action The intent action to give it when start the target activity (+-a+) [optional]
200
- # @option opts [String] :intent_category The intent category to give it when start the target activity (+-c+) [optional]
201
- # @option opts [String] :intent_flags The intent flag to give it when start the target activity (+-f+) [optional]
202
- # @option opts [String] :optional_intent_arguments The optional intent action to give it when start the target activity [optional]
203
- # You can set arbitrary arguments with space as string.
204
- # e.g. +'--ez your_extra_bool bool --ei your_extra_int 1'+
205
- # @option opts [bool] :dont_stop_app_on_reset Do not stop the app when the reset is called in Appium create/delete session [optional]
206
- #
207
- # @example
208
- #
209
- # start_activity app_package: 'io.appium.android.apis',
210
- # app_activity: '.accessibility.AccessibilityNodeProviderActivity'
211
- #
212
-
213
- # @deprecated Use 'mobile: setConnectivity' extension instead.
214
- # @!method set_network_connection(mode)
215
- # Set the device network connection mode
216
- # Same as +#network_connection_type+ in selenium-webdriver.
217
- #
218
- # @param [String] mode Bit mask that represent the network mode
219
- # Or the key matched with <code>{:airplane_mode: 1, wifi: 2, data: 4, all: 6, none: 0}</code>
220
- #
221
- # Value (Alias) | Data | Wifi | Airplane Mode
222
- # -------------------------------------------------
223
- # 1 (Airplane Mode) | 0 | 0 | 1
224
- # 6 (All network on) | 1 | 1 | 0
225
- # 4 (Data only) | 1 | 0 | 0
226
- # 2 (Wifi only) | 0 | 1 | 0
227
- # 0 (None) | 0 | 0 | 0
228
- #
229
- # @example
230
- #
231
- # @driver.set_network_connection 1
232
- # @driver.set_network_connection :airplane_mode
233
- # @driver.network_connection_type = :airplane_mode # As selenium-webdriver
234
126
#
235
127
236
- # @deprecated Use 'mobile: getPerformanceDataTypes' extension instead.
237
128
# @!method get_performance_data_types
238
129
# Get the information type of the system state which is supported to read such as
239
130
# cpu, memory, network, battery via adb commands.
@@ -244,17 +135,15 @@ module Device
244
135
# @driver.get_performance_data_types #=> ["cpuinfo", "batteryinfo", "networkinfo", "memoryinfo"]
245
136
#
246
137
247
- # @deprecated Use 'mobile: getPerformanceData' extension instead.
248
- # @!method get_performance_data(package_name:, data_type:, data_read_timeout: 1000)
138
+ # @!method get_performance_data(package_name:, data_type:)
249
139
# Get the resource usage information of the application.
250
140
# https://github.com/appium/appium-base-driver/blob/be29aec2318316d12b5c3295e924a5ba8f09b0fb/lib/mjsonwp/routes.js#L303
251
141
# @param [String] package_name: Package name
252
142
# @param [String] data_type: Data type get with +get_performance_data_types+
253
- # @param [String] data_read_timeout: Command timeout. Default is 2.
254
143
#
255
144
# @example
256
145
#
257
- # @driver.get_performance_data package_name: package_name, data_type: data_type, data_read_timeout: 2
146
+ # @driver.get_performance_data package_name: package_name, data_type: data_type
258
147
#
259
148
260
149
# @!method start_recording_screen(remote_path: nil, user: nil, pass: nil, method: 'PUT', file_field_name: nil, form_fields: nil, headers: nil, force_restart: nil, video_size: nil, time_limit: '180', bit_rate: '4000000', bug_report: nil)
@@ -324,7 +213,6 @@ module Device
324
213
# @driver.set_clipboard(content: 'happy testing') #=> {"protocol"=>"W3C"}
325
214
#
326
215
327
- # @deprecated Use 'mobile: fingerprint' extension instead.
328
216
# @!method finger_print(finger_id)
329
217
# Authenticate users by using their finger print scans on supported emulators.
330
218
#
@@ -364,110 +252,51 @@ def extended(_mod)
364
252
365
253
::Appium ::Core ::Device . add_endpoint_method ( :open_notifications ) do
366
254
def open_notifications
367
- ::Appium ::Logger . warn "[DEPRECATION] Please use 'mobile: openNotifications' extension instead"
368
-
369
- execute :open_notifications
255
+ execute_script 'mobile:openNotifications' , { }
370
256
end
371
257
end
372
258
373
259
::Appium ::Core ::Device . add_endpoint_method ( :current_activity ) do
374
260
def current_activity
375
- ::Appium ::Logger . warn "[DEPRECATION] Please use 'mobile: getCurrentActivity' extension instead"
376
-
377
- execute :current_activity
261
+ execute_script 'mobile:getCurrentActivity' , { }
378
262
end
379
263
end
380
264
381
265
::Appium ::Core ::Device . add_endpoint_method ( :current_package ) do
382
266
def current_package
383
- ::Appium ::Logger . warn "[DEPRECATION] Please use 'mobile: getCurrentPackage' extension instead"
384
-
385
- execute :current_package
267
+ execute_script 'mobile:getCurrentPackage' , { }
386
268
end
387
269
end
388
270
389
271
::Appium ::Core ::Device . add_endpoint_method ( :get_system_bars ) do
390
272
def get_system_bars
391
- ::Appium ::Logger . warn "[DEPRECATION] Please use 'mobile: getSystemBars' extension instead"
392
-
393
- execute :get_system_bars
273
+ execute_script 'mobile:getSystemBars' , { }
394
274
end
395
275
end
396
276
# as alias to get_system_bars
397
277
::Appium ::Core ::Device . add_endpoint_method ( :system_bars ) do
398
278
def system_bars
399
- ::Appium ::Logger . warn "[DEPRECATION] Please use 'mobile: getSystemBars' extension instead"
400
-
401
- execute :get_system_bars
279
+ execute_script 'mobile:getSystemBars' , { }
402
280
end
403
281
end
404
282
405
283
::Appium ::Core ::Device . add_endpoint_method ( :toggle_location_services ) do
406
284
def toggle_location_services
407
- ::Appium ::Logger . warn "[DEPRECATION] Please use 'mobile: toggleGps' extension instead"
408
-
409
- execute :toggle_location_services
410
- end
411
- end
412
-
413
- ::Appium ::Core ::Device . add_endpoint_method ( :start_activity ) do
414
- def start_activity ( opts )
415
- ::Appium ::Logger . warn "[DEPRECATION] Please use 'mobile: startActivity' extension instead"
416
-
417
- raise ::Appium ::Core ::Error ::ArgumentError , 'opts must be a hash' unless opts . is_a? Hash
418
-
419
- option = { }
420
-
421
- app_package = opts [ :app_package ]
422
- raise ::Appium ::Core ::Error ::ArgumentError , 'app_package is required' unless app_package
423
-
424
- app_activity = opts [ :app_activity ]
425
- raise ::Appium ::Core ::Error ::ArgumentError , 'app_activity is required' unless app_activity
426
-
427
- option [ :appPackage ] = app_package
428
- option [ :appActivity ] = app_activity
429
-
430
- app_wait_package = opts . fetch ( :app_wait_package , nil )
431
- app_wait_activity = opts . fetch ( :app_wait_activity , nil )
432
- option [ :appWaitPackage ] = app_wait_package if app_wait_package
433
- option [ :appWaitActivity ] = app_wait_activity if app_wait_activity
434
-
435
- intent_action = opts . fetch ( :intent_action , nil )
436
- intent_category = opts . fetch ( :intent_category , nil )
437
- intent_flags = opts . fetch ( :intent_flags , nil )
438
- optional_intent_arguments = opts . fetch ( :optional_intent_arguments , nil )
439
- dont_stop_app_on_reset = opts . fetch ( :dont_stop_app_on_reset , nil )
440
-
441
- option [ :intentAction ] = intent_action if intent_action
442
- option [ :intentCategory ] = intent_category if intent_category
443
- option [ :intentFlags ] = intent_flags if intent_flags
444
- option [ :optionalIntentArguments ] = optional_intent_arguments if optional_intent_arguments
445
- option [ :dontStopAppOnReset ] = dont_stop_app_on_reset if dont_stop_app_on_reset
446
-
447
- execute :start_activity , { } , option
285
+ execute_script 'mobile:toggleGps' , { }
448
286
end
449
287
end
450
288
451
289
# Android, Override included method in bridge
452
290
::Appium ::Core ::Device . add_endpoint_method ( :hide_keyboard ) do
453
- def hide_keyboard ( close_key = nil , strategy = nil )
454
- ::Appium ::Logger . warn "[DEPRECATION] Please use 'mobile: hideKeyboard' extension instead"
455
-
456
- option = { }
457
-
458
- option [ :key ] = close_key if close_key
459
- option [ :strategy ] = strategy if strategy
460
-
461
- execute :hide_keyboard , { } , option
291
+ def hide_keyboard ( _close_key = nil )
292
+ execute_script 'mobile:hideKeyboard' , { }
462
293
end
463
294
end
464
295
465
296
# Android, Override included method in bridge
466
297
::Appium ::Core ::Device . add_endpoint_method ( :background_app ) do
467
298
def background_app ( duration = 0 )
468
- ::Appium ::Logger . warn "[DEPRECATION] Please use 'mobile: backgroundApp' extension instead"
469
-
470
- execute :background_app , { } , seconds : duration
299
+ execute_script 'mobile:backgroundApp' , { seconds : duration }
471
300
end
472
301
end
473
302
@@ -482,7 +311,6 @@ def execute_cdp(cmd, **params)
482
311
483
312
Screen . add_methods
484
313
Performance . add_methods
485
- Network . add_methods
486
314
Clipboard . add_methods
487
315
Emulator . add_methods
488
316
Authentication . add_methods
0 commit comments