Skip to content
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
4 changes: 2 additions & 2 deletions lib/appium_lib_core/common/base/bidi_bridge.rb
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,11 @@ def refresh
def quit
super
ensure
bidi.close
bidi&.close
end

def close
execute(:close_window).tap { |handles| bidi.close if handles.empty? }
execute(:close_window).tap { |handles| bidi&.close if handles.empty? }
end

# steep:ignore:end
Expand Down
2 changes: 1 addition & 1 deletion lib/appium_lib_core/common/base/driver.rb
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def create_bridge(**opts)

raise ::Appium::Core::Error::ArgumentError, "Unable to create a driver with parameters: #{opts}" unless opts.empty?

@has_bidi = capabilities && capabilities['webSocketUrl'] ? true : false
@has_bidi = capabilities && (capabilities['webSocketUrl'] || capabilities[:webSocketUrl]) ? true : false
bridge_clzz = @has_bidi ? ::Appium::Core::Base::BiDiBridge : ::Appium::Core::Base::Bridge
# steep:ignore:start
bridge = bridge_clzz.new(**bridge_opts)
Expand Down
28 changes: 28 additions & 0 deletions test/unit/driver_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -836,6 +836,34 @@ def test_bidi_bridge
mock_bidi.verify
end

def test_bidi_bridge_with_symbol_key_and_without_server_websocket_url
response = {
value: {
sessionId: '1234567890',
capabilities: {
platformName: :android,
automationName: ENV['APPIUM_DRIVER'] || 'uiautomator2',
deviceName: 'Android Emulator'
}
}
}.to_json

stub_request(:post, 'http://127.0.0.1:4723/session')
.to_return(headers: HEADER, status: 200, body: response)

capabilities = Caps.android[:capabilities].merge(webSocketUrl: true)
core = ::Appium::Core.for capabilities: capabilities
driver = core.start_driver

assert_equal Appium::Core::Base::BiDiBridge, driver.send(:bridge).class
assert_nil driver.bidi

stub_request(:delete, 'http://127.0.0.1:4723/session/1234567890')
.to_return(headers: HEADER, status: 200, body: { value: nil }.to_json)

driver.quit
end

def test_elements
driver = android_mock_create_session

Expand Down
Loading