Skip to content

fix: support symbol webSocketUrl capability for BiDiBridge and guard nil bidi on close - #729

Merged
KazuCocoa merged 2 commits into
appium:masterfrom
hoanle0126:fix/bidi-bridge-symbol-capability-and-nil-close
Oct 27, 2026
Merged

KazuCocoa merged 2 commits into
appium:masterfrom
hoanle0126:fix/bidi-bridge-symbol-capability-and-nil-close

Conversation

@hoanle0126

Copy link
Copy Markdown
Contributor

Proposed changes

Appium::Core::Base::Capabilities preserves the input key type when initialized from a hash (e.g., webSocketUrl: true as shown in the BiDiBridge documentation example, or web_socket_url: true), whereas Driver#create_bridge only checked capabilities['webSocketUrl']. When webSocketUrl was passed as a symbol key, @has_bidi remained false and Bridge was used instead of BiDiBridge.

Additionally, if BiDiBridge#create_session completed without a webSocketUrl in the server response (leaving @bidi as nil), BiDiBridge#quit and BiDiBridge#close raised NoMethodError when calling bidi.close.

This PR:

  • Checks 'webSocketUrl', :webSocketUrl, 'web_socket_url', and :web_socket_url when determining @has_bidi in Driver#create_bridge.
  • Uses safe navigation (bidi&.close) in BiDiBridge#quit and BiDiBridge#close.

Testing

  • bundle exec rake rubocop
  • bundle exec rake steep
  • UNIT_TEST=true bundle exec rake test:unit TEST=test/unit/driver_test.rb

@hoanle0126
hoanle0126 requested a review from KazuCocoa as a code owner October 26, 2026 08:28
def bidi_enabled?(capabilities)
return false unless capabilities

['webSocketUrl', :webSocketUrl, 'web_socket_url', :web_socket_url].any? { |key| capabilities[key] }

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're going to remove the snack_case conversion in #674, so this don't be full modifications. bidi_enabled? can be removed

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated to inline (capabilities['webSocketUrl'] || capabilities[:webSocketUrl]) and removed bidi_enabled? — thanks @KazuCocoa!

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 = bidi_enabled?(capabilities)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
@has_bidi = bidi_enabled?(capabilities)
@has_bidi = capabilities && (capabilities['webSocketUrl'] || capabilities[:webSocketUrl]) ? true : false

@KazuCocoa
KazuCocoa merged commit d104352 into appium:master Oct 27, 2026
27 of 32 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants