From 8c423566315b47cf99150a38be09b059aab4d358 Mon Sep 17 00:00:00 2001 From: Kazuaki Matsuo Date: Mon, 1 Nov 2021 23:26:54 +0900 Subject: [PATCH] chore: add deprecated in app management (#353) * chore: add deprecated in app management * update changelog --- CHANGELOG.md | 6 ++- lib/appium_lib_core/common/base/driver.rb | 53 +++++++++---------- lib/appium_lib_core/driver.rb | 3 +- test/unit/windows/device/w3c/commands_test.rb | 18 +++++++ 4 files changed, 50 insertions(+), 30 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cf83404f..6d309dfd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -31,6 +31,7 @@ Read `release_notes.md` for commit level details. - No longer set default `timeouts` as `0` - ruby_lib_core calls `/timeouts` endpoint only when `appium_lib: { wait: 5 }` is provided explicitly - Raises `::Appium::Core::Error::ArgumentError` instead of `ArgumentError` for this library specific argument errors +- Removed Selendroid related methods ### Deprecations - `Appium::Core::TouchAction` and `Appium::Core::MultiTouch` are deprecated @@ -43,7 +44,10 @@ Read `release_notes.md` for commit level details. - https://www.youtube.com/watch?v=oAJ7jwMNFVU - https://appiumpro.com/editions/30-ios-specific-touch-action-methods - https://appiumpro.com/editions/29-automating-complex-gestures-with-the-w3c-actions-api -- Removed Selendroid related methods +- `launch_app`, `close_app` and `reset`. Please read [issues#15807](https://github.com/appium/appium/issues/15807) for more details. + - `activate_app` or a new session request can be alternatives of `launch_app` + - `terminate_app` or close the session request can be alternatives of `close_app` + - Close current session and creating a new session, or `terminate_app` and `launch_app` can be alternatives of `reset` ## [4.7.1] - 2021-09-26 diff --git a/lib/appium_lib_core/common/base/driver.rb b/lib/appium_lib_core/common/base/driver.rb index e05b3c2b..3225cced 100644 --- a/lib/appium_lib_core/common/base/driver.rb +++ b/lib/appium_lib_core/common/base/driver.rb @@ -52,6 +52,10 @@ def initialize(bridge: nil, listener: nil, **opts) @wait_timeout = opts.delete(:wait_timeout) @wait_interval = opts.delete(:wait_interval) + # For logging. + # TODO: Remove when appium core no longer uses this in this bridge. + @automation_name = opts.delete(:automation_name) + super end @@ -414,17 +418,9 @@ def context=(context = null) alias set_context context= # Place a file in a specific location on the device. - # On iOS, the server should have ifuse libraries installed and configured properly for this feature to work on - # real devices. # On Android, the application under test should be built with debuggable flag enabled in order to get access to # its container on the internal file system. # - # {https://github.com/libimobiledevice/ifuse iFuse GitHub page6} - # - # {https://github.com/osxfuse/osxfuse/wiki/FAQ osxFuse FAQ} - # - # {https://developer.android.com/studio/debug 'Debug Your App' developer article} - # # @param [String] path Either an absolute path OR, for iOS devices, a path relative to the app, as described. # If the path starts with application id prefix, then the file will be pushed to the root of # the corresponding application container. @@ -441,18 +437,10 @@ def push_file(path, filedata) @bridge.push_file(path, filedata) end - # Pull a file from the simulator/device. - # On iOS the server should have ifuse - # libraries installed and configured properly for this feature to work on real devices. + # Pull a file from the remote device. # On Android the application under test should be built with debuggable flag enabled in order to get access # to its container on the internal file system. # - # {https://github.com/libimobiledevice/ifuse iFuse GitHub page6} - # - # {https://github.com/osxfuse/osxfuse/wiki/FAQ osxFuse FAQ} - # - # {https://developer.android.com/studio/debug 'Debug Your App' developer article} - # # @param [String] path Either an absolute path OR, for iOS devices, a path relative to the app, as described. # If the path starts with application id prefix, then the file will be pulled from the root # of the corresponding application container. @@ -461,7 +449,6 @@ def push_file(path, filedata) # Only pulling files from application containers is supported for iOS Simulator. # Provide the remote path in format # @bundle.identifier:container_type/relative_path_in_container - # (Make sure this in ifuse doc) # # @return [Base64-decoded] Base64 decoded data # @@ -478,18 +465,10 @@ def pull_file(path) @bridge.pull_file(path) end - # Pull a folder content from the simulator/device. - # On iOS the server should have ifuse libraries installed and configured properly for this feature to work - # on real devices. + # Pull a folder content from the remote device. # On Android the application under test should be built with debuggable flag enabled in order to get access to # its container on the internal file system. # - # {https://github.com/libimobiledevice/ifuse iFuse GitHub page6} - # - # {https://github.com/osxfuse/osxfuse/wiki/FAQ osxFuse FAQ} - # - # {https://developer.android.com/studio/debug 'Debug Your App' developer article} - # # @param [String] path Absolute path to the folder. # If the path starts with @applicationId/ prefix, then the folder will be pulled # from the root of the corresponding application container. @@ -498,7 +477,6 @@ def pull_file(path) # Only pulling files from application containers is supported for iOS Simulator. # Provide the remote path in format # @bundle.identifier:container_type/relative_path_in_container - # (Make sure this in ifuse doc) # # @return [Base64-decoded] Base64 decoded data which is zip archived # @@ -556,6 +534,7 @@ def long_press_keycode(key, metastate: [], flags: []) @bridge.long_press_keycode(key, metastate: metastate, flags: flags) end + # @deprecated Except for Windows # Start the simulator and application configured with desired capabilities # # @example @@ -563,9 +542,16 @@ def long_press_keycode(key, metastate: [], flags: []) # @driver.launch_app # def launch_app + # TODO: Define only in Windows module when ruby_lib_core removes this method + if @automation_name != :windows + ::Appium::Logger.warn( + '[DEPRECATION] launch_app is deprecated. Please use activate_app instead.' + ) + end @bridge.launch_app end + # @deprecated Except for Windows # Close an app on device # # @example @@ -573,9 +559,16 @@ def launch_app # @driver.close_app # def close_app + # TODO: Define only in Windows module when ruby_lib_core removes this method + if @automation_name != :windows + ::Appium::Logger.warn( + '[DEPRECATION] close_app is deprecated. Please use terminate_app instead.' + ) + end @bridge.close_app end + # @deprecated # Reset the device, relaunching the application. # # @example @@ -583,6 +576,10 @@ def close_app # @driver.reset # def reset + ::Appium::Logger.warn( + '[DEPRECATION] reset is deprecated. Please use terminate_app and activate_app, ' \ + 'or quit and create a new session instead.' + ) @bridge.reset end diff --git a/lib/appium_lib_core/driver.rb b/lib/appium_lib_core/driver.rb index c3afd4c1..5305efbd 100644 --- a/lib/appium_lib_core/driver.rb +++ b/lib/appium_lib_core/driver.rb @@ -366,7 +366,8 @@ def start_driver(server_url: nil, capabilities: @caps, # ::Selenium::WebDriver::Remote::Capabilities url: @custom_url, wait_timeout: @wait_timeout, - wait_interval: @wait_interval) + wait_interval: @wait_interval, + automation_name: @automation_name) if @direct_connect d_c = DirectConnections.new(@driver.capabilities) diff --git a/test/unit/windows/device/w3c/commands_test.rb b/test/unit/windows/device/w3c/commands_test.rb index 40a25255..bc12d1d1 100644 --- a/test/unit/windows/device/w3c/commands_test.rb +++ b/test/unit/windows/device/w3c/commands_test.rb @@ -92,6 +92,24 @@ def test_stop_recording_screen_custom assert_requested(:post, "#{SESSION}/appium/stop_recording_screen", times: 1) end + + def test_launch_app + stub_request(:post, "#{SESSION}/appium/app/launch") + .to_return(headers: HEADER, status: 200, body: { value: nil }.to_json) + + @driver.launch_app + + assert_requested(:post, "#{SESSION}/appium/app/launch", times: 1) + end + + def test_close_app + stub_request(:post, "#{SESSION}/appium/app/close") + .to_return(headers: HEADER, status: 200, body: { value: nil }.to_json) + + @driver.close_app + + assert_requested(:post, "#{SESSION}/appium/app/close", times: 1) + end end # class CommandsTest end # module W3C end # module Device