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

chore: remove deprecated methods for w3c further #531

Merged
merged 2 commits into from
Mar 6, 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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ Read `release_notes.md` for commit level details.
- https://www.rubydoc.info/gems/appium_lib_core/Appium/Core/Base/Bridge#action-instance_method
- `immediate_value` and `replace_value`
- `end_coverage`
- `sessions` and `session_capabilities` since they are not W3C WebDriver spec and already removed from the dependent selenium clients.
- To get events info, please use `driver.logs.events` instead

## [7.5.0] - 2024-02-21
- Remove upper limitation in `selenium-webdriver`
Expand Down
10 changes: 0 additions & 10 deletions lib/appium_lib_core/common/base/bridge.rb
Original file line number Diff line number Diff line change
Expand Up @@ -168,11 +168,6 @@ def commands(command)
@available_commands[command]
end

# Returns all available sessions on the Appium server instance
def sessions
execute :get_all_sessions
end

def status
execute :status
end
Expand Down Expand Up @@ -205,11 +200,6 @@ def get_timeouts
execute :get_timeouts
end

# Port from MJSONWP
def session_capabilities
::Appium::Core::Base::Capabilities.json_create execute(:get_capabilities)
end

# For Appium
# override
def element_displayed?(element)
Expand Down
95 changes: 0 additions & 95 deletions lib/appium_lib_core/common/base/driver.rb
Original file line number Diff line number Diff line change
Expand Up @@ -913,101 +913,6 @@ def get_timeouts
@bridge.get_timeouts
end

# Retrieve the capabilities of the specified session.
# It's almost same as [email protected]+ but you can get more details.
#
# @return [Selenium::WebDriver::Remote::Capabilities, Selenium::WebDriver::Remote::Capabilities]
#
# @example
# @driver.session_capabilities
#
# #=> uiautomator2
# # <Selenium::WebDriver::Remote::Capabilities:0x007fa38dae1360
# # @capabilities=
# # {:browser_name=>nil,
# # :browser_version=>nil,
# # :platform_name=>"android",
# # :page_load_strategy=>nil,
# # :remote_session_id=>nil,
# # :accessibility_checks=>nil,
# # :profile=>nil,
# # :rotatable=>nil,
# # :device=>nil,
# # "platform"=>"LINUX",
# # "webStorageEnabled"=>false,
# # "takesScreenshot"=>true,
# # "javascriptEnabled"=>true,
# # "databaseEnabled"=>false,
# # "networkConnectionEnabled"=>true,
# # "locationContextEnabled"=>false,
# # "warnings"=>{},
# # "desired"=>
# # {"platformName"=>"android",
# # "automationName"=>"uiautomator2",
# # "app"=>"/path/to/app/api.apk.zip",
# # "platformVersion"=>"8.1.0",
# # "deviceName"=>"Android Emulator",
# # "appPackage"=>"io.appium.android.apis",
# # "appActivity"=>"io.appium.android.apis.ApiDemos",
# # "someCapability"=>"some_capability",
# # "automationName"=>"uiautomator2",
# # "app"=>"/path/to/app/api.apk.zip",
# # "platformVersion"=>"8.1.0",
# # "deviceName"=>"emulator-5554",
# # "appPackage"=>"io.appium.android.apis",
# # "appActivity"=>"io.appium.android.apis.ApiDemos",
# # "someCapability"=>"some_capability",
# # "deviceUDID"=>"emulator-5554",
# # "deviceScreenSize"=>"1080x1920",
# # "deviceScreenDensity"=>420,
# # "deviceModel"=>"Android SDK built for x86",
# # "deviceManufacturer"=>"Google",
# # "pixelRatio"=>2.625,
# # "statBarHeight"=>63,
# # "viewportRect"=>{"left"=>0, "top"=>63, "width"=>1080, "height"=>1731}}>
# #
# #=> XCUITest
# # <Selenium::WebDriver::Remote::Capabilities:0x007fb15dc01370
# # @capabilities=
# # {:browser_name=>"UICatalog",
# # :browser_version=>nil,
# # :platform_name=>"ios",
# # :page_load_strategy=>nil,
# # :remote_session_id=>nil,
# # :accessibility_checks=>nil,
# # :profile=>nil,
# # :rotatable=>nil,
# # :device=>"iphone",
# # "udid"=>"DED4DBAD-8E5E-4AD6-BDC4-E75CF9AD84D8",
# # "automationName"=>"XCUITest",
# # "app"=>"/path/to/app/UICatalog.app",
# # "platformVersion"=>"11.4",
# # "deviceName"=>"iPhone Simulator",
# # "useNewWDA"=>true,
# # "useJSONSource"=>true,
# # "someCapability"=>"some_capability",
# # "sdkVersion"=>"11.4",
# # "CFBundleIdentifier"=>"com.example.apple-samplecode.UICatalog",
# # "pixelRatio"=>2,
# # "statBarHeight"=>23.4375,
# # "viewportRect"=>{"left"=>0, "top"=>47, "width"=>750, "height"=>1287}}>
#
def session_capabilities
@bridge.session_capabilities
end

