Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: remove deprecated methods #529

Merged
merged 6 commits into from
Mar 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@ Read `release_notes.md` for commit level details.
### Bug fixes

### Deprecations
- Removed deprecated methods
- `launch_app`, `close_app` and `reset`
- Please use `activate_app`, `terminate_app`, or launch/activate/terminate commands by `mobile:` command
- `TouchActions`, `MultiActions`
- Please refer to W3C WebDriver actions
- https://www.rubydoc.info/gems/appium_lib_core/Appium/Core/Base/Bridge#action-instance_method
- `immediate_value` and `replace_value`
- `end_coverage`

## [7.5.0] - 2024-02-21
- Remove upper limitation in `selenium-webdriver`
Expand Down
15 changes: 0 additions & 15 deletions lib/appium_lib_core/android/device.rb
Original file line number Diff line number Diff line change
Expand Up @@ -188,13 +188,6 @@ 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.
Expand Down Expand Up @@ -481,14 +474,6 @@ def background_app(duration = 0)
end
end

# 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

::Appium::Core::Device.add_endpoint_method(:execute_cdp) do
# SeleniumWebdriver could already define this method
return if method_defined? :execute_cdp
Expand Down
1 change: 0 additions & 1 deletion lib/appium_lib_core/common/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
require_relative 'device/ime_actions'
require_relative 'device/setting'
require_relative 'device/context'
require_relative 'device/value'
require_relative 'device/file_management'
require_relative 'device/keyevent'
require_relative 'device/image_comparison'
Expand Down
1 change: 0 additions & 1 deletion lib/appium_lib_core/common/base/bridge.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ class Bridge < ::Selenium::WebDriver::Remote::Bridge
include Device::ImeActions
include Device::Setting
include Device::Context
include Device::Value
include Device::FileManagement
include Device::KeyEvent
include Device::ImageComparison
Expand Down
5 changes: 0 additions & 5 deletions lib/appium_lib_core/common/command.rb
Original file line number Diff line number Diff line change
Expand Up @@ -189,10 +189,6 @@ module Commands
set_context: [:post, 'session/:session_id/context'],
current_context: [:get, 'session/:session_id/context'],

# TODO: remove
set_immediate_value: [:post, 'session/:session_id/appium/element/:id/value'],
replace_value: [:post, 'session/:session_id/appium/element/:id/replace_value'],

background_app: [:post, 'session/:session_id/appium/app/background'],
app_strings: [:post, 'session/:session_id/appium/app/strings'],

Expand Down Expand Up @@ -238,7 +234,6 @@ module Commands
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'],
end_coverage: [:post, 'session/:session_id/appium/app/end_test_coverage'],
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
Expand Down
50 changes: 0 additions & 50 deletions lib/appium_lib_core/common/device/value.rb

This file was deleted.

1 change: 0 additions & 1 deletion lib/appium_lib_core/device.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ def extended(_mod)
:ime_activate, :ime_available_engines, :ime_active_engine, :ime_activated, :ime_deactivate,
:get_settings, :update_settings,
:within_context, :switch_to_default_context, :current_context, :available_contexts, :set_context,
:set_immediate_value, :replace_value,
:push_file, :pull_file, :pull_folder,
:keyevent, :press_keycode, :long_press_keycode,
:match_images_features, :find_image_occurrence, :get_images_similarity, :compare_images,
Expand Down
29 changes: 0 additions & 29 deletions lib/appium_lib_core/element.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,35 +64,6 @@ def respond_to_missing?(*)
# Alias for type
alias type send_keys

# @deprecated Use element send_keys instead.
# Set the value to element directly
#
# @example
#
# element.immediate_value 'hello'
#
def immediate_value(*value)
::Appium::Logger.warn(
'[DEPRECATION] element.immediate_value is deprecated. Please use element.send_keys instead.'
)
@bridge.set_immediate_value @id, *value
end

# @deprecated Use element send_keys or 'mobile: replaceElementValue' for UIAutomator2 instead.
# Replace the value to element directly
#
# @example
#
# element.replace_value 'hello'
#
def replace_value(*value)
::Appium::Logger.warn(
'[DEPRECATION] element.replace_value is deprecated. Please use element.send_keys instead, ' \
'or "mobile: replaceElementValue" for UIAutomator2.'
)
@bridge.replace_value @id, *value
end

# For use with location_rel.
#
# @return [::Selenium::WebDriver::Point] the relative x, y in a struct. ex: { x: 0.50, y: 0.20 }
Expand Down
16 changes: 0 additions & 16 deletions test/functional/android/webdriver/device_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,22 +39,6 @@ def test_remote_status
assert !status['build']['version'].nil?
end

def test_set_immediate_value_and_replace_value
@@core.wait { @driver.find_element :accessibility_id, 'App' }.click
@@core.wait { @driver.find_element :accessibility_id, 'Activity' }.click
@@core.wait { @driver.find_element :accessibility_id, 'Custom Title' }.click

e = @@core.wait { @driver.find_element :id, 'io.appium.android.apis:id/left_text_edit' }
e.immediate_value 'hello'

text = @@core.wait { @driver.find_element :id, 'io.appium.android.apis:id/left_text_edit' }
assert_equal 'Left is besthello', text.text

text.replace_value %w(テスト hello)
replaced_text = @@core.wait { @driver.find_element :id, 'io.appium.android.apis:id/left_text_edit' }
assert_equal '44OG44K544OIaGVsbG/ugIA=', Base64.strict_encode64(replaced_text.text)
end

def test_page_source
require 'rexml/document'

Expand Down
14 changes: 0 additions & 14 deletions test/functional/ios/patch_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,20 +67,6 @@ def test_location_rel
assert_equal '411.0 / 896.0', location.y
end
end

