diff --git a/lib/appium_lib_core/android/device.rb b/lib/appium_lib_core/android/device.rb index 25cbb032..2859bab3 100644 --- a/lib/appium_lib_core/android/device.rb +++ b/lib/appium_lib_core/android/device.rb @@ -27,6 +27,7 @@ module Device # rubocop:disable Layout/LineLength + # @deprecated Use 'mobile: openNotifications' extension instead. # @!method open_notifications # Open Android notifications # @@ -35,6 +36,7 @@ module Device # @driver.open_notifications # + # @deprecated Use 'mobile: getCurrentActivity' extension instead. # @!method current_activity # Get current activity name # @return [String] An activity name @@ -44,6 +46,7 @@ module Device # @driver.current_activity # '.ApiDemos' # + # @deprecated Use 'mobile: getCurrentPackage' extension instead. # @!method current_package # Get current package name # @return [String] A package name @@ -53,6 +56,7 @@ module Device # @driver.current_package # 'com.example.android.apis' # + # @deprecated Use 'mobile: getSystemBars' extension instead. # @!method get_system_bars # Get system bar's information # @return [String] @@ -63,6 +67,7 @@ module Device # @driver.system_bars # + # @deprecated Use 'mobile: getDisplayDensity' extension instead. # @!method get_display_density # Get connected device's density. # @return [Integer] The size of density @@ -72,6 +77,7 @@ module Device # @driver.get_display_density # 320 # + # @deprecated Use 'mobile: getConnectivity' extension instead. # @!method get_network_connection # Get the device network connection current status # See set_network_connection method for return value @@ -86,6 +92,7 @@ module Device # @driver.get_network_connection #=> 6 # + # @deprecated Use 'mobile: getConnectivity' extension instead. # @!method toggle_wifi # Switch the state of the wifi service only for Android # @@ -96,6 +103,7 @@ module Device # @driver.toggle_wifi # + # @deprecated Use 'mobile: getConnectivity' extension instead. # @!method toggle_data # Switch the state of data service only for Android, and the device should be rooted # @@ -106,6 +114,7 @@ module Device # @driver.toggle_data # + # @deprecated Use 'mobile: getConnectivity' extension instead. # @!method location # Get the location of the device. # @@ -143,6 +152,7 @@ module Device # driver.set_location 10, 10, 0 # + # @deprecated Use 'mobile: toggleGps' extension instead. # @!method toggle_location_services # Switch the state of the location service # @@ -153,6 +163,7 @@ module Device # @driver.toggle_location_services # + # @deprecated Use 'mobile: getConnectivity' extension instead. # @!method toggle_airplane_mode # Toggle flight mode on or off # @@ -161,6 +172,7 @@ module Device # @driver.toggle_airplane_mode # + # @deprecated Use 'mobile: hideKeyboard' extension instead. # @!method hide_keyboard(close_key = nil, strategy = nil) # Hide the onscreen keyboard # @param [String] close_key The name of the key which closes the keyboard. @@ -176,12 +188,14 @@ module Device # @driver.hide_keyboard(nil, :tapOutside) # Close a keyboard with tapping out side of keyboard # + # @deprecated The method no longer exists. This method will be removed. # @!method end_coverage(path, intent) # Android only; Ends the test coverage and writes the results to the given path on device. # @param [String] path Path on the device to write too. # @param [String] intent Intent to broadcast when ending coverage. # + # @deprecated Use 'mobile: startActivity' extension instead. # @!method start_activity(opts) # Android only. Start a new activity within the current app or launch a new app and start the target activity. # @@ -206,6 +220,7 @@ module Device # app_activity: '.accessibility.AccessibilityNodeProviderActivity' # + # @deprecated Use 'mobile: setConnectivity' extension instead. # @!method set_network_connection(mode) # Set the device network connection mode # Same as +#network_connection_type+ in selenium-webdriver. @@ -228,6 +243,7 @@ module Device # @driver.network_connection_type = :airplane_mode # As selenium-webdriver # + # @deprecated Use 'mobile: getPerformanceDataTypes' extension instead. # @!method get_performance_data_types # Get the information type of the system state which is supported to read such as # cpu, memory, network, battery via adb commands. @@ -238,6 +254,7 @@ module Device # @driver.get_performance_data_types #=> ["cpuinfo", "batteryinfo", "networkinfo", "memoryinfo"] # + # @deprecated Use 'mobile: getPerformanceData' extension instead. # @!method get_performance_data(package_name:, data_type:, data_read_timeout: 1000) # Get the resource usage information of the application. # https://github.com/appium/appium-base-driver/blob/be29aec2318316d12b5c3295e924a5ba8f09b0fb/lib/mjsonwp/routes.js#L303 @@ -317,6 +334,7 @@ module Device # @driver.set_clipboard(content: 'happy testing') #=> {"protocol"=>"W3C"} # + # @deprecated Use 'mobile: fingerprint' extension instead. # @!method finger_print(finger_id) # Authenticate users by using their finger print scans on supported emulators. # @@ -356,42 +374,56 @@ def extended(_mod) ::Appium::Core::Device.add_endpoint_method(:open_notifications) do def open_notifications + ::Appium::Logger.warn "[DEPRECATION] Please use 'mobile: openNotifications' extension instead" + execute :open_notifications end end ::Appium::Core::Device.add_endpoint_method(:current_activity) do def current_activity + ::Appium::Logger.warn "[DEPRECATION] Please use 'mobile: getCurrentActivity' extension instead" + execute :current_activity end end ::Appium::Core::Device.add_endpoint_method(:current_package) do def current_package + ::Appium::Logger.warn "[DEPRECATION] Please use 'mobile: getCurrentPackage' extension instead" + execute :current_package end end ::Appium::Core::Device.add_endpoint_method(:get_system_bars) do def get_system_bars + ::Appium::Logger.warn "[DEPRECATION] Please use 'mobile: getSystemBars' extension instead" + execute :get_system_bars end end # as alias to get_system_bars ::Appium::Core::Device.add_endpoint_method(:system_bars) do def system_bars + ::Appium::Logger.warn "[DEPRECATION] Please use 'mobile: getSystemBars' extension instead" + execute :get_system_bars end end ::Appium::Core::Device.add_endpoint_method(:toggle_location_services) do def toggle_location_services + ::Appium::Logger.warn "[DEPRECATION] Please use 'mobile: toggleGps' extension instead" + execute :toggle_location_services end end ::Appium::Core::Device.add_endpoint_method(:start_activity) do def start_activity(opts) + ::Appium::Logger.warn "[DEPRECATION] Please use 'mobile: startActivity' extension instead" + raise 'opts must be a hash' unless opts.is_a? Hash option = {} @@ -429,6 +461,8 @@ def start_activity(opts) # Android, Override included method in bridge ::Appium::Core::Device.add_endpoint_method(:hide_keyboard) do def hide_keyboard(close_key = nil, strategy = nil) + ::Appium::Logger.warn "[DEPRECATION] Please use 'mobile: hideKeyboard' extension instead" + option = {} option[:key] = close_key if close_key @@ -441,6 +475,8 @@ def hide_keyboard(close_key = nil, strategy = nil) # Android, Override included method in bridge ::Appium::Core::Device.add_endpoint_method(:background_app) do def background_app(duration = 0) + ::Appium::Logger.warn "[DEPRECATION] Please use 'mobile: backgroundApp' extension instead" + execute :background_app, {}, seconds: duration end end @@ -448,6 +484,7 @@ def background_app(duration = 0) # TODO: TEST ME ::Appium::Core::Device.add_endpoint_method(:end_coverage) do def end_coverage(path, intent) + ::Appium::Logger.warn '[DEPRECATION] The method no longer exists. This method will be removed.' execute :end_coverage, {}, path: path, intent: intent end end diff --git a/lib/appium_lib_core/android/device/auth_finger_print.rb b/lib/appium_lib_core/android/device/auth_finger_print.rb index 41d1febd..31d2aa1e 100644 --- a/lib/appium_lib_core/android/device/auth_finger_print.rb +++ b/lib/appium_lib_core/android/device/auth_finger_print.rb @@ -20,6 +20,8 @@ module Authentication def self.add_methods ::Appium::Core::Device.add_endpoint_method(:finger_print) do def finger_print(finger_id) + ::Appium::Logger.warn "[DEPRECATION] Please use 'mobile: fingerprint' extension instead" + unless (1..10).cover? finger_id.to_i raise ::Appium::Core::Error::ArgumentError, "finger_id should be integer between 1 to 10. Not #{finger_id}" diff --git a/lib/appium_lib_core/android/device/network.rb b/lib/appium_lib_core/android/device/network.rb index 72d0b2ca..1a9fae01 100644 --- a/lib/appium_lib_core/android/device/network.rb +++ b/lib/appium_lib_core/android/device/network.rb @@ -20,24 +20,32 @@ module Network def self.add_methods ::Appium::Core::Device.add_endpoint_method(:get_network_connection) do def get_network_connection + ::Appium::Logger.warn "[DEPRECATION] Please use 'mobile: getConnectivity' extension instead" + execute :get_network_connection end end ::Appium::Core::Device.add_endpoint_method(:toggle_wifi) do def toggle_wifi + ::Appium::Logger.warn "[DEPRECATION] Please use 'mobile: setConnectivity' extension instead" + execute :toggle_wifi end end ::Appium::Core::Device.add_endpoint_method(:toggle_data) do def toggle_data + ::Appium::Logger.warn "[DEPRECATION] Please use 'mobile: setConnectivity' extension instead" + execute :toggle_data end end ::Appium::Core::Device.add_endpoint_method(:set_network_connection) do def set_network_connection(mode) + ::Appium::Logger.warn "[DEPRECATION] Please use 'mobile: setConnectivity' extension instead" + # same as ::Selenium::WebDriver::DriverExtensions::HasNetworkConnection # But this method accept number connection_type = { airplane_mode: 1, wifi: 2, data: 4, all: 6, none: 0 } @@ -49,6 +57,8 @@ def set_network_connection(mode) ::Appium::Core::Device.add_endpoint_method(:toggle_airplane_mode) do def toggle_airplane_mode + ::Appium::Logger.warn "[DEPRECATION] Please use 'mobile: setConnectivity' extension instead" + execute :toggle_airplane_mode end alias_method :toggle_flight_mode, :toggle_airplane_mode diff --git a/lib/appium_lib_core/android/device/performance.rb b/lib/appium_lib_core/android/device/performance.rb index cfe6b9e6..1874b8ac 100644 --- a/lib/appium_lib_core/android/device/performance.rb +++ b/lib/appium_lib_core/android/device/performance.rb @@ -20,12 +20,15 @@ module Performance def self.add_methods ::Appium::Core::Device.add_endpoint_method(:get_performance_data_types) do def get_performance_data_types + ::Appium::Logger.warn "[DEPRECATION] Please use 'mobile: getPerformanceDataTypes' extension instead" execute :get_performance_data_types end end ::Appium::Core::Device.add_endpoint_method(:get_performance_data) do def get_performance_data(package_name:, data_type:, data_read_timeout: 1000) + ::Appium::Logger.warn "[DEPRECATION] Please use 'mobile: getPerformanceData' extension instead" + execute(:get_performance_data, {}, packageName: package_name, dataType: data_type, dataReadTimeout: data_read_timeout) end diff --git a/lib/appium_lib_core/android/device/screen.rb b/lib/appium_lib_core/android/device/screen.rb index 985977dd..e7f58f35 100644 --- a/lib/appium_lib_core/android/device/screen.rb +++ b/lib/appium_lib_core/android/device/screen.rb @@ -20,6 +20,8 @@ module Screen def self.add_methods ::Appium::Core::Device.add_endpoint_method(:get_display_density) do def get_display_density + ::Appium::Logger.warn "[DEPRECATION] Please use 'mobile: getDisplayDensity' extension instead" + execute :get_display_density end end diff --git a/lib/appium_lib_core/common/base/driver.rb b/lib/appium_lib_core/common/base/driver.rb index f6bdd494..24650506 100644 --- a/lib/appium_lib_core/common/base/driver.rb +++ b/lib/appium_lib_core/common/base/driver.rb @@ -224,6 +224,7 @@ def key_action(async: false) ) end + # @deprecated Use 'mobile: lock' extension instead. # Lock the device # @return [String] # @@ -234,9 +235,11 @@ def key_action(async: false) # # Block other commands during locking the device. # def lock(duration = nil) + ::Appium::Logger.warn "[DEPRECATION] Please use 'mobile: lock' extension instead" @bridge.lock(duration) end + # @deprecated Use 'mobile: isLocked' extension instead. # Check current device status is weather locked or not # # @example @@ -245,10 +248,12 @@ def lock(duration = nil) # @driver.locked? # def locked? + ::Appium::Logger.warn "[DEPRECATION] Please use 'mobile: isLocked' extension instead" @bridge.device_locked? end alias device_locked? locked? + # @deprecated Use 'mobile: unlock' extension instead. # Unlock the device # # @example @@ -256,9 +261,11 @@ def locked? # @driver.unlock # def unlock + ::Appium::Logger.warn "[DEPRECATION] Please use 'mobile: unlock' extension instead" @bridge.unlock end + # @deprecated Use 'mobile: hideKeyboard' extension instead. # Hide the onscreen keyboard # @param [String] close_key The name of the key which closes the keyboard. # Defaults to 'Done' for iOS(except for XCUITest). @@ -273,9 +280,11 @@ def unlock # @driver.hide_keyboard(nil, :tapOutside) # Close a keyboard with tapping out side of keyboard # def hide_keyboard(close_key = nil, strategy = nil) + ::Appium::Logger.warn "[DEPRECATION] Please use 'mobile: hideKeyboard' extension instead" @bridge.hide_keyboard close_key, strategy end + # @deprecated Use 'mobile: isKeyboardShown' extension instead. # Get whether keyboard is displayed or not. # @return [Boolean] Return true if keyboard is shown. Return false if keyboard is hidden. # @@ -284,6 +293,7 @@ def hide_keyboard(close_key = nil, strategy = nil) # @driver.keyboard_shown? # true # def keyboard_shown? + ::Appium::Logger.warn "[DEPRECATION] Please use 'mobile: isKeyboardShown' extension instead" @bridge.is_keyboard_shown end alias is_keyboard_shown keyboard_shown? @@ -327,6 +337,7 @@ def settings=(value) end alias update_settings settings= + # @deprecated Use 'mobile: shell' extension instead. # Returns an instance of DeviceIME # # @return [Appium::Core::Base::Driver::DeviceIME] @@ -340,9 +351,11 @@ def settings=(value) # @driver.ime.deactivate #=> Deactivate current IME engine # def ime + ::Appium::Logger.warn "[DEPRECATION] Please use 'mobile: shell' extension instead" @ime ||= DeviceIME.new(@bridge) end + # @deprecated Use 'mobile: shell' extension instead. # Android only. Make an engine that is available active. # # @param [String] ime_name The IME owning the activity [required] @@ -356,6 +369,7 @@ def ime_activate(ime_name) ime.activate(ime_name) end + # @deprecated Use 'mobile: shell' extension instead. # Android only. List all available input engines on the machine. # # @example @@ -367,6 +381,7 @@ def ime_available_engines ime.available_engines end + # @deprecated Use 'mobile: shell' extension instead. # Android only. Get the name of the active IME engine. # # @example @@ -378,6 +393,7 @@ def ime_active_engine ime.active_engine end + # @deprecated Use 'mobile: shell' extension instead. # @!method ime_activated # Android only. Indicates whether IME input is active at the moment (not if it is available). # @@ -392,6 +408,7 @@ def ime_activated ime.activated? end + # @deprecated Use 'mobile: shell' extension instead. # Android only. De-activates the currently-active IME engine. # # @example @@ -477,6 +494,7 @@ def context=(context = null) # @driver.push_file "/sdcard/Pictures", file # Push a file binary to /sdcard/Pictures path in Android # def push_file(path, filedata) + # TODO: use 'mobile: pushFile' internally @bridge.push_file(path, filedata) end @@ -505,6 +523,7 @@ def push_file(path, filedata) # File.open('proper_filename', 'wb') { |f| f<< decoded_file } # def pull_file(path) + # TODO: use 'mobile: pullFile' internally @bridge.pull_file(path) end @@ -530,9 +549,11 @@ def pull_file(path) # File.open('proper_filename', 'wb') { |f| f<< decoded_file } # def pull_folder(path) + # TODO: use 'mobile: pullFolder' internally @bridge.pull_folder(path) end + # @deprecated Use 'mobile: pressKey' extension instead. # Press keycode on the device. # http://developer.android.com/reference/android/view/KeyEvent.html # @param [Integer] key The key to press. The values which have +KEYCODE_+ prefix in http://developer.android.com/reference/android/view/KeyEvent.html @@ -552,9 +573,11 @@ def pull_folder(path) # @driver.press_keycode 66, metastate: [1], flags: [32] # def press_keycode(key, metastate: [], flags: []) + ::Appium::Logger.warn "[DEPRECATION] Please use 'mobile: pressKey' extension instead" @bridge.press_keycode(key, metastate: metastate, flags: flags) end + # @deprecated Use 'mobile: pressKey' extension instead. # Long press keycode on the device. # http://developer.android.com/reference/android/view/KeyEvent.html # @param [Integer] key The key to long press. The values which have +KEYCODE_+ prefix in http://developer.android.com/reference/android/view/KeyEvent.html @@ -574,10 +597,11 @@ def press_keycode(key, metastate: [], flags: []) # @driver.long_press_keycode 66, metastate: [1], flags: [32, 8192] # def long_press_keycode(key, metastate: [], flags: []) + ::Appium::Logger.warn "[DEPRECATION] Please use 'mobile: pressKey' extension instead" @bridge.long_press_keycode(key, metastate: metastate, flags: flags) end - # @deprecated Except for Windows + # @deprecated Will be removed, or use 'windows: launchApp' extension instead for Windows. # Start the simulator and application configured with desired capabilities # # @example @@ -588,7 +612,7 @@ def launch_app @bridge.launch_app end - # @deprecated Except for Windows + # @deprecated Will be removed, or use 'windows: closeApp' extension instead for Windows. # Close an app on device # # @example @@ -614,6 +638,7 @@ def reset @bridge.reset end + # @deprecated Use 'mobile: getAppStrings' extension instead. # Return the hash of all localization strings. # @return [Hash] # @@ -622,9 +647,11 @@ def reset # @driver.app_strings #=> "TransitionsTitle"=>"Transitions", "WebTitle"=>"Web" # def app_strings(language = nil) + ::Appium::Logger.warn "[DEPRECATION] Please use 'mobile: getAppStrings' extension instead" @bridge.app_strings(language) end + # @deprecated Use 'mobile: backgroundApp' extension instead. # Backgrounds the app for a set number of seconds. # This is a blocking application # @param [Integer] duration How many seconds to background the app for. @@ -667,6 +694,7 @@ def background_app(duration = 0) # @driver.install_app("/path/to/test.ipa", timeoutMs: 20000) # def install_app(path, **options) + # TODO: use mobile command in the background? options = options.transform_keys { |key| key.to_s.gsub(/_./) { |v| v[1].upcase } } unless options.nil? @bridge.install_app(path, options) end @@ -687,6 +715,7 @@ def install_app(path, **options) # @driver.remove_app("io.appium.bundle", keep_data: false, timeout, 10000) # def remove_app(app_id, keep_data: nil, timeout: nil) + # TODO: use mobile command in the background? @bridge.remove_app(app_id, keep_data: keep_data, timeout: timeout) end @@ -698,6 +727,7 @@ def remove_app(app_id, keep_data: nil, timeout: nil) # @driver.app_installed?("io.appium.bundle") # def app_installed?(app_id) + # TODO: use mobile command in the background? @bridge.app_installed?(app_id) end @@ -709,6 +739,7 @@ def app_installed?(app_id) # @driver.activate_app("io.appium.bundle") #=> {} # def activate_app(app_id) + # TODO: use mobile command in the background? @bridge.activate_app(app_id) end @@ -725,6 +756,7 @@ def activate_app(app_id) # @driver.terminate_app("io.appium.bundle", timeout: 500) # def terminate_app(app_id, timeout: nil) + # TODO: use mobile command in the background? @bridge.terminate_app(app_id, timeout: timeout) end @@ -748,6 +780,7 @@ def terminate_app(app_id, timeout: nil) # @driver.query_app_state("io.appium.bundle") #=> :not_running # def app_state(app_id) + # TODO: use mobile command in the background? @bridge.app_state(app_id) end alias query_app_state app_state @@ -787,6 +820,7 @@ def stop_and_save_recording_screen(file_path) @bridge.stop_and_save_recording_screen(file_path) end + # @deprecated Use 'mobile: shake' extension instead. # Cause the device to shake # # @example @@ -794,9 +828,11 @@ def stop_and_save_recording_screen(file_path) # @driver.shake # def shake + ::Appium::Logger.warn "[DEPRECATION] Please use 'mobile: shake' extension instead" @bridge.shake end + # @deprecated Use 'mobile: getDeviceTime' extension instead. # Get the time on the device # # @param [String] format The set of format specifiers. Read https://momentjs.com/docs/ to get @@ -810,6 +846,7 @@ def shake # @driver.device_time "YYYY-MM-DD" #=> "2018-06-12" # def device_time(format = nil) + ::Appium::Logger.warn "[DEPRECATION] Please use 'mobile: getDeviceTime' extension instead" @bridge.device_time(format) end diff --git a/lib/appium_lib_core/ios/xcuitest/device.rb b/lib/appium_lib_core/ios/xcuitest/device.rb index 81f1a7ee..6604aab2 100644 --- a/lib/appium_lib_core/ios/xcuitest/device.rb +++ b/lib/appium_lib_core/ios/xcuitest/device.rb @@ -25,6 +25,7 @@ module Device # rubocop:disable Layout/LineLength + # @deprecated Use 'mobile: hideKeyboard' extension instead. # @!method hide_keyboard(close_key = nil, strategy = nil) # Hide the onscreen keyboard # @param [String] close_key The name of the key which closes the keyboard. @@ -38,6 +39,7 @@ module Device # @driver.hide_keyboard('Finished') # Close a keyboard with the 'Finished' button # + # @deprecated Use 'mobile: backgroundApp' extension instead. # @!method background_app(duration = 0) # Backgrounds the app for a set number of seconds. # This is a blocking application.