1414
1515require_relative 'device/emulator'
1616require_relative 'device/clipboard'
17- require_relative 'device/network'
1817require_relative 'device/performance'
1918require_relative 'device/screen'
2019require_relative 'device/auth_finger_print'
@@ -27,7 +26,6 @@ module Device
2726
2827 # rubocop:disable Layout/LineLength
2928
30- # @deprecated Use 'mobile: openNotifications' extension instead.
3129 # @!method open_notifications
3230 # Open Android notifications
3331 #
@@ -36,7 +34,6 @@ module Device
3634 # @driver.open_notifications
3735 #
3836
39- # @deprecated Use 'mobile: getCurrentActivity' extension instead.
4037 # @!method current_activity
4138 # Get current activity name
4239 # @return [String] An activity name
@@ -46,7 +43,6 @@ module Device
4643 # @driver.current_activity # '.ApiDemos'
4744 #
4845
49- # @deprecated Use 'mobile: getCurrentPackage' extension instead.
5046 # @!method current_package
5147 # Get current package name
5248 # @return [String] A package name
@@ -56,7 +52,6 @@ module Device
5652 # @driver.current_package # 'com.example.android.apis'
5753 #
5854
59- # @deprecated Use 'mobile: getSystemBars' extension instead.
6055 # @!method get_system_bars
6156 # Get system bar's information
6257 # @return [String]
@@ -67,7 +62,6 @@ module Device
6762 # @driver.system_bars
6863 #
6964
70- # @deprecated Use 'mobile: getDisplayDensity' extension instead.
7165 # @!method get_display_density
7266 # Get connected device's density.
7367 # @return [Integer] The size of density
@@ -77,44 +71,6 @@ module Device
7771 # @driver.get_display_density # 320
7872 #
7973
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.
11874 # @!method location
11975 # Get the location of the device.
12076 #
@@ -124,7 +80,6 @@ module Device
12480 #
12581 # driver.location #=> ::Appium::Location.new(10, 10, 10)
12682 #
127-
12883 # @!method location=
12984 # Set the [::Appium::Location] of the device.
13085 #
@@ -149,7 +104,6 @@ module Device
149104 # driver.set_location 10, 10, 0
150105 #
151106
152- # @deprecated Use 'mobile: toggleGps' extension instead.
153107 # @!method toggle_location_services
154108 # Switch the state of the location service
155109 #
@@ -160,80 +114,17 @@ module Device
160114 # @driver.toggle_location_services
161115 #
162116
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)
174118 # Hide the onscreen keyboard
175119 # @param [String] close_key The name of the key which closes the keyboard.
176120 # 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+.
180121 #
181122 # @example
182123 #
183124 # @driver.hide_keyboard # Close a keyboard with the 'Done' button
184125 # @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
234126 #
235127
236- # @deprecated Use 'mobile: getPerformanceDataTypes' extension instead.
237128 # @!method get_performance_data_types
238129 # Get the information type of the system state which is supported to read such as
239130 # cpu, memory, network, battery via adb commands.
@@ -244,17 +135,15 @@ module Device
244135 # @driver.get_performance_data_types #=> ["cpuinfo", "batteryinfo", "networkinfo", "memoryinfo"]
245136 #
246137
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:)
249139 # Get the resource usage information of the application.
250140 # https://github.com/appium/appium-base-driver/blob/be29aec2318316d12b5c3295e924a5ba8f09b0fb/lib/mjsonwp/routes.js#L303
251141 # @param [String] package_name: Package name
252142 # @param [String] data_type: Data type get with +get_performance_data_types+
253- # @param [String] data_read_timeout: Command timeout. Default is 2.
254143 #
255144 # @example
256145 #
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
258147 #
259148
260149 # @!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
324213 # @driver.set_clipboard(content: 'happy testing') #=> {"protocol"=>"W3C"}
325214 #
326215
327- # @deprecated Use 'mobile: fingerprint' extension instead.
328216 # @!method finger_print(finger_id)
329217 # Authenticate users by using their finger print scans on supported emulators.
330218 #
@@ -364,110 +252,51 @@ def extended(_mod)
364252
365253 ::Appium ::Core ::Device . add_endpoint_method ( :open_notifications ) do
366254 def open_notifications
367- ::Appium ::Logger . warn "[DEPRECATION] Please use 'mobile: openNotifications' extension instead"
368-
369- execute :open_notifications
255+ execute_script 'mobile:openNotifications' , { }
370256 end
371257 end
372258
373259 ::Appium ::Core ::Device . add_endpoint_method ( :current_activity ) do
374260 def current_activity
375- ::Appium ::Logger . warn "[DEPRECATION] Please use 'mobile: getCurrentActivity' extension instead"
376-
377- execute :current_activity
261+ execute_script 'mobile:getCurrentActivity' , { }
378262 end
379263 end
380264
381265 ::Appium ::Core ::Device . add_endpoint_method ( :current_package ) do
382266 def current_package
383- ::Appium ::Logger . warn "[DEPRECATION] Please use 'mobile: getCurrentPackage' extension instead"
384-
385- execute :current_package
267+ execute_script 'mobile:getCurrentPackage' , { }
386268 end
387269 end
388270
389271 ::Appium ::Core ::Device . add_endpoint_method ( :get_system_bars ) do
390272 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' , { }
394274 end
395275 end
396276 # as alias to get_system_bars
397277 ::Appium ::Core ::Device . add_endpoint_method ( :system_bars ) do
398278 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' , { }
402280 end
403281 end
404282
405283 ::Appium ::Core ::Device . add_endpoint_method ( :toggle_location_services ) do
406284 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' , { }
448286 end
449287 end
450288
451289 # Android, Override included method in bridge
452290 ::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' , { }
462293 end
463294 end
464295
465296 # Android, Override included method in bridge
466297 ::Appium ::Core ::Device . add_endpoint_method ( :background_app ) do
467298 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 }
471300 end
472301 end
473302
@@ -482,7 +311,6 @@ def execute_cdp(cmd, **params)
482311
483312 Screen . add_methods
484313 Performance . add_methods
485- Network . add_methods
486314 Clipboard . add_methods
487315 Emulator . add_methods
488316 Authentication . add_methods
0 commit comments