Enable BiDi support for connect-existing mode#45
Closed
MayCXC wants to merge 1 commit intomozilla:mainfrom
Closed
Conversation
GeckodriverHttpDriver now requests webSocketUrl: true in the session capabilities and exposes a getBidi() method that opens a WebSocket to Firefox's Remote Agent. This allows ConsoleEvents and NetworkEvents (which depend on BiDi subscriptions) to work when using --connect-existing, without going through selenium-webdriver's createSession() which hangs during BiDi auto-upgrade. The BiDi WebSocket is opened lazily on the first getBidi() call and closed on quit/kill. The subscribe() helper sends session.subscribe commands and waits for the matching response. The socket property gives ConsoleEvents and NetworkEvents direct access to the event stream, matching the interface they already use on the Selenium WebDriver path. No behavior change for launch mode (which continues to use selenium-webdriver with enableBidi). No behavior change for connect-existing when Firefox was not started with --remote-debugging-port (getBidi throws a clear error).
Collaborator
|
Thanks, it's great to fix the limitation with --connect-existing! I think there will be merge conflicts with #46, but it should be easy to reconcile. |
Collaborator
|
Hey @MayCXC, thanks for the PR! We just released 0.9.0 which included the PR #46 rebase, so there are merge conflicts now — but your changes are well-scoped to The approach looks correct — we verified there's no simpler built-in path in selenium-webdriver for this. Could you rebase on current |
5 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
--connect-existingmode currently disables all BiDi-dependent features (console events, network events) becauseselenium-webdriver'screateSession()hangs when trying to auto-upgrade to BiDi with an existing Firefox instance.This PR enables BiDi in connect-existing mode by:
webSocketUrl: truein the session capabilities sent to geckodriverwebSocketUrlfrom the session response (set by Firefox's Remote Agent)getBidi()method toGeckodriverHttpDriverthat opens a WebSocket to that URL and provides thesubscribe/socketinterface thatConsoleEventsandNetworkEventsalready useThe existing
hasBidicheck inindex.ts('getBidi' in driver) naturally picks up the new method, so console and network event collection work without further changes.Behavior
selenium-webdriverwithenableBidi().--remote-debugging-port: BiDi features (console, network) now work.--remote-debugging-port:getBidi()throws a clear error. All non-BiDi features continue to work as before.Changes
src/firefox/core.ts: 82 insertions, 6 deletions (all inGeckodriverHttpDriver)Test plan
tsc --noEmitpassesbun run buildsucceeds--connect-existingwith Firefox started viafirefox --marionette --remote-debugging-port 9222, verifylist_console_messagesandlist_network_requestsreturn data