Use default contexts and pages rather than creating new ones #45
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.
Description
Kernel browsers launch with a default context and page and don't play well with
newContext()/newPage(). We have a note about this in our docs. Updates the sample apps so as to not send users down the wrong path.Full context:
browser.newContext() only works when Playwright owns the browser (e.g. it was launched with chromium.launch() or when you attach with the full Playwright-protocol browserType.connect() API).
When you attach with connectOverCDP() you are talking to a running Chromium that Playwright did not launch; Chromium exposes only the existing “default” context to remote CDP clients and rejects attempts to create more contexts. The Playwright docs hint at this:
“The default browser context is accessible via browser.contexts()”
Implementation Checklist
Testing
Additional Notes
Also resolves a conflicting Pydantic dependency in the cua app