# Returns available sessions on the Appium server
#
# @return [[Hash]]
#
# @example
#
# @driver.sessions #=> [{'id' => 'c363add8-a7ca-4455-b9e3-9ac4d69e95b3', 'capabilities' => { capabilities as Hash }}]
#
def sessions
@bridge.sessions
end

# Image Comparison
def match_images_features(first_image:,
second_image:,
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 @@ -157,10 +157,6 @@ module Commands

get_timeouts: [:get, 'session/:session_id/timeouts'], # https://w3c.github.io/webdriver/#get-timeouts

# Add OSS commands to W3C commands. We can remove them if we would like to remove them from W3C module.
### Session capability
get_capabilities: [:get, 'session/:session_id'],

### rotatable
get_screen_orientation: [:get, 'session/:session_id/orientation'],
set_screen_orientation: [:post, 'session/:session_id/orientation'],
Expand All @@ -184,7 +180,6 @@ module Commands
###

# common
get_all_sessions: [:get, 'sessions'],
available_contexts: [:get, 'session/:session_id/contexts'],
set_context: [:post, 'session/:session_id/context'],
current_context: [:get, 'session/:session_id/context'],
Expand Down
4 changes: 1 addition & 3 deletions lib/appium_lib_core/common/log.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ def available_types

# @since Appium 1.16.0
#
# Logs a custom event. The event is available via {::Appium::Core::Events#get} or
# <code>@driver.session_capabilities['events']</code> with <code>eventTimings</code> capabilities.
# Logs a custom event. The event is available via {::Appium::Core::Events#get}.
#
# @param [String] vendor The vendor prefix for the event
# @param [String] event The name of event
Expand All @@ -54,7 +53,6 @@ def available_types
# @example
#
# @driver.logs.event vendor: 'appium', event: 'funEvent'
# @driver.session_capabilities['events'] #=> {...., 'appium:funEvent' => 1572957315}
#
# @driver.logs.event = { vendor: 'appium', event: 'anotherEvent' }
# @driver.logs.events #=> {...., 'appium:funEvent' => [1572957315, 1572960305],
Expand Down
5 changes: 0 additions & 5 deletions test/functional/android/webdriver/device_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -134,11 +134,6 @@ def test_network_connection
# TODO: depends on selenium-webdriver. Test failed with webdriver 3.11.0 with a number.
assert @driver.network_connection_type = :all
end

def test_session_capability
# with eventTimings
assert [email protected]_capabilities['events']['commands'].nil?
end
end
end
end
Expand Down
5 changes: 0 additions & 5 deletions test/functional/ios/webdriver/device_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -149,11 +149,6 @@ def test_logs
assert @@driver.logs.get(:syslog)
end

def test_session_capability
# with eventTimings
assert !@@driver.session_capabilities['events']['commands'].nil?
end

# @since Appium 1.10.0
def test_screenshot_quality
skip_as_appium_version '1.10.0'
Expand Down
11 changes: 0 additions & 11 deletions test/unit/android/webdriver/w3c/commands_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -245,17 +245,6 @@ def test_active_element
assert_requested(:get, "#{SESSION}/element/active", times: 1)
end

def test_session_capabilities
stub_request(:get, SESSION.to_s)
.to_return(headers: HEADER, status: 200, body: { value: { sample_key: 'xxx' } }.to_json)

capability = @driver.session_capabilities
assert capability.is_a? Selenium::WebDriver::Remote::Capabilities
assert capability['sample_key'] == 'xxx'

assert_requested(:get, SESSION.to_s, times: 1)
end

def test_finger_print
stub_request(:post, "#{SESSION}/appium/device/finger_print")
.with(body: { fingerprintId: 1 }.to_json)
Expand Down
11 changes: 1 addition & 10 deletions test/unit/common_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -80,18 +80,9 @@ def test_create_session_w3c
.with(body: { capabilities: { alwaysMatch: APPIUM_PREFIX_CAPS, firstMatch: [{}] } }.to_json)
.to_return(headers: Mock::HEADER, status: 200, body: response)

stub_request(:get, 'http://127.0.0.1:4723/wd/hub/sessions')
.to_return(headers: Mock::HEADER, status: 200, body: { value: [{ id: 'c363add8-a7ca-4455-b9e3-9ac4d69e95b3',
capabilities: CAPS }] }.to_json)

driver = ::Appium::Core.for({ caps: CAPS, appium_lib: {} }).start_driver
_driver = ::Appium::Core.for({ caps: CAPS, appium_lib: {} }).start_driver

assert_requested(:post, 'http://127.0.0.1:4723/wd/hub/session', times: 1)

sessions = driver.sessions
assert_requested(:get, 'http://127.0.0.1:4723/wd/hub/sessions', times: 1)
assert_equal 1, sessions.length
assert_equal 'c363add8-a7ca-4455-b9e3-9ac4d69e95b3', sessions.first['id']
end

def test_create_session_w3c_with_http_package
Expand Down
Loading