fix(contexts): detect the browser's implicit context and create targets in it without id - #627
Merged
Merged
Conversation
…ts in it without id Connecting to a browser that came up with its own startup window, raised `Failed to find browser context with id` on the first `create_page`. That window lives in the browser's implicit context, which Chrome below 145 refuses to address by id. We now detect the implicit context up front as the context holding targets that `Target.getBrowserContexts` doesn't report, since that reports only contexts created through `Target.createBrowserContext`, and create targets in it the way Chrome expects, by omitting `browserContextId`. `Target.getBrowserContexts` covers every client driving the browser, so a context another Ferrum created in it is never mistaken for the implicit one. `Ferrum::Context#implicit?` tells the two apart. The implicit context is never disposed, so `#reset` leaves such a browser's startup window and cookies alone; launch the remote browser with --no-startup-window to get a context of our own that `#reset` can clean up. Closes #578
route
force-pushed
the
fix/implicit-browser-context
branch
from
September 1, 2026 16:37
245233a to
4e3c3ec
Compare
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.
Connecting to a browser that came up with its own startup window, raised
Failed to find browser context with idon the firstcreate_page. That window lives in the browser's implicit context, which Chrome below 145 refuses to address by id.We now detect the implicit context up front as the context holding targets that
Target.getBrowserContextsdoesn't report, since that reports only contexts created throughTarget.createBrowserContext, and create targets in it the way Chrome expects, by omittingbrowserContextId.Target.getBrowserContextscovers every client driving the browser, so a context another Ferrum created in it is never mistaken for the implicit one.Ferrum::Context#implicit?tells the two apart. The implicit context is never disposed, so#resetleaves such a browser's startup window and cookies alone; launch the remote browser with --no-startup-window to get a context of our own that#resetcan clean up.Closes #578