def test_immediate_value
w3c_scroll @@driver

@@core.wait { @@driver.find_element :accessibility_id, 'Text Fields' }.click

text = @@core.wait { @@driver.find_element :class, 'XCUIElementTypeTextField' }
text.immediate_value 'hello'

text = @@core.wait { @@driver.find_element :predicate, 'value == "hello"' }
assert_equal 'hello', text.value

@@driver.back
end
end
end
# rubocop:enable Style/ClassVars
18 changes: 0 additions & 18 deletions test/functional/ios/webdriver/device_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,24 +51,6 @@ def test_remote_status
assert !status['build']['version'].nil?
end

# TODO: replave_value

def test_set_immediate_value
w3c_scroll @@driver

@@core.wait { @@driver.find_element :accessibility_id, 'Text Fields' }.click

e = @@core.wait { @@driver.find_element :predicate, 'value == "Placeholder text"' }
e.click
e.immediate_value 'hello'

# Using predicate case
e = @@core.wait { @@driver.find_element :predicate, by_predicate('hello') }
assert_equal 'hello', e.value

@@driver.back
end

def by_predicate(value)
%(name ==[c] "#{value}" || label ==[c] "#{value}" || value ==[c] "#{value}")
end
Expand Down
9 changes: 0 additions & 9 deletions test/unit/android/device/w3c/app_management_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,6 @@ def test_background_app
assert_requested(:post, "#{SESSION}/appium/app/background", times: 1)
end

def test_end_coverage
stub_request(:post, "#{SESSION}/appium/app/end_test_coverage")
.to_return(headers: HEADER, status: 200, body: { value: '' }.to_json)

@driver.end_coverage 'path/to', 'intent'

assert_requested(:post, "#{SESSION}/appium/app/end_test_coverage", times: 1)
end

def test_terminate_app
stub_request(:post, "#{SESSION}/appium/device/terminate_app")
.to_return(headers: HEADER, status: 200, body: { value: true }.to_json)
Expand Down
1 change: 0 additions & 1 deletion test/unit/android/device/w3c/definition_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ def test_with_arg_definitions
:get_settings,
:update_settings,
:start_activity,
:end_coverage,
:set_network_connection,
:get_performance_data,
:get_clipboard,
Expand Down
42 changes: 0 additions & 42 deletions test/unit/android/device/w3c/keyboard_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -122,48 +122,6 @@ def test_long_press_keycode_with_flags_with_wrong_metastate
@driver.long_press_keycode 86, metastate: 0x02
end
end

## Immediate value
def test_immediate_value
stub_request(:post, "#{SESSION}/appium/element/id/value")
.with(body: { text: 'abc' }.to_json)
.to_return(headers: HEADER, status: 200, body: { value: '' }.to_json)

::Appium::Core::Element.new(@driver.send(:bridge), 'id').immediate_value %w(a b c)

assert_requested(:post, "#{SESSION}/appium/element/id/value", times: 1)
end

def test_replace_value
stub_request(:post, "#{SESSION}/appium/element/id/replace_value")
.with(body: { text: 'abc' }.to_json)
.to_return(headers: HEADER, status: 200, body: { value: '' }.to_json)

::Appium::Core::Element.new(@driver.send(:bridge), 'id').replace_value %w(a b c)

assert_requested(:post, "#{SESSION}/appium/element/id/replace_value", times: 1)
end

## Immediate value
def test_immediate_value_text
stub_request(:post, "#{SESSION}/appium/element/id/value")
.with(body: { text: 'abcテスト' }.to_json)
.to_return(headers: HEADER, status: 200, body: { value: '' }.to_json)

::Appium::Core::Element.new(@driver.send(:bridge), 'id').immediate_value 'abcテスト'

assert_requested(:post, "#{SESSION}/appium/element/id/value", times: 1)
end

def test_replace_value_text
stub_request(:post, "#{SESSION}/appium/element/id/replace_value")
.with(body: { text: 'abcテスト' }.to_json)
.to_return(headers: HEADER, status: 200, body: { value: '' }.to_json)

::Appium::Core::Element.new(@driver.send(:bridge), 'id').replace_value 'abcテスト'

assert_requested(:post, "#{SESSION}/appium/element/id/replace_value", times: 1)
end
end # class CommandsTest
end # module W3C
end # module Device
Expand Down
22 changes: 0 additions & 22 deletions test/unit/common/element_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,28 +54,6 @@ def test_location_rel
assert_equal '110.0 / 667.0', location.y
end

def test_immediate_value
stub_request(:post, "#{SESSION}/appium/element/id/value")
.with(body: { text: 'hello' }.to_json)
.to_return(headers: HEADER, status: 200, body: { value: '' }.to_json)

e = ::Appium::Core::Element.new(@driver.send(:bridge), 'id')
e.immediate_value 'hello'

assert_requested(:post, "#{SESSION}/appium/element/id/value", times: 1)
end

def test_replace
stub_request(:post, "#{SESSION}/appium/element/id/replace_value")
.with(body: { text: 'hello' }.to_json)
.to_return(headers: HEADER, status: 200, body: { value: '' }.to_json)

e = ::Appium::Core::Element.new(@driver.send(:bridge), 'id')
e.replace_value 'hello'

assert_requested(:post, "#{SESSION}/appium/element/id/replace_value", times: 1)
end

def test_element_screenshot_as
stub_request(:get, "#{SESSION}/element/id/screenshot")
.to_return(headers: HEADER, status: 200,
Expand Down
1 change: 0 additions & 1 deletion test/unit/ios/device/w3c/definition_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ def test_with_arg_definitions
:keyevent,
:press_keycode,
:long_press_keycode,
:set_immediate_value,
:push_file,
:pull_file,
:pull_folder,
Expand Down
Loading