diff --git a/lib/appium_lib_core/android/device.rb b/lib/appium_lib_core/android/device.rb index c1122481..ac817180 100644 --- a/lib/appium_lib_core/android/device.rb +++ b/lib/appium_lib_core/android/device.rb @@ -14,7 +14,6 @@ require_relative 'device/emulator' require_relative 'device/clipboard' -require_relative 'device/network' require_relative 'device/performance' require_relative 'device/screen' require_relative 'device/auth_finger_print' @@ -27,7 +26,6 @@ module Device # rubocop:disable Layout/LineLength - # @deprecated Use 'mobile: openNotifications' extension instead. # @!method open_notifications # Open Android notifications # @@ -36,7 +34,6 @@ module Device # @driver.open_notifications # - # @deprecated Use 'mobile: getCurrentActivity' extension instead. # @!method current_activity # Get current activity name # @return [String] An activity name @@ -46,7 +43,6 @@ module Device # @driver.current_activity # '.ApiDemos' # - # @deprecated Use 'mobile: getCurrentPackage' extension instead. # @!method current_package # Get current package name # @return [String] A package name @@ -56,7 +52,6 @@ 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] @@ -67,7 +62,6 @@ 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 @@ -77,44 +71,6 @@ 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 - # Same as #network_connection_type in selenium-webdriver. - # - # Returns a key of {:airplane_mode: 1, wifi: 2, data: 4, all: 6, none: 0} in #network_connection_type - # Returns a number of the mode in +#get_network_connection+ - # - # @example - # - # @driver.network_connection_type #=> :all - # @driver.get_network_connection #=> 6 - # - - # @deprecated Use 'mobile: getConnectivity' extension instead. - # @!method toggle_wifi - # Switch the state of the wifi service only for Android - # - # @return [String] - # - # @example - # - # @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 - # - # @return [String] - # - # @example - # - # @driver.toggle_data - # - - # @deprecated Use 'mobile: getConnectivity' extension instead. # @!method location # Get the location of the device. # @@ -124,7 +80,6 @@ module Device # # driver.location #=> ::Appium::Location.new(10, 10, 10) # - # @!method location= # Set the [::Appium::Location] of the device. # @@ -149,7 +104,6 @@ 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 # @@ -160,80 +114,17 @@ module Device # @driver.toggle_location_services # - # @deprecated Use 'mobile: getConnectivity' extension instead. - # @!method toggle_airplane_mode - # Toggle flight mode on or off - # - # @example - # - # @driver.toggle_airplane_mode - # - - # @deprecated Use 'mobile: hideKeyboard' extension instead. - # @!method hide_keyboard(close_key = nil, strategy = nil) + # @!method hide_keyboard(close_key = nil) # 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). - # @param [Symbol] strategy The symbol of the strategy which closes the keyboard. - # XCUITest ignore this argument. - # Default for iOS is +:pressKey+. Default for Android is +:tapOutside+. # # @example # # @driver.hide_keyboard # Close a keyboard with the 'Done' button # @driver.hide_keyboard('Finished') # Close a keyboard with the 'Finished' button - # @driver.hide_keyboard(nil, :tapOutside) # Close a keyboard with tapping out side of keyboard - # - - # @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. - # - # Read https://developer.android.com/studio/command-line/adb#IntentSpec for each flags. - # - # @param opts [Hash] Options - # @option opts [String] :app_package The package owning the activity [required] - # @option opts [String] :app_activity The target activity [required] - # @option opts [String] :app_wait_package The package to start before the target package [optional] - # @option opts [String] :app_wait_activity The activity to start before the target activity [optional] - # @option opts [String] :intent_action The intent action to give it when start the target activity (+-a+) [optional] - # @option opts [String] :intent_category The intent category to give it when start the target activity (+-c+) [optional] - # @option opts [String] :intent_flags The intent flag to give it when start the target activity (+-f+) [optional] - # @option opts [String] :optional_intent_arguments The optional intent action to give it when start the target activity [optional] - # You can set arbitrary arguments with space as string. - # e.g. +'--ez your_extra_bool bool --ei your_extra_int 1'+ - # @option opts [bool] :dont_stop_app_on_reset Do not stop the app when the reset is called in Appium create/delete session [optional] - # - # @example - # - # start_activity app_package: 'io.appium.android.apis', - # 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. - # - # @param [String] mode Bit mask that represent the network mode - # Or the key matched with {:airplane_mode: 1, wifi: 2, data: 4, all: 6, none: 0} - # - # Value (Alias) | Data | Wifi | Airplane Mode - # ------------------------------------------------- - # 1 (Airplane Mode) | 0 | 0 | 1 - # 6 (All network on) | 1 | 1 | 0 - # 4 (Data only) | 1 | 0 | 0 - # 2 (Wifi only) | 0 | 1 | 0 - # 0 (None) | 0 | 0 | 0 - # - # @example - # - # @driver.set_network_connection 1 - # @driver.set_network_connection :airplane_mode - # @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. @@ -244,17 +135,15 @@ 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) + # @!method get_performance_data(package_name:, data_type:) # Get the resource usage information of the application. # https://github.com/appium/appium-base-driver/blob/be29aec2318316d12b5c3295e924a5ba8f09b0fb/lib/mjsonwp/routes.js#L303 # @param [String] package_name: Package name # @param [String] data_type: Data type get with +get_performance_data_types+ - # @param [String] data_read_timeout: Command timeout. Default is 2. # # @example # - # @driver.get_performance_data package_name: package_name, data_type: data_type, data_read_timeout: 2 + # @driver.get_performance_data package_name: package_name, data_type: data_type # # @!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 # @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. # @@ -364,110 +252,51 @@ 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 + execute_script 'mobile:openNotifications', {} 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 + execute_script 'mobile:getCurrentActivity', {} 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 + execute_script 'mobile:getCurrentPackage', {} 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 + execute_script 'mobile:getSystemBars', {} 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 + execute_script 'mobile:getSystemBars', {} 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 ::Appium::Core::Error::ArgumentError, 'opts must be a hash' unless opts.is_a? Hash - - option = {} - - app_package = opts[:app_package] - raise ::Appium::Core::Error::ArgumentError, 'app_package is required' unless app_package - - app_activity = opts[:app_activity] - raise ::Appium::Core::Error::ArgumentError, 'app_activity is required' unless app_activity - - option[:appPackage] = app_package - option[:appActivity] = app_activity - - app_wait_package = opts.fetch(:app_wait_package, nil) - app_wait_activity = opts.fetch(:app_wait_activity, nil) - option[:appWaitPackage] = app_wait_package if app_wait_package - option[:appWaitActivity] = app_wait_activity if app_wait_activity - - intent_action = opts.fetch(:intent_action, nil) - intent_category = opts.fetch(:intent_category, nil) - intent_flags = opts.fetch(:intent_flags, nil) - optional_intent_arguments = opts.fetch(:optional_intent_arguments, nil) - dont_stop_app_on_reset = opts.fetch(:dont_stop_app_on_reset, nil) - - option[:intentAction] = intent_action if intent_action - option[:intentCategory] = intent_category if intent_category - option[:intentFlags] = intent_flags if intent_flags - option[:optionalIntentArguments] = optional_intent_arguments if optional_intent_arguments - option[:dontStopAppOnReset] = dont_stop_app_on_reset if dont_stop_app_on_reset - - execute :start_activity, {}, option + execute_script 'mobile:toggleGps', {} end end # 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 - option[:strategy] = strategy if strategy - - execute :hide_keyboard, {}, option + def hide_keyboard(_close_key = nil) + execute_script 'mobile:hideKeyboard', {} end end # 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 + execute_script 'mobile:backgroundApp', { seconds: duration } end end @@ -482,7 +311,6 @@ def execute_cdp(cmd, **params) Screen.add_methods Performance.add_methods - Network.add_methods Clipboard.add_methods Emulator.add_methods Authentication.add_methods 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 31d2aa1e..1f94065c 100644 --- a/lib/appium_lib_core/android/device/auth_finger_print.rb +++ b/lib/appium_lib_core/android/device/auth_finger_print.rb @@ -20,14 +20,11 @@ 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}" end - - execute(:finger_print, {}, { fingerprintId: finger_id.to_i }) + execute_script 'mobile:fingerprint', { fingerprintId: finger_id.to_i } end end end # def self.emulator_commands diff --git a/lib/appium_lib_core/android/device/clipboard.rb b/lib/appium_lib_core/android/device/clipboard.rb index 36f217e5..3419e7e4 100644 --- a/lib/appium_lib_core/android/device/clipboard.rb +++ b/lib/appium_lib_core/android/device/clipboard.rb @@ -29,7 +29,7 @@ def get_clipboard(content_type: :plaintext) params = { contentType: content_type } - data = execute(:get_clipboard, {}, params) + data = execute_script 'mobile:getClipboard', params Base64.decode64 data end end @@ -47,7 +47,7 @@ def set_clipboard(content:, content_type: :plaintext, label: nil) } params[:label] = label unless label.nil? - execute(:set_clipboard, {}, params) + execute_script 'mobile:setClipboard', params end end end diff --git a/lib/appium_lib_core/android/device/emulator.rb b/lib/appium_lib_core/android/device/emulator.rb index 12efeb8d..548cddbf 100644 --- a/lib/appium_lib_core/android/device/emulator.rb +++ b/lib/appium_lib_core/android/device/emulator.rb @@ -115,7 +115,7 @@ module Emulator def self.add_methods ::Appium::Core::Device.add_endpoint_method(:send_sms) do def send_sms(phone_number:, message:) - execute(:send_sms, {}, { phoneNumber: phone_number, message: message }) + execute_script 'mobile:sendSms', { phoneNumber: phone_number, message: message } end end @@ -125,7 +125,7 @@ def gsm_call(phone_number:, action:) raise ::Appium::Core::Error::ArgumentError, "action: should be member of #{GSM_CALL_ACTIONS}. Not #{action}." end - execute(:gsm_call, {}, { phoneNumber: phone_number, action: action }) + execute_script 'mobile:gsmCall', { phoneNumber: phone_number, action: action } end end @@ -136,8 +136,7 @@ def gsm_signal(signal_strength) "#{signal_strength} should be member of #{GSM_SIGNALS.keys} " end - execute(:gsm_signal, {}, { signalStrength: GSM_SIGNALS[signal_strength], - signalStrengh: GSM_SIGNALS[signal_strength] }) + execute_script 'mobile:gsmSignal', { strength: GSM_SIGNALS[signal_strength] } end end @@ -147,7 +146,7 @@ def gsm_voice(state) raise ::Appium::Core::Error::ArgumentError, "The state should be member of #{GSM_VOICE_STATES}. Not #{state}." end - execute(:gsm_voice, {}, { state: state }) + execute_script 'mobile:gsmVoice', { state: state } end end @@ -158,7 +157,7 @@ def set_network_speed(netspeed) "The netspeed should be member of #{NET_SPEED}. Not #{netspeed}." end - execute(:set_network_speed, {}, { netspeed: netspeed }) + execute_script 'mobile:networkSpeed', { speed: netspeed } end end @@ -168,7 +167,7 @@ def set_power_capacity(percent) ::Appium::Logger.warn "The percent should be between 0 and 100. Not #{percent}." end - execute(:set_power_capacity, {}, { percent: percent }) + execute_script 'mobile:powerCapacity', { percent: percent } end end @@ -178,7 +177,7 @@ def set_power_ac(state) raise ::Appium::Core::Error::ArgumentError, "The state should be member of #{POWER_AC_STATE}. Not #{state}." end - execute(:set_power_ac, {}, { state: state }) + execute_script 'mobile:powerAc', { state: state } end end end # def self.emulator_commands diff --git a/lib/appium_lib_core/android/device/network.rb b/lib/appium_lib_core/android/device/network.rb deleted file mode 100644 index 1a9fae01..00000000 --- a/lib/appium_lib_core/android/device/network.rb +++ /dev/null @@ -1,71 +0,0 @@ -# frozen_string_literal: true - -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -module Appium - module Core - module Android - module Device - 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 } - type = connection_type.key?(mode) ? connection_type[mode] : mode.to_i - - execute :set_network_connection, {}, type: type - end - end - - ::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 - end - end - end # module Network - end # module Device - end # module Android - end # module Core -end # module Appium diff --git a/lib/appium_lib_core/android/device/performance.rb b/lib/appium_lib_core/android/device/performance.rb index 1874b8ac..66ea98e0 100644 --- a/lib/appium_lib_core/android/device/performance.rb +++ b/lib/appium_lib_core/android/device/performance.rb @@ -20,17 +20,13 @@ 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 + execute_script 'mobile:getPerformanceDataTypes', {} 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) + def get_performance_data(package_name:, data_type:) + execute_script 'mobile:getPerformanceData', { packageName: package_name, dataType: data_type } end end end diff --git a/lib/appium_lib_core/android/device/screen.rb b/lib/appium_lib_core/android/device/screen.rb index 6e464f47..1c5c3d1c 100644 --- a/lib/appium_lib_core/android/device/screen.rb +++ b/lib/appium_lib_core/android/device/screen.rb @@ -20,9 +20,7 @@ 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 + execute_script 'mobile:getDisplayDensity', {} end end diff --git a/lib/appium_lib_core/common/base/bridge.rb b/lib/appium_lib_core/common/base/bridge.rb index e947f4c5..18c04d1d 100644 --- a/lib/appium_lib_core/common/base/bridge.rb +++ b/lib/appium_lib_core/common/base/bridge.rb @@ -245,20 +245,6 @@ def convert_to_element(id) ::Appium::Core::Element.new self, element_id_from(id) end - # For Appium - # override - # called in 'extend DriverExtensions::HasNetworkConnection' - def network_connection - execute :get_network_connection - end - - # For Appium - # override - # called in 'extend DriverExtensions::HasNetworkConnection' - def network_connection=(type) - execute :set_network_connection, {}, { parameters: { type: type } } - end - # For Appium # No implementation for W3C webdriver module # called in 'extend DriverExtensions::HasLocation' diff --git a/lib/appium_lib_core/common/base/driver.rb b/lib/appium_lib_core/common/base/driver.rb index afa1020d..75e34a89 100644 --- a/lib/appium_lib_core/common/base/driver.rb +++ b/lib/appium_lib_core/common/base/driver.rb @@ -20,7 +20,6 @@ require_relative 'rotable' require_relative 'remote_status' require_relative 'has_location' -require_relative 'has_network_connection' require_relative '../wait' module Appium @@ -35,7 +34,6 @@ class Driver < ::Selenium::WebDriver::Driver include ::Appium::Core::Base::TakesScreenshot include ::Appium::Core::Base::HasRemoteStatus include ::Appium::Core::Base::HasLocation - include ::Appium::Core::Base::HasNetworkConnection include ::Appium::Core::Waitable @@ -223,7 +221,6 @@ def key_action(async: false) ) end - # @deprecated Use 'mobile: lock' extension instead. # Lock the device # @return [String] # @@ -234,11 +231,9 @@ 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 @@ -247,12 +242,10 @@ 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 @@ -260,30 +253,22 @@ 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). - # @param [Symbol] strategy The symbol of the strategy which closes the keyboard. - # XCUITest ignore this argument. - # Default for iOS is +:pressKey+. Default for Android is +:tapOutside+. # # @example # # @driver.hide_keyboard # Close a keyboard with the 'Done' button # @driver.hide_keyboard('Finished') # Close a keyboard with the 'Finished' button - # @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 + def hide_keyboard(close_key = nil) + @bridge.hide_keyboard close_key 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. # @@ -292,7 +277,6 @@ 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? @@ -542,7 +526,6 @@ def pull_folder(path) @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 @@ -562,11 +545,9 @@ 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 @@ -586,11 +567,9 @@ 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 Use 'mobile: getAppStrings' extension instead. # Return the hash of all localization strings. # @return [Hash] # @@ -599,11 +578,9 @@ def long_press_keycode(key, metastate: [], flags: []) # @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. @@ -732,7 +709,6 @@ 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 @@ -772,7 +748,6 @@ 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 @@ -780,11 +755,9 @@ 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 @@ -798,7 +771,6 @@ 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/common/base/has_network_connection.rb b/lib/appium_lib_core/common/base/has_network_connection.rb deleted file mode 100644 index 119aa2d5..00000000 --- a/lib/appium_lib_core/common/base/has_network_connection.rb +++ /dev/null @@ -1,56 +0,0 @@ -# frozen_string_literal: true - -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -module Appium - module Core - class Base - # - # @api private - # - module HasNetworkConnection - def network_connection_type - connection_value = @bridge.network_connection - - connection_type = values_to_type[connection_value] - - # In case the connection type is not recognized return the - # connection value. - connection_type || connection_value - end - - def network_connection_type=(connection_type) - raise ::Appium::Core::Error::ArgumentError, 'Invalid connection type' unless valid_type? connection_type - - connection_value = type_to_values[connection_type] - - @bridge.network_connection = connection_value - end - - private - - def type_to_values - { airplane_mode: 1, wifi: 2, data: 4, all: 6, none: 0 } - end - - def values_to_type - type_to_values.invert - end - - def valid_type?(type) - type_to_values.keys.include? type - end - end - end - end -end diff --git a/lib/appium_lib_core/common/command.rb b/lib/appium_lib_core/common/command.rb index 38c4c8d2..7b44a8ce 100644 --- a/lib/appium_lib_core/common/command.rb +++ b/lib/appium_lib_core/common/command.rb @@ -184,75 +184,31 @@ module Commands set_context: [:post, 'session/:session_id/context'], current_context: [:get, 'session/:session_id/context'], - background_app: [:post, 'session/:session_id/appium/app/background'], - app_strings: [:post, 'session/:session_id/appium/app/strings'], - - device_locked?: [:post, 'session/:session_id/appium/device/is_locked'], - unlock: [:post, 'session/:session_id/appium/device/unlock'], - lock: [:post, 'session/:session_id/appium/device/lock'], device_time: [:get, 'session/:session_id/appium/device/system_time'], install_app: [:post, 'session/:session_id/appium/device/install_app'], remove_app: [:post, 'session/:session_id/appium/device/remove_app'], app_installed?: [:post, 'session/:session_id/appium/device/app_installed'], activate_app: [:post, 'session/:session_id/appium/device/activate_app'], terminate_app: [:post, 'session/:session_id/appium/device/terminate_app'], - app_state: [:post, 'session/:session_id/appium/device/app_state'], - shake: [:post, 'session/:session_id/appium/device/shake'], - hide_keyboard: [:post, 'session/:session_id/appium/device/hide_keyboard'], - press_keycode: [:post, 'session/:session_id/appium/device/press_keycode'], - long_press_keycode: [:post, 'session/:session_id/appium/device/long_press_keycode'], push_file: [:post, 'session/:session_id/appium/device/push_file'], pull_file: [:post, 'session/:session_id/appium/device/pull_file'], pull_folder: [:post, 'session/:session_id/appium/device/pull_folder'], - get_clipboard: [:post, 'session/:session_id/appium/device/get_clipboard'], - set_clipboard: [:post, 'session/:session_id/appium/device/set_clipboard'], - finger_print: [:post, 'session/:session_id/appium/device/finger_print'], get_settings: [:get, 'session/:session_id/appium/settings'], update_settings: [:post, 'session/:session_id/appium/settings'], stop_recording_screen: [:post, 'session/:session_id/appium/stop_recording_screen'], start_recording_screen: [:post, 'session/:session_id/appium/start_recording_screen'], compare_images: [:post, 'session/:session_id/appium/compare_images'], - is_keyboard_shown: [:get, 'session/:session_id/appium/device/is_keyboard_shown'], execute_driver: [:post, 'session/:session_id/appium/execute_driver'], post_log_event: [:post, 'session/:session_id/appium/log_event'], get_log_events: [:post, 'session/:session_id/appium/events'] }.freeze COMMAND_ANDROID = { - open_notifications: [:post, 'session/:session_id/appium/device/open_notifications'], - toggle_airplane_mode: [:post, 'session/:session_id/appium/device/toggle_airplane_mode'], - start_activity: [:post, 'session/:session_id/appium/device/start_activity'], - current_activity: [:get, 'session/:session_id/appium/device/current_activity'], - current_package: [:get, 'session/:session_id/appium/device/current_package'], - get_system_bars: [:get, 'session/:session_id/appium/device/system_bars'], - get_display_density: [:get, 'session/:session_id/appium/device/display_density'], - toggle_wifi: [:post, 'session/:session_id/appium/device/toggle_wifi'], - toggle_data: [:post, 'session/:session_id/appium/device/toggle_data'], - toggle_location_services: [:post, 'session/:session_id/appium/device/toggle_location_services'], - get_performance_data_types: [:post, 'session/:session_id/appium/performanceData/types'], - get_performance_data: [:post, 'session/:session_id/appium/getPerformanceData'], - get_network_connection: [:get, 'session/:session_id/network_connection'], # defined also in OSS - set_network_connection: [:post, 'session/:session_id/network_connection'], # defined also in OSS - - # only emulator - send_sms: [:post, 'session/:session_id/appium/device/send_sms'], - gsm_call: [:post, 'session/:session_id/appium/device/gsm_call'], - gsm_signal: [:post, 'session/:session_id/appium/device/gsm_signal'], - gsm_voice: [:post, 'session/:session_id/appium/device/gsm_voice'], - set_network_speed: [:post, 'session/:session_id/appium/device/network_speed'], - set_power_capacity: [:post, 'session/:session_id/appium/device/power_capacity'], - set_power_ac: [:post, 'session/:session_id/appium/device/power_ac'], - # For chromium: https://chromium.googlesource.com/chromium/src/+/master/chrome/test/chromedriver/server/http_handler.cc chrome_send_command: [:post, 'session/:session_id/goog/cdp/execute'] }.freeze - COMMAND_IOS = { - touch_id: [:post, 'session/:session_id/appium/simulator/touch_id'], - toggle_touch_id_enrollment: [:post, 'session/:session_id/appium/simulator/toggle_touch_id_enrollment'] - }.freeze - - COMMANDS = {}.merge(COMMAND).merge(COMMAND_ANDROID).merge(COMMAND_IOS).freeze + COMMANDS = {}.merge(COMMAND).merge(COMMAND_ANDROID).freeze end # module Commands end # module Core end # module Appium diff --git a/lib/appium_lib_core/common/device/app_management.rb b/lib/appium_lib_core/common/device/app_management.rb index 2312f496..706be79c 100644 --- a/lib/appium_lib_core/common/device/app_management.rb +++ b/lib/appium_lib_core/common/device/app_management.rb @@ -19,7 +19,7 @@ module Device module AppManagement def app_strings(language = nil) opts = language ? { language: language } : {} - execute :app_strings, {}, opts + execute_script 'mobile:getAppStrings', opts end def background_app(duration = 0) diff --git a/lib/appium_lib_core/common/device/app_state.rb b/lib/appium_lib_core/common/device/app_state.rb index 1e3af414..53d23713 100644 --- a/lib/appium_lib_core/common/device/app_state.rb +++ b/lib/appium_lib_core/common/device/app_state.rb @@ -26,8 +26,8 @@ module AppState ].freeze def app_state(app_id) - # required: [['appId'], ['bundleId']] - response = execute :app_state, {}, appId: app_id + # appId is for android, bundleId is for ios. + response = execute_script 'mobile:queryAppState', { 'appId': app_id, 'bundleId': app_id } case response when 0, 1, 2, 3, 4 diff --git a/lib/appium_lib_core/common/device/device.rb b/lib/appium_lib_core/common/device/device.rb index 7959828d..fa19dd67 100644 --- a/lib/appium_lib_core/common/device/device.rb +++ b/lib/appium_lib_core/common/device/device.rb @@ -18,13 +18,14 @@ class Base module Device module Device def shake - execute :shake + execute_script 'mobile:shake', {} end def device_time(format = nil) arg = {} arg[:format] = format unless format.nil? - execute :device_time, {}, arg + + execute_script 'mobile:getDeviceTime', arg end end # module Device end # module Device diff --git a/lib/appium_lib_core/common/device/device_lock.rb b/lib/appium_lib_core/common/device/device_lock.rb index fdfb2951..9fb61b9c 100644 --- a/lib/appium_lib_core/common/device/device_lock.rb +++ b/lib/appium_lib_core/common/device/device_lock.rb @@ -19,15 +19,15 @@ module Device module DeviceLock def lock(duration = nil) opts = duration ? { seconds: duration } : {} - execute :lock, {}, opts + execute_script 'mobile:lock', opts end def device_locked? - execute :device_locked? + execute_script 'mobile:isLocked', {} end def unlock - execute :unlock + execute_script 'mobile:unlock', {} end end # module DeviceLock end # module Device diff --git a/lib/appium_lib_core/common/device/keyboard.rb b/lib/appium_lib_core/common/device/keyboard.rb index 868d914b..43ef52f8 100644 --- a/lib/appium_lib_core/common/device/keyboard.rb +++ b/lib/appium_lib_core/common/device/keyboard.rb @@ -17,17 +17,16 @@ module Core class Base module Device module Keyboard - def hide_keyboard(close_key = nil, strategy = nil) + def hide_keyboard(close_key = nil) option = {} - option[:key] = close_key || 'Done' # default to Done key. - option[:strategy] = strategy || :pressKey # default to pressKey + option[:key] = close_key || 'Done' # default to Done key. - execute :hide_keyboard, {}, option + execute_script 'mobile:hideKeyboard', option end def is_keyboard_shown # rubocop:disable Naming/PredicateName - execute :is_keyboard_shown + execute_script 'mobile:isKeyboardShown', {} end end # module Keyboard end # module Device diff --git a/lib/appium_lib_core/common/device/keyevent.rb b/lib/appium_lib_core/common/device/keyevent.rb index 5f8b1bbf..1ef44704 100644 --- a/lib/appium_lib_core/common/device/keyevent.rb +++ b/lib/appium_lib_core/common/device/keyevent.rb @@ -32,18 +32,18 @@ def press_keycode(key, metastate: [], flags: []) args[:metastate] = metastate.reduce(0) { |acc, meta| acc | meta } unless metastate.empty? args[:flags] = flags.reduce(0) { |acc, flag| acc | flag } unless flags.empty? - execute :press_keycode, {}, args + execute_script 'mobile:pressKey', args end def long_press_keycode(key, metastate: [], flags: []) raise ::Appium::Core::Error::ArgumentError, 'flags should be Array' unless flags.is_a? Array raise ::Appium::Core::Error::ArgumentError, 'metastates should be Array' unless metastate.is_a? Array - args = { keycode: key } + args = { keycode: key, isLongPress: true } args[:metastate] = metastate.reduce(0) { |acc, meta| acc | meta } unless metastate.empty? args[:flags] = flags.reduce(0) { |acc, flag| acc | flag } unless flags.empty? - execute :long_press_keycode, {}, args + execute_script 'mobile:pressKey', args end end # module KeyEvent end # module Device diff --git a/lib/appium_lib_core/ios/device.rb b/lib/appium_lib_core/ios/device.rb index fc0aa7ff..26d1aad8 100644 --- a/lib/appium_lib_core/ios/device.rb +++ b/lib/appium_lib_core/ios/device.rb @@ -75,13 +75,13 @@ def extended(_mod) ::Appium::Core::Device.add_endpoint_method(:touch_id) do def touch_id(match = true) - execute :touch_id, {}, match: match + execute_script 'mobile:sendBiometricMatch', { 'type': 'touch_id', match: match } end end ::Appium::Core::Device.add_endpoint_method(:toggle_touch_id_enrollment) do def toggle_touch_id_enrollment(enabled = true) - execute :toggle_touch_id_enrollment, {}, enabled: enabled + execute_script 'mobile:enrollBiometric', { 'isEnabled': enabled } end end diff --git a/lib/appium_lib_core/ios/device/clipboard.rb b/lib/appium_lib_core/ios/device/clipboard.rb index d43a5b5b..2e9d0fbd 100644 --- a/lib/appium_lib_core/ios/device/clipboard.rb +++ b/lib/appium_lib_core/ios/device/clipboard.rb @@ -29,7 +29,7 @@ def get_clipboard(content_type: :plaintext) params = { contentType: content_type } - data = execute(:get_clipboard, {}, params) + data = execute_script 'mobile:getClipboard', params Base64.decode64 data end end @@ -46,7 +46,7 @@ def set_clipboard(content:, content_type: :plaintext) content: Base64.strict_encode64(content) } - execute(:set_clipboard, {}, params) + execute_script 'mobile:setClipboard', params end end end diff --git a/lib/appium_lib_core/ios/xcuitest/device.rb b/lib/appium_lib_core/ios/xcuitest/device.rb index 6604aab2..8f7d08ea 100644 --- a/lib/appium_lib_core/ios/xcuitest/device.rb +++ b/lib/appium_lib_core/ios/xcuitest/device.rb @@ -25,13 +25,9 @@ module Device # rubocop:disable Layout/LineLength - # @deprecated Use 'mobile: hideKeyboard' extension instead. - # @!method hide_keyboard(close_key = nil, strategy = nil) + # @!method hide_keyboard(close_key = nil) # Hide the onscreen keyboard # @param [String] close_key The name of the key which closes the keyboard. - # @param [Symbol] strategy The symbol of the strategy which closes the keyboard. - # XCUITest ignore this argument. - # Default for iOS is +:pressKey+. Default for Android is +:tapOutside+. # # @example # @@ -39,7 +35,6 @@ 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. @@ -183,23 +178,19 @@ class << self def extended(_mod) # Xcuitest, Override included method in bridge ::Appium::Core::Device.add_endpoint_method(:hide_keyboard) do - def hide_keyboard(close_key = nil, strategy = nil) + def hide_keyboard(close_key = nil) option = {} option[:key] = close_key if close_key - option[:strategy] = strategy if strategy - execute :hide_keyboard, {}, option + execute_script 'mobile:hideKeyboard', option end end # Xcuitest, Override included method in bridge ::Appium::Core::Device.add_endpoint_method(:background_app) do def background_app(duration = 0) - # https://github.com/appium/ruby_lib/issues/500, https://github.com/appium/appium/issues/7741 - # 'execute :background_app, {}, seconds: { timeout: duration_milli_sec }' works over Appium 1.6.4 - duration_milli_sec = duration.nil? ? nil : duration * 1000 - execute :background_app, {}, seconds: { timeout: duration_milli_sec } + execute_script 'mobile:backgroundApp', { seconds: duration } end end diff --git a/sig/lib/appium_lib_core/common/base/driver.rbs b/sig/lib/appium_lib_core/common/base/driver.rbs index 956446d5..cb13f5d9 100644 --- a/sig/lib/appium_lib_core/common/base/driver.rbs +++ b/sig/lib/appium_lib_core/common/base/driver.rbs @@ -32,8 +32,6 @@ module Appium include Base::HasLocation - include Base::HasNetworkConnection - include Core::Waitable attr_reader bridge: untyped @@ -62,7 +60,7 @@ module Appium def unlock: () -> untyped - def hide_keyboard: (?untyped? close_key, ?untyped? strategy) -> untyped + def hide_keyboard: (?untyped? close_key) -> untyped def keyboard_shown?: () -> untyped diff --git a/sig/lib/appium_lib_core/common/base/has_network_connection.rbs b/sig/lib/appium_lib_core/common/base/has_network_connection.rbs deleted file mode 100644 index 2b9b562f..00000000 --- a/sig/lib/appium_lib_core/common/base/has_network_connection.rbs +++ /dev/null @@ -1,19 +0,0 @@ -module Appium - module Core - class Base - module HasNetworkConnection - def network_connection_type: () -> untyped - - def network_connection_type=: (untyped connection_type) -> untyped - - private - - def type_to_values: () -> Hash[Symbol, Integer] - - def values_to_type: () -> untyped - - def valid_type?: (untyped type) -> untyped - end - end - end -end diff --git a/test/functional/android/android/device_data_test.rb b/test/functional/android/android/device_data_test.rb index 8629e4d3..720ef589 100644 --- a/test/functional/android/android/device_data_test.rb +++ b/test/functional/android/android/device_data_test.rb @@ -71,8 +71,7 @@ def test_performance_related assert_equal [%w(user kernel), %w(0 0)], @driver.get_performance_data(package_name: 'io.appium.android.apis', - data_type: 'cpuinfo', - data_read_timeout: 10) + data_type: 'cpuinfo') end def test_take_element_screenshot diff --git a/test/functional/android/android/device_test.rb b/test/functional/android/android/device_test.rb index 9e7e21b9..e13e1ef6 100644 --- a/test/functional/android/android/device_test.rb +++ b/test/functional/android/android/device_test.rb @@ -49,9 +49,9 @@ def test_shake end def test_lock_unlock - @driver.lock + @driver.lock 0 # Unstable on CI - @@core.wait { assert @@driver.device_locked? } unless ci? + @@core.wait { assert @driver.device_locked? } unless ci? @driver.unlock @driver.wait_until { |d| assert !d.device_locked? } @@ -151,26 +151,6 @@ def test_app_management @driver.wait_until { assert @driver.app_state('io.appium.android.apis') == :running_in_foreground } end - def test_start_activity - e = @driver.wait_until(&:current_activity) - assert_equal '.ApiDemos', e - - @driver.start_activity app_package: 'io.appium.android.apis', - app_activity: '.accessibility.AccessibilityNodeProviderActivity' - e = @driver.wait_until(&:current_activity) - assert true, e.include?('Node') - - # Espresso cannot launch my root launched activity: https://github.com/appium/appium-espresso-driver/pull/378#discussion_r250034209 - return if @@core.automation_name == :espresso - - @driver.start_activity app_package: 'com.android.settings', app_activity: '.Settings', - app_wait_package: 'com.android.settings', app_wait_activity: '.Settings' - e = @driver.wait_until(&:current_activity) - assert true, e.include?('Settings') - - @driver.start_activity app_package: 'io.appium.android.apis', app_activity: '.ApiDemos' - end - def test_current_package e = @driver.wait_until(&:current_package) assert_equal 'io.appium.android.apis', e @@ -228,9 +208,9 @@ def test_open_notifications # test & comments from https://github.com/appium/appium/blob/1.x/test/functional/android/apidemos/notifications-specs.js#L19 # get to the notification page - @@core.wait { scroll_to('App').click } + @@core.wait { @driver.find_element(:accessibility_id, 'App').click } @@core.wait { scroll_to('Notification').click } - @@core.wait { scroll_to('Status Bar').click } + @@core.wait { @driver.find_element(:accessibility_id, 'Status Bar').click } # create a notification @@core.wait { @driver.find_element :accessibility_id, ':-|' }.click @driver.open_notifications @@ -245,7 +225,7 @@ def test_open_notifications end # should see the notification - @@core.wait_true { text 'Mood ring' } + @@core.wait_true { @driver.find_element :xpath, '//*[@text="Mood ring"]' } # return to app @driver.back # should be able to see elements from app @@ -311,10 +291,6 @@ def resource_id(string, on_match) resource_id = %r{^[a-zA-Z_][a-zA-Z0-9._]*:[^\/]+\/\S+$} string.match(resource_id) ? on_match : '' end - - def text(value) - @driver.find_element :uiautomator, "new UiSelector().className(\"android.widget.TextView\").text(\"#{value}\");" - end end end end diff --git a/test/functional/android/android/mobile_commands_test.rb b/test/functional/android/android/mobile_commands_test.rb index a9061776..05b6cf48 100644 --- a/test/functional/android/android/mobile_commands_test.rb +++ b/test/functional/android/android/mobile_commands_test.rb @@ -213,7 +213,7 @@ def test_webatom el = @core.wait { @driver.find_element(:id, 'wv1') } @driver.execute_script 'mobile: webAtoms', { - webviewElement: el.id, + webviewEl: el.id, forceJavascriptEnabled: true, methodChain: [ { name: 'withElement', atom: { name: 'findElement', locator: { using: 'ID', value: 'i_am_a_textbox' } } }, diff --git a/test/functional/android/webdriver/device_test.rb b/test/functional/android/webdriver/device_test.rb index 0f2c7848..d51e16a6 100644 --- a/test/functional/android/webdriver/device_test.rb +++ b/test/functional/android/webdriver/device_test.rb @@ -126,14 +126,6 @@ def test_logs assert_equal %i(logcat bugreport server), @driver.logs.available_types assert @driver.logs.get(:logcat) end - - def test_network_connection - assert @driver.get_network_connection - assert @driver.network_connection_type - assert @driver.set_network_connection(6) - # TODO: depends on selenium-webdriver. Test failed with webdriver 3.11.0 with a number. - assert @driver.network_connection_type = :all - end end end end diff --git a/test/functional/ios/ios/device_test.rb b/test/functional/ios/ios/device_test.rb index f1255bf4..b6926ac9 100644 --- a/test/functional/ios/ios/device_test.rb +++ b/test/functional/ios/ios/device_test.rb @@ -221,7 +221,7 @@ def test_hidekeyboard @@core.wait do @@driver.hide_keyboard - sleep 1 # wait animation + sleep 2 # wait animation end m = assert_raises ::Selenium::WebDriver::Error::WebDriverError do diff --git a/test/unit/android/device/w3c/app_management_test.rb b/test/unit/android/device/w3c/app_management_test.rb index 38361da0..659c7dd9 100644 --- a/test/unit/android/device/w3c/app_management_test.rb +++ b/test/unit/android/device/w3c/app_management_test.rb @@ -29,22 +29,23 @@ def setup end def test_app_strings - stub_request(:post, "#{SESSION}/appium/app/strings") + stub_request(:post, "#{SESSION}/execute/sync") + .with(body: { script: 'mobile:getAppStrings', args: [{}] }.to_json) .to_return(headers: HEADER, status: 200, body: { value: 'xxxx' }.to_json) @driver.app_strings - assert_requested(:post, "#{SESSION}/appium/app/strings", times: 1) + assert_requested(:post, "#{SESSION}/execute/sync", times: 1) end def test_background_app - stub_request(:post, "#{SESSION}/appium/app/background") - .with(body: { seconds: 0 }.to_json) + stub_request(:post, "#{SESSION}/execute/sync") + .with(body: { script: 'mobile:backgroundApp', args: [{ seconds: 0 }] }.to_json) .to_return(headers: HEADER, status: 200, body: { value: '' }.to_json) @driver.background_app 0 - assert_requested(:post, "#{SESSION}/appium/app/background", times: 1) + assert_requested(:post, "#{SESSION}/execute/sync", times: 1) end def test_terminate_app @@ -76,12 +77,16 @@ def test_activate_app end def test_app_state - stub_request(:post, "#{SESSION}/appium/device/app_state") + stub_request(:post, "#{SESSION}/execute/sync") + .with(body: { + script: 'mobile:queryAppState', + args: [{ 'appId' => 'com.app.id', 'bundleId' => 'com.app.id' }] + }.to_json) .to_return(headers: HEADER, status: 200, body: { value: 4 }.to_json) state = @driver.app_state 'com.app.id' - assert_requested(:post, "#{SESSION}/appium/device/app_state", times: 1) + assert_requested(:post, "#{SESSION}/execute/sync", times: 1) assert_equal :running_in_foreground, state end diff --git a/test/unit/android/device/w3c/commands_test.rb b/test/unit/android/device/w3c/commands_test.rb index 327da143..0b496b16 100644 --- a/test/unit/android/device/w3c/commands_test.rb +++ b/test/unit/android/device/w3c/commands_test.rb @@ -38,72 +38,68 @@ def test_delete end def test_shake - stub_request(:post, "#{SESSION}/appium/device/shake") + stub_request(:post, "#{SESSION}/execute/sync") + .with(body: { script: 'mobile:shake', args: [{}] }.to_json) .to_return(headers: HEADER, status: 200, body: { value: nil }.to_json) @driver.shake - assert_requested(:post, "#{SESSION}/appium/device/shake", times: 1) + assert_requested(:post, "#{SESSION}/execute/sync", times: 1) end def test_device_time - stub_request(:get, "#{SESSION}/appium/device/system_time") - .with(body: {}.to_json) + stub_request(:post, "#{SESSION}/execute/sync") + .with(body: { script: 'mobile:getDeviceTime', args: [{}] }.to_json) .to_return(headers: HEADER, status: 200, body: { value: 'device time' }.to_json) @driver.device_time - assert_requested(:get, "#{SESSION}/appium/device/system_time", times: 1) + assert_requested(:post, "#{SESSION}/execute/sync", times: 1) end def test_device_time_with_format - stub_request(:get, "#{SESSION}/appium/device/system_time") - .with(body: { format: 'YYYY-MM-DD' }.to_json) + stub_request(:post, "#{SESSION}/execute/sync") + .with(body: { script: 'mobile:getDeviceTime', args: [{ format: 'YYYY-MM-DD' }] }.to_json) .to_return(headers: HEADER, status: 200, body: { value: 'device time' }.to_json) @driver.device_time('YYYY-MM-DD') - assert_requested(:get, "#{SESSION}/appium/device/system_time", times: 1) + assert_requested(:post, "#{SESSION}/execute/sync", times: 1) end def test_open_notifications - stub_request(:post, "#{SESSION}/appium/device/open_notifications") + stub_request(:post, "#{SESSION}/execute/sync") + .with(body: { script: 'mobile:openNotifications', args: [{}] }.to_json) .to_return(headers: HEADER, status: 200, body: { value: nil }.to_json) @driver.open_notifications - assert_requested(:post, "#{SESSION}/appium/device/open_notifications", times: 1) - end - - def test_toggle_airplane_mode - stub_request(:post, "#{SESSION}/appium/device/toggle_airplane_mode") - .to_return(headers: HEADER, status: 200, body: { value: nil }.to_json) - - @driver.toggle_airplane_mode - - assert_requested(:post, "#{SESSION}/appium/device/toggle_airplane_mode", times: 1) + assert_requested(:post, "#{SESSION}/execute/sync", times: 1) end def test_current_activity - stub_request(:get, "#{SESSION}/appium/device/current_activity") + stub_request(:post, "#{SESSION}/execute/sync") + .with(body: { script: 'mobile:getCurrentActivity', args: [{}] }.to_json) .to_return(headers: HEADER, status: 200, body: { value: 'A' }.to_json) @driver.current_activity - assert_requested(:get, "#{SESSION}/appium/device/current_activity", times: 1) + assert_requested(:post, "#{SESSION}/execute/sync", times: 1) end def test_current_package - stub_request(:get, "#{SESSION}/appium/device/current_package") + stub_request(:post, "#{SESSION}/execute/sync") + .with(body: { script: 'mobile:getCurrentPackage', args: [{}] }.to_json) .to_return(headers: HEADER, status: 200, body: { value: 'A' }.to_json) @driver.current_package - assert_requested(:get, "#{SESSION}/appium/device/current_package", times: 1) + assert_requested(:post, "#{SESSION}/execute/sync", times: 1) end def test_get_system_bars - stub_request(:get, "#{SESSION}/appium/device/system_bars") + stub_request(:post, "#{SESSION}/execute/sync") + .with(body: { script: 'mobile:getSystemBars', args: [{}] }.to_json) .to_return(headers: HEADER, status: 200, body: { value: { statusBar: { visible: true, x: 0, y: 0, width: 1080, height: 63 }, navigationBar: { visible: true, x: 0, y: 1794, width: 1080, height: 126 } @@ -111,35 +107,28 @@ def test_get_system_bars info = @driver.get_system_bars - assert_requested(:get, "#{SESSION}/appium/device/system_bars", times: 1) + assert_requested(:post, "#{SESSION}/execute/sync", times: 1) assert_equal({ 'visible' => true, 'x' => 0, 'y' => 0, 'width' => 1080, 'height' => 63 }, info['statusBar']) end def test_get_display_density - stub_request(:get, "#{SESSION}/appium/device/display_density") + stub_request(:post, "#{SESSION}/execute/sync") + .with(body: { script: 'mobile:getDisplayDensity', args: [{}] }.to_json) .to_return(headers: HEADER, status: 200, body: { value: 'A' }.to_json) @driver.get_display_density - assert_requested(:get, "#{SESSION}/appium/device/display_density", times: 1) - end - - def test_get_network_connection - stub_request(:get, "#{SESSION}/network_connection") - .to_return(headers: HEADER, status: 200, body: { value: 'A' }.to_json) - - @driver.get_network_connection - - assert_requested(:get, "#{SESSION}/network_connection", times: 1) + assert_requested(:post, "#{SESSION}/execute/sync", times: 1) end def test_get_performance_data_types - stub_request(:post, "#{SESSION}/appium/performanceData/types") + stub_request(:post, "#{SESSION}/execute/sync") + .with(body: { script: 'mobile:getPerformanceDataTypes', args: [{}] }.to_json) .to_return(headers: HEADER, status: 200, body: { value: ['a'] }.to_json) @driver.get_performance_data_types - assert_requested(:post, "#{SESSION}/appium/performanceData/types", times: 1) + assert_requested(:post, "#{SESSION}/execute/sync", times: 1) end def test_push_file @@ -214,56 +203,17 @@ def test_settings_update_equal assert_requested(:post, "#{SESSION}/appium/settings", times: 1) end - def test_start_activity - stub_request(:post, "#{SESSION}/appium/device/start_activity") - .with(body: { appPackage: 'package', appActivity: 'activity', intentAction: 'action.MAIN' }.to_json) - .to_return(headers: HEADER, status: 200, body: { value: '' }.to_json) - @driver.start_activity(app_activity: 'activity', app_package: 'package', intent_action: 'action.MAIN') - - assert_requested(:post, "#{SESSION}/appium/device/start_activity", times: 1) - end - - def test_start_activity_with_wait - stub_request(:post, "#{SESSION}/appium/device/start_activity") - .with(body: { appPackage: 'package', appActivity: 'activity', - appWaitPackage: 'wait_package', appWaitActivity: 'wait_activity', - intentAction: 'action.MAIN', dontStopAppOnReset: true }.to_json) - .to_return(headers: HEADER, status: 200, body: { value: '' }.to_json) - - @driver.start_activity(app_activity: 'activity', app_package: 'package', - app_wait_package: 'wait_package', app_wait_activity: 'wait_activity', - intent_action: 'action.MAIN', dont_stop_app_on_reset: true) - - assert_requested(:post, "#{SESSION}/appium/device/start_activity", times: 1) - end - - def test_set_network_connection - stub_request(:post, "#{SESSION}/network_connection") - .with(body: { type: 1 }.to_json) - .to_return(headers: HEADER, status: 200, body: { value: '' }.to_json) - - @driver.set_network_connection 1 - - assert_requested(:post, "#{SESSION}/network_connection", times: 1) - end - - def test_set_network_connection_key - stub_request(:post, "#{SESSION}/network_connection") - .with(body: { type: 6 }.to_json) - .to_return(headers: HEADER, status: 200, body: { value: '' }.to_json) - - @driver.set_network_connection :all - - assert_requested(:post, "#{SESSION}/network_connection", times: 1) - end - def test_get_perfoemance_data - stub_request(:post, "#{SESSION}/appium/getPerformanceData") + stub_request(:post, "#{SESSION}/execute/sync") + .with(body: { + script: 'mobile:getPerformanceData', + args: [{ 'packageName' => 'package_name', 'dataType' => 'type' }] + }.to_json) .to_return(headers: HEADER, status: 200, body: { value: '' }.to_json) @driver.get_performance_data(package_name: 'package_name', data_type: 'type') - assert_requested(:post, "#{SESSION}/appium/getPerformanceData", times: 1) + assert_requested(:post, "#{SESSION}/execute/sync", times: 1) end def test_start_recording_screen_default @@ -336,105 +286,84 @@ def test_stop_recording_screen_custom # emulator def test_send_sms - stub_request(:post, "#{SESSION}/appium/device/send_sms") - .with(body: { phoneNumber: '00000000000', message: 'test message' }.to_json) + stub_request(:post, "#{SESSION}/execute/sync") + .with(body: { script: 'mobile:sendSms', args: [{ phoneNumber: '00000000000', message: 'test message' }] }.to_json) .to_return(headers: HEADER, status: 200, body: { value: '' }.to_json) @driver.send_sms phone_number: '00000000000', message: 'test message' - assert_requested(:post, "#{SESSION}/appium/device/send_sms", times: 1) + assert_requested(:post, "#{SESSION}/execute/sync", times: 1) end def test_gsm_call - stub_request(:post, "#{SESSION}/appium/device/gsm_call") - .with(body: { phoneNumber: '00000000000', action: 'call' }.to_json) + stub_request(:post, "#{SESSION}/execute/sync") + .with(body: { script: 'mobile:gsmCall', args: [{ phoneNumber: '00000000000', action: 'call' }] }.to_json) .to_return(headers: HEADER, status: 200, body: { value: '' }.to_json) @driver.gsm_call phone_number: '00000000000', action: :call - assert_requested(:post, "#{SESSION}/appium/device/gsm_call", times: 1) + assert_requested(:post, "#{SESSION}/execute/sync", times: 1) end def test_gsm_signal - stub_request(:post, "#{SESSION}/appium/device/gsm_signal") - .with(body: { signalStrength: ::Appium::Core::Android::Device::Emulator::GSM_SIGNALS[:good], - signalStrengh: ::Appium::Core::Android::Device::Emulator::GSM_SIGNALS[:good] }.to_json) + stub_request(:post, "#{SESSION}/execute/sync") + .with(body: { script: 'mobile:gsmSignal', +args: [{ strength: ::Appium::Core::Android::Device::Emulator::GSM_SIGNALS[:good] }] }.to_json) .to_return(headers: HEADER, status: 200, body: { value: '' }.to_json) @driver.gsm_signal :good - assert_requested(:post, "#{SESSION}/appium/device/gsm_signal", times: 1) + assert_requested(:post, "#{SESSION}/execute/sync", times: 1) end def test_gsm_voice - stub_request(:post, "#{SESSION}/appium/device/gsm_voice") - .with(body: { state: 'on' }.to_json) + stub_request(:post, "#{SESSION}/execute/sync") + .with(body: { script: 'mobile:gsmVoice', args: [{ state: 'on' }] }.to_json) .to_return(headers: HEADER, status: 200, body: { value: '' }.to_json) @driver.gsm_voice :on - assert_requested(:post, "#{SESSION}/appium/device/gsm_voice", times: 1) + assert_requested(:post, "#{SESSION}/execute/sync", times: 1) end def test_network_speed - stub_request(:post, "#{SESSION}/appium/device/network_speed") - .with(body: { netspeed: 'gsm' }.to_json) + stub_request(:post, "#{SESSION}/execute/sync") + .with(body: { script: 'mobile:networkSpeed', args: [{ speed: 'gsm' }] }.to_json) .to_return(headers: HEADER, status: 200, body: { value: '' }.to_json) @driver.set_network_speed :gsm - assert_requested(:post, "#{SESSION}/appium/device/network_speed", times: 1) + assert_requested(:post, "#{SESSION}/execute/sync", times: 1) end def test_set_power_capacity - stub_request(:post, "#{SESSION}/appium/device/power_capacity") - .with(body: { percent: 10 }.to_json) + stub_request(:post, "#{SESSION}/execute/sync") + .with(body: { script: 'mobile:powerCapacity', args: [{ percent: 10 }] }.to_json) .to_return(headers: HEADER, status: 200, body: { value: '' }.to_json) @driver.set_power_capacity 10 - assert_requested(:post, "#{SESSION}/appium/device/power_capacity", times: 1) + assert_requested(:post, "#{SESSION}/execute/sync", times: 1) end def test_power_ac - stub_request(:post, "#{SESSION}/appium/device/power_ac") - .with(body: { state: 'on' }.to_json) + stub_request(:post, "#{SESSION}/execute/sync") + .with(body: { script: 'mobile:powerAc', args: [{ state: 'on' }] }.to_json) .to_return(headers: HEADER, status: 200, body: { value: '' }.to_json) @driver.set_power_ac :on - assert_requested(:post, "#{SESSION}/appium/device/power_ac", times: 1) - end - - # toggles - def test_toggle_wifi - stub_request(:post, "#{SESSION}/appium/device/toggle_wifi") - .with(body: '{}') - .to_return(headers: HEADER, status: 200, body: { value: '' }.to_json) - - @driver.toggle_wifi - - assert_requested(:post, "#{SESSION}/appium/device/toggle_wifi", times: 1) - end - - def test_toggle_data - stub_request(:post, "#{SESSION}/appium/device/toggle_data") - .with(body: '{}') - .to_return(headers: HEADER, status: 200, body: { value: '' }.to_json) - - @driver.toggle_data - - assert_requested(:post, "#{SESSION}/appium/device/toggle_data", times: 1) + assert_requested(:post, "#{SESSION}/execute/sync", times: 1) end def test_toggle_location_services - stub_request(:post, "#{SESSION}/appium/device/toggle_location_services") - .with(body: '{}') + stub_request(:post, "#{SESSION}/execute/sync") + .with(body: { script: 'mobile:toggleGps', args: [{}] }) .to_return(headers: HEADER, status: 200, body: { value: '' }.to_json) @driver.toggle_location_services - assert_requested(:post, "#{SESSION}/appium/device/toggle_location_services", times: 1) + assert_requested(:post, "#{SESSION}/execute/sync", times: 1) end def test_get_battery_info diff --git a/test/unit/android/device/w3c/definition_test.rb b/test/unit/android/device/w3c/definition_test.rb index 5d167f02..7d57ffa1 100644 --- a/test/unit/android/device/w3c/definition_test.rb +++ b/test/unit/android/device/w3c/definition_test.rb @@ -50,14 +50,11 @@ def test_with_arg_definitions :device_time, :current_context, :open_notifications, - :toggle_airplane_mode, :current_activity, :current_package, :get_system_bars, :get_display_density, :is_keyboard_shown, - :get_network_connection, - :get_performance_data_types, :available_contexts, :set_context, :app_strings, @@ -78,9 +75,6 @@ def test_with_arg_definitions :pull_folder, :get_settings, :update_settings, - :start_activity, - :set_network_connection, - :get_performance_data, :get_clipboard, :set_clipboard, :execute_driver, diff --git a/test/unit/android/device/w3c/device_lock_test.rb b/test/unit/android/device/w3c/device_lock_test.rb index 8240aa79..3fa224f7 100644 --- a/test/unit/android/device/w3c/device_lock_test.rb +++ b/test/unit/android/device/w3c/device_lock_test.rb @@ -29,39 +29,53 @@ def setup end def test_device_locked? - stub_request(:post, "#{SESSION}/appium/device/is_locked") + stub_request(:post, "#{SESSION}/execute/sync") + .with(body: { script: 'mobile:isLocked', args: [{}] }) .to_return(headers: HEADER, status: 200, body: { value: 'true' }.to_json) @driver.device_locked? - assert_requested(:post, "#{SESSION}/appium/device/is_locked", times: 1) + assert_requested(:post, "#{SESSION}/execute/sync", times: 1) end def test_locked? - stub_request(:post, "#{SESSION}/appium/device/is_locked") + stub_request(:post, "#{SESSION}/execute/sync") + .with(body: { script: 'mobile:isLocked', args: [{}] }) .to_return(headers: HEADER, status: 200, body: { value: 'true' }.to_json) @driver.locked? - assert_requested(:post, "#{SESSION}/appium/device/is_locked", times: 1) + assert_requested(:post, "#{SESSION}/execute/sync", times: 1) end def test_unlock - stub_request(:post, "#{SESSION}/appium/device/unlock") + stub_request(:post, "#{SESSION}/execute/sync") + .with(body: { script: 'mobile:unlock', args: [{}] }) .to_return(headers: HEADER, status: 200, body: { value: nil }.to_json) @driver.unlock - assert_requested(:post, "#{SESSION}/appium/device/unlock", times: 1) + assert_requested(:post, "#{SESSION}/execute/sync", times: 1) + end + + def test_lock_no_duration + stub_request(:post, "#{SESSION}/execute/sync") + .with(body: { script: 'mobile:lock', args: [{}] }) + .to_return(headers: HEADER, status: 200, body: { value: '' }.to_json) + + @driver.lock + + assert_requested(:post, "#{SESSION}/execute/sync", times: 1) end def test_lock - stub_request(:post, "#{SESSION}/appium/device/lock") + stub_request(:post, "#{SESSION}/execute/sync") + .with(body: { script: 'mobile:lock', args: [{ seconds: 5 }] }) .to_return(headers: HEADER, status: 200, body: { value: '' }.to_json) @driver.lock 5 - assert_requested(:post, "#{SESSION}/appium/device/lock", times: 1) + assert_requested(:post, "#{SESSION}/execute/sync", times: 1) end end # class DeviceLockTest end # module W3C diff --git a/test/unit/android/device/w3c/keyboard_test.rb b/test/unit/android/device/w3c/keyboard_test.rb index 6a2483da..9eabb2a5 100644 --- a/test/unit/android/device/w3c/keyboard_test.rb +++ b/test/unit/android/device/w3c/keyboard_test.rb @@ -29,46 +29,47 @@ def setup end def test_is_keyboard_shown - stub_request(:get, "#{SESSION}/appium/device/is_keyboard_shown") + stub_request(:post, "#{SESSION}/execute/sync") + .with(body: { script: 'mobile:isKeyboardShown', args: [{}] }.to_json) .to_return(headers: HEADER, status: 200, body: { value: 'A' }.to_json) @driver.is_keyboard_shown - assert_requested(:get, "#{SESSION}/appium/device/is_keyboard_shown", times: 1) + assert_requested(:post, "#{SESSION}/execute/sync", times: 1) end def test_hide_keyboard - stub_request(:post, "#{SESSION}/appium/device/hide_keyboard") - .with(body: { key: 'Done' }.to_json) + stub_request(:post, "#{SESSION}/execute/sync") + .with(body: { script: 'mobile:hideKeyboard', args: [{}] }.to_json) .to_return(headers: HEADER, status: 200, body: { value: '' }.to_json) @driver.hide_keyboard 'Done' - assert_requested(:post, "#{SESSION}/appium/device/hide_keyboard", times: 1) + assert_requested(:post, "#{SESSION}/execute/sync", times: 1) end # keypress def test_press_keycode - stub_request(:post, "#{SESSION}/appium/device/press_keycode") - .with(body: { keycode: 86 }.to_json) + stub_request(:post, "#{SESSION}/execute/sync") + .with(body: { script: 'mobile:pressKey', args: [{ keycode: 86 }] }.to_json) .to_return(headers: HEADER, status: 200, body: { value: '' }.to_json) @driver.press_keycode 86 - assert_requested(:post, "#{SESSION}/appium/device/press_keycode", times: 1) + assert_requested(:post, "#{SESSION}/execute/sync", times: 1) end # keypress def test_press_keycode_with_flags - stub_request(:post, "#{SESSION}/appium/device/press_keycode") - .with(body: { keycode: 86, metastate: 2_097_153, flags: 44 }.to_json) + stub_request(:post, "#{SESSION}/execute/sync") + .with(body: { script: 'mobile:pressKey', args: [{ keycode: 86, metastate: 2_097_153, flags: 44 }] }.to_json) .to_return(headers: HEADER, status: 200, body: { value: '' }.to_json) # metastate is META_SHIFT_ON and META_NUM_LOCK_ON # flags is CANCELFLAG_CANCELEDED, FLAG_KEEP_TOUCH_MODE, FLAG_FROM_SYSTEM @driver.press_keycode 86, metastate: [0x00000001, 0x00200000], flags: [0x20, 0x00000004, 0x00000008] - assert_requested(:post, "#{SESSION}/appium/device/press_keycode", times: 1) + assert_requested(:post, "#{SESSION}/execute/sync", times: 1) end # keypress @@ -87,26 +88,29 @@ def test_press_keycode_with_flags_with_wrong_metastate # keypress def test_long_press_keycode - stub_request(:post, "#{SESSION}/appium/device/long_press_keycode") - .with(body: { keycode: 86 }.to_json) + stub_request(:post, "#{SESSION}/execute/sync") + .with(body: { script: 'mobile:pressKey', args: [{ keycode: 86, isLongPress: true }] }.to_json) .to_return(headers: HEADER, status: 200, body: { value: '' }.to_json) @driver.long_press_keycode 86 - assert_requested(:post, "#{SESSION}/appium/device/long_press_keycode", times: 1) + assert_requested(:post, "#{SESSION}/execute/sync", times: 1) end # keypress def test_long_press_keycodewith_flags - stub_request(:post, "#{SESSION}/appium/device/long_press_keycode") - .with(body: { keycode: 86, metastate: 1, flags: 36 }.to_json) + stub_request(:post, "#{SESSION}/execute/sync") + .with(body: { + script: 'mobile:pressKey', + args: [{ keycode: 86, isLongPress: true, metastate: 1, flags: 36 }] + }.to_json) .to_return(headers: HEADER, status: 200, body: { value: '' }.to_json) # metastate is META_SHIFT_ON # flags is CANCELFLAG_CANCELEDED, FLAG_KEEP_TOUCH_MODE @driver.long_press_keycode 86, metastate: [1], flags: [32, 4] - assert_requested(:post, "#{SESSION}/appium/device/long_press_keycode", times: 1) + assert_requested(:post, "#{SESSION}/execute/sync", times: 1) end # keypress diff --git a/test/unit/android/webdriver/w3c/commands_test.rb b/test/unit/android/webdriver/w3c/commands_test.rb index 056550e1..af6bb130 100644 --- a/test/unit/android/webdriver/w3c/commands_test.rb +++ b/test/unit/android/webdriver/w3c/commands_test.rb @@ -246,8 +246,8 @@ def test_active_element end def test_finger_print - stub_request(:post, "#{SESSION}/appium/device/finger_print") - .with(body: { fingerprintId: 1 }.to_json) + stub_request(:post, "#{SESSION}/execute/sync") + .with(body: { script: 'mobile:fingerprint', 'args': [{ 'fingerprintId' => 1 }] }.to_json) .to_return(headers: HEADER, status: 200, body: { value: { finger: 'name' } }.to_json) error = assert_raises ::Appium::Core::Error::ArgumentError do @@ -257,7 +257,7 @@ def test_finger_print @driver.finger_print 1 - assert_requested(:post, "#{SESSION}/appium/device/finger_print", times: 1) + assert_requested(:post, "#{SESSION}/execute/sync", times: 1) end def test_remote diff --git a/test/unit/ios/device/w3c/commands_test.rb b/test/unit/ios/device/w3c/commands_test.rb index 604c6a78..a0dda5c9 100644 --- a/test/unit/ios/device/w3c/commands_test.rb +++ b/test/unit/ios/device/w3c/commands_test.rb @@ -29,21 +29,23 @@ def setup end def test_touch_id - stub_request(:post, "#{SESSION}/appium/simulator/touch_id") + stub_request(:post, "#{SESSION}/execute/sync") + .with(body: { script: 'mobile:sendBiometricMatch', args: [{ type: 'touch_id', match: true }] }) .to_return(headers: HEADER, status: 200, body: { value: nil }.to_json) @driver.touch_id - assert_requested(:post, "#{SESSION}/appium/simulator/touch_id", times: 1) + assert_requested(:post, "#{SESSION}/execute/sync", times: 1) end def test_toggle_touch_id_enrollment - stub_request(:post, "#{SESSION}/appium/simulator/toggle_touch_id_enrollment") + stub_request(:post, "#{SESSION}/execute/sync") + .with(body: { script: 'mobile:enrollBiometric', args: [{ isEnabled: true }] }) .to_return(headers: HEADER, status: 200, body: { value: nil }.to_json) @driver.toggle_touch_id_enrollment(true) - assert_requested(:post, "#{SESSION}/appium/simulator/toggle_touch_id_enrollment", times: 1) + assert_requested(:post, "#{SESSION}/execute/sync", times: 1) end def test_start_recording_screen @@ -133,13 +135,13 @@ def test_method_missing end def test_background_app - stub_request(:post, "#{SESSION}/appium/app/background") - .with(body: { seconds: { timeout: 0 } }.to_json) + stub_request(:post, "#{SESSION}/execute/sync") + .with(body: { script: 'mobile:backgroundApp', args: [{ seconds: 0 }] }.to_json) .to_return(headers: HEADER, status: 200, body: { value: '' }.to_json) @driver.background_app 0 - assert_requested(:post, "#{SESSION}/appium/app/background", times: 1) + assert_requested(:post, "#{SESSION}/execute/sync", times: 1) end end # class CommandsTest end # module W3C