Skip to content

Commit a1684f0

Browse files
authored
chore: remove deprecated methods for w3c further (#531)
* chore: remove deprecated methods for w3c further * cleanup further
1 parent fb5a545 commit a1684f0

File tree

9 files changed

+4
-144
lines changed

9 files changed

+4
-144
lines changed

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ Read `release_notes.md` for commit level details.
1717
- https://www.rubydoc.info/gems/appium_lib_core/Appium/Core/Base/Bridge#action-instance_method
1818
- `immediate_value` and `replace_value`
1919
- `end_coverage`
20+
- `sessions` and `session_capabilities` since they are not W3C WebDriver spec and already removed from the dependent selenium clients.
21+
- To get events info, please use `driver.logs.events` instead
2022

2123
## [7.5.0] - 2024-02-21
2224
- Remove upper limitation in `selenium-webdriver`

lib/appium_lib_core/common/base/bridge.rb

-10
Original file line numberDiff line numberDiff line change
@@ -168,11 +168,6 @@ def commands(command)
168168
@available_commands[command]
169169
end
170170

171-
# Returns all available sessions on the Appium server instance
172-
def sessions
173-
execute :get_all_sessions
174-
end
175-
176171
def status
177172
execute :status
178173
end
@@ -205,11 +200,6 @@ def get_timeouts
205200
execute :get_timeouts
206201
end
207202

208-
# Port from MJSONWP
209-
def session_capabilities
210-
::Appium::Core::Base::Capabilities.json_create execute(:get_capabilities)
211-
end
212-
213203
# For Appium
214204
# override
215205
def element_displayed?(element)

lib/appium_lib_core/common/base/driver.rb

-95
Original file line numberDiff line numberDiff line change
@@ -913,101 +913,6 @@ def get_timeouts
913913
@bridge.get_timeouts
914914
end
915915

916-
# Retrieve the capabilities of the specified session.
917-
# It's almost same as +@driver.capabilities+ but you can get more details.
918-
#
919-
# @return [Selenium::WebDriver::Remote::Capabilities, Selenium::WebDriver::Remote::Capabilities]
920-
#
921-
# @example
922-
# @driver.session_capabilities
923-
#
924-
# #=> uiautomator2
925-
# # <Selenium::WebDriver::Remote::Capabilities:0x007fa38dae1360
926-
# # @capabilities=
927-
# # {:browser_name=>nil,
928-
# # :browser_version=>nil,
929-
# # :platform_name=>"android",
930-
# # :page_load_strategy=>nil,
931-
# # :remote_session_id=>nil,
932-
# # :accessibility_checks=>nil,
933-
# # :profile=>nil,
934-
# # :rotatable=>nil,
935-
# # :device=>nil,
936-
# # "platform"=>"LINUX",
937-
# # "webStorageEnabled"=>false,
938-
# # "takesScreenshot"=>true,
939-
# # "javascriptEnabled"=>true,
940-
# # "databaseEnabled"=>false,
941-
# # "networkConnectionEnabled"=>true,
942-
# # "locationContextEnabled"=>false,
943-
# # "warnings"=>{},
944-
# # "desired"=>
945-
# # {"platformName"=>"android",
946-
# # "automationName"=>"uiautomator2",
947-
# # "app"=>"/path/to/app/api.apk.zip",
948-
# # "platformVersion"=>"8.1.0",
949-
# # "deviceName"=>"Android Emulator",
950-
# # "appPackage"=>"io.appium.android.apis",
951-
# # "appActivity"=>"io.appium.android.apis.ApiDemos",
952-
# # "someCapability"=>"some_capability",
953-
# # "automationName"=>"uiautomator2",
954-
# # "app"=>"/path/to/app/api.apk.zip",
955-
# # "platformVersion"=>"8.1.0",
956-
# # "deviceName"=>"emulator-5554",
957-
# # "appPackage"=>"io.appium.android.apis",
958-
# # "appActivity"=>"io.appium.android.apis.ApiDemos",
959-
# # "someCapability"=>"some_capability",
960-
# # "deviceUDID"=>"emulator-5554",
961-
# # "deviceScreenSize"=>"1080x1920",
962-
# # "deviceScreenDensity"=>420,
963-
# # "deviceModel"=>"Android SDK built for x86",
964-
# # "deviceManufacturer"=>"Google",
965-
# # "pixelRatio"=>2.625,
966-
# # "statBarHeight"=>63,
967-
# # "viewportRect"=>{"left"=>0, "top"=>63, "width"=>1080, "height"=>1731}}>
968-
# #
969-
# #=> XCUITest
970-
# # <Selenium::WebDriver::Remote::Capabilities:0x007fb15dc01370
971-
# # @capabilities=
972-
# # {:browser_name=>"UICatalog",
973-
# # :browser_version=>nil,
974-
# # :platform_name=>"ios",
975-
# # :page_load_strategy=>nil,
976-
# # :remote_session_id=>nil,
977-
# # :accessibility_checks=>nil,
978-
# # :profile=>nil,
979-
# # :rotatable=>nil,
980-
# # :device=>"iphone",
981-
# # "udid"=>"DED4DBAD-8E5E-4AD6-BDC4-E75CF9AD84D8",
982-
# # "automationName"=>"XCUITest",
983-
# # "app"=>"/path/to/app/UICatalog.app",
984-
# # "platformVersion"=>"11.4",
985-
# # "deviceName"=>"iPhone Simulator",
986-
# # "useNewWDA"=>true,
987-
# # "useJSONSource"=>true,
988-
# # "someCapability"=>"some_capability",
989-
# # "sdkVersion"=>"11.4",
990-
# # "CFBundleIdentifier"=>"com.example.apple-samplecode.UICatalog",
991-
# # "pixelRatio"=>2,
992-
# # "statBarHeight"=>23.4375,
993-
# # "viewportRect"=>{"left"=>0, "top"=>47, "width"=>750, "height"=>1287}}>
994-
#
995-
def session_capabilities
996-
@bridge.session_capabilities
997-
end
998-
999-
# Returns available sessions on the Appium server
1000-
#
1001-
# @return [[Hash]]
1002-
#
1003-
# @example
1004-
#
1005-
# @driver.sessions #=> [{'id' => 'c363add8-a7ca-4455-b9e3-9ac4d69e95b3', 'capabilities' => { capabilities as Hash }}]
1006-
#
1007-
def sessions
1008-
@bridge.sessions
1009-
end
1010-
1011916
# Image Comparison
1012917
def match_images_features(first_image:,
1013918
second_image:,

lib/appium_lib_core/common/command.rb

-5
Original file line numberDiff line numberDiff line change
@@ -157,10 +157,6 @@ module Commands
157157

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

160-
# Add OSS commands to W3C commands. We can remove them if we would like to remove them from W3C module.
161-
### Session capability
162-
get_capabilities: [:get, 'session/:session_id'],
163-
164160
### rotatable
165161
get_screen_orientation: [:get, 'session/:session_id/orientation'],
166162
set_screen_orientation: [:post, 'session/:session_id/orientation'],
@@ -184,7 +180,6 @@ module Commands
184180
###
185181

186182
# common
187-
get_all_sessions: [:get, 'sessions'],
188183
available_contexts: [:get, 'session/:session_id/contexts'],
189184
set_context: [:post, 'session/:session_id/context'],
190185
current_context: [:get, 'session/:session_id/context'],

lib/appium_lib_core/common/log.rb

+1-3
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,7 @@ def available_types
4444

4545
# @since Appium 1.16.0
4646
#
47-
# Logs a custom event. The event is available via {::Appium::Core::Events#get} or
48-
# <code>@driver.session_capabilities['events']</code> with <code>eventTimings</code> capabilities.
47+
# Logs a custom event. The event is available via {::Appium::Core::Events#get}.
4948
#
5049
# @param [String] vendor The vendor prefix for the event
5150
# @param [String] event The name of event
@@ -54,7 +53,6 @@ def available_types
5453
# @example
5554
#
5655
# @driver.logs.event vendor: 'appium', event: 'funEvent'
57-
# @driver.session_capabilities['events'] #=> {...., 'appium:funEvent' => 1572957315}
5856
#
5957
# @driver.logs.event = { vendor: 'appium', event: 'anotherEvent' }
6058
# @driver.logs.events #=> {...., 'appium:funEvent' => [1572957315, 1572960305],

test/functional/android/webdriver/device_test.rb

-5
Original file line numberDiff line numberDiff line change
@@ -134,11 +134,6 @@ def test_network_connection
134134
# TODO: depends on selenium-webdriver. Test failed with webdriver 3.11.0 with a number.
135135
assert @driver.network_connection_type = :all
136136
end
137-
138-
def test_session_capability
139-
# with eventTimings
140-
assert !@driver.session_capabilities['events']['commands'].nil?
141-
end
142137
end
143138
end
144139
end

test/functional/ios/webdriver/device_test.rb

-5
Original file line numberDiff line numberDiff line change
@@ -149,11 +149,6 @@ def test_logs
149149
assert @@driver.logs.get(:syslog)
150150
end
151151

152-
def test_session_capability
153-
# with eventTimings
154-
assert !@@driver.session_capabilities['events']['commands'].nil?
155-
end
156-
157152
# @since Appium 1.10.0
158153
def test_screenshot_quality
159154
skip_as_appium_version '1.10.0'

test/unit/android/webdriver/w3c/commands_test.rb

-11
Original file line numberDiff line numberDiff line change
@@ -245,17 +245,6 @@ def test_active_element
245245
assert_requested(:get, "#{SESSION}/element/active", times: 1)
246246
end
247247

248-
def test_session_capabilities
249-
stub_request(:get, SESSION.to_s)
250-
.to_return(headers: HEADER, status: 200, body: { value: { sample_key: 'xxx' } }.to_json)
251-
252-
capability = @driver.session_capabilities
253-
assert capability.is_a? Selenium::WebDriver::Remote::Capabilities
254-
assert capability['sample_key'] == 'xxx'
255-
256-
assert_requested(:get, SESSION.to_s, times: 1)
257-
end
258-
259248
def test_finger_print
260249
stub_request(:post, "#{SESSION}/appium/device/finger_print")
261250
.with(body: { fingerprintId: 1 }.to_json)

test/unit/common_test.rb

+1-10
Original file line numberDiff line numberDiff line change
@@ -80,18 +80,9 @@ def test_create_session_w3c
8080
.with(body: { capabilities: { alwaysMatch: APPIUM_PREFIX_CAPS, firstMatch: [{}] } }.to_json)
8181
.to_return(headers: Mock::HEADER, status: 200, body: response)
8282

83-
stub_request(:get, 'http://127.0.0.1:4723/wd/hub/sessions')
84-
.to_return(headers: Mock::HEADER, status: 200, body: { value: [{ id: 'c363add8-a7ca-4455-b9e3-9ac4d69e95b3',
85-
capabilities: CAPS }] }.to_json)
86-
87-
driver = ::Appium::Core.for({ caps: CAPS, appium_lib: {} }).start_driver
83+
_driver = ::Appium::Core.for({ caps: CAPS, appium_lib: {} }).start_driver
8884

8985
assert_requested(:post, 'http://127.0.0.1:4723/wd/hub/session', times: 1)
90-
91-
sessions = driver.sessions
92-
assert_requested(:get, 'http://127.0.0.1:4723/wd/hub/sessions', times: 1)
93-
assert_equal 1, sessions.length
94-
assert_equal 'c363add8-a7ca-4455-b9e3-9ac4d69e95b3', sessions.first['id']
9586
end
9687

9788
def test_create_session_w3c_with_http_package

0 commit comments

Comments
 (0)