Skip to content

[docs] ADR: windows are objects, reached through driver.windows - #17681

Open
AutomatedTester wants to merge 14 commits into
trunkfrom
adr-bidi-context-handles
Open

AutomatedTester wants to merge 14 commits into
trunkfrom
adr-bidi-context-handles

Conversation

@AutomatedTester

@AutomatedTester AutomatedTester commented Jun 15, 2026 •

Copy link
Copy Markdown
Member

Requested by David · project thread

📄 The decision, its rationale, considered options, and consequences are in the record file
this PR adds; read it there. The sections below are proposal notes and review logistics.

🔗 Related

📝 Proposal notes

  • This replaces the earlier draft in this PR. That draft kept the flat driver.browsing_context module as a compatibility surface, which 17670 decision 3 now rules out, and depended on [docs] decision: BiDi events are awaited with expect_* context managers #17671 (expect_*). Both are gone. Earlier review comments about naming and keeping the driver small are reflected in the "Considered options" section.
  • Grouped as one record because the window object, user contexts and window events share one identity and scoping model; none reads on its own.
  • Out of scope: frames as objects, workers, user prompts, and an async page model.

🗣 Discussion

  • Type name. Window reads best, but Java already has WebDriver.Window. Is Window in its own package acceptable there, or should every binding use something like BrowserWindow?
  • Default handler scope. Decision 9 follows [adr] script and logging async/event API on driver.script #17776: with no scope a handler observes every window. 17685 defaults network handlers to the current window. Is the passive-observer default right for window events?
  • Navigation events. One family with a stage field, or one family per stage?

Discussed at the TLC meetings below; see the minutes for the full discussion and attribution.

  • 2026-11-12: parts are not needed for Selenium 5; the window API's direction after Selenium 5 goes to a separate roadmap discussion.
  • 2026-11-12: unscoped handlers apply to every window.

📌 Tracking

Tracking issue: (linked on acceptance)


Generated by Claude Code

@AutomatedTester
AutomatedTester force-pushed the adr-bidi-context-handles branch from 7a177ac to 6b5f6f8 Compare June 15, 2026 09:08
@AutomatedTester AutomatedTester added the A-needs decision TLC needs to discuss and agree label Jun 15, 2026
Add user contexts (BiDi isolation unit) to the handle object model rather
than a separate record: isolated= shortcut for the common case, the
create_user_context() factory for shared partitions, session-option
inheritance, and internal/private isolation types. Rename the file to use
the PR number (17681) instead of an ADR number.
… contextCreated

Point cross-references at the PR-number filenames, add expect_popup to the
return-type change note, and list browsingContext.contextCreated (which backs
expect_page/expect_popup) in the appendix for consistency with 17671.
Add a Java handle snippet alongside the JS one, and a subsection (with a Java
example) stating that log/network events are scoped by subscription, not by the
user context: global vs contexts=[tab] vs userContexts=[uc] (latter covers
future tabs). Back it with the §3.6 subscription-matching fact in the appendix.
Aligns the record with 17670 (no protocol module on the driver), the
window-handle and user-context scoping of 17685 and 17776, and returns
objects rather than bare id strings from the new API.
@AutomatedTester AutomatedTester changed the title [docs] decision: browsing contexts are exposed as handle objects [docs] ADR: windows are objects, reached through driver.windows Oct 31, 2026
@qodo-code-review

qodo-code-review Bot commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0)

Grey Divider

Great, no issues found!

Qodo reviewed your code and found no material issues that require review

Grey Divider

Tip of the day
💡 Did you know, you can move or hide resolved findings to focus on what still needs action

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Previous reviews

Review updated until commit 3f6512d ⏭️ Skipped

Results up to commit c7dd587 ⏭️ Skipped


No changes from previous review

Results up to commit f9da341 ⏭️ Skipped


No changes from previous review

Results up to commit 67f7982 ⏭️ Skipped


No changes from previous review

Results up to commit 27d7c1f ⏭️ Skipped


No changes from previous review

Results up to commit e3f9459 ⏭️ Skipped


No changes from previous review

Results up to commit 120929d ⏭️ Skipped


No changes from previous review

Results up to commit 84e560a ⏭️ Skipped


No changes from previous review

Results up to commit 6b5dd14 ⏭️ Skipped


No changes from previous review

Results up to commit 960f84a ⏭️ Skipped


No changes from previous review

Grey Divider

Qodo Logo

@qodo-code-review

Copy link
Copy Markdown
Contributor

Code review by qodo was updated up to the latest commit f9da341

@diemol diemol left a comment

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.

The decision makes sense to me. Window objects through driver.windows fit well with #17670 and the scoping in #17685/#17776.

One process note: the README asks for "about a page", and this is around 190 lines with 9 decisions. Bundling is fine per the scoping rules, but could anything be cut down or left to the bindings to make review easier?

Narrow navigation waits to a window's own verbs and point waits for
other navigations to #17676 and user prompts to #17672. State that
closing an isolated window closes its popups and that an inherited
setting the browser cannot apply fails context creation. Add options
per sub-choice, a deprecation timeline and the Java default method,
and cut the binding table and most code samples.

Copy link
Copy Markdown
Member Author

Thanks @diemol. Everything is addressed in 67f7982. The record is down from about 190 lines to about 130: the binding table and most code samples are gone, and considered options are now one line per sub-choice. That's still more than a page, because the template's options-per-sub-choice section pulls the other way. If there's a decision you'd rather leave to the bindings, I'm happy to cut it.

The one open item is the default handler scope, discussed in the thread on decision 9.


Generated by Claude Code

@qodo-code-review

Copy link
Copy Markdown
Contributor

Code review by qodo was updated up to the latest commit 67f7982

@qodo-code-review

Copy link
Copy Markdown
Contributor

Code review by qodo was updated up to the latest commit 27d7c1f

Window event handlers follow 17776's passive-observer rule, not 17685
decision 7, since there is no request to fail. Describe 17685's default
scope correctly: bound to the window current at registration, it does
not follow switch_to and misses windows opened later.
@qodo-code-review

Copy link
Copy Markdown
Contributor

Code review by qodo was updated up to the latest commit e3f9459

@qodo-code-review

Copy link
Copy Markdown
Contributor

Code review by qodo was updated up to the latest commit 120929d

@diemol diemol left a comment

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.

Thanks, almost everything from my review is addressed, and I resolved those threads. The one thing left is the default handler scope in decision 9: we'd ship with two meanings of "no scope" (here and in #17685). I'm OK accepting this if a follow-up record to change #17685's default is filed and linked here. Is that the plan?

Page load strategy names for per-call waits, last-window close, every
user context in the list, default user context cannot be removed,
inherited settings without an override, downloads scope, Java default
methods for every new overload, and a link to the record proposing to
align 17685's unscoped default.
@qodo-code-review

Copy link
Copy Markdown
Contributor

Code review by qodo was updated up to the latest commit 84e560a

@qodo-code-review

Copy link
Copy Markdown
Contributor

Code review by qodo was updated up to the latest commit 6b5dd14

Copy link
Copy Markdown
Member Author

@diemol Yes, that's the plan. I've filed it as #18279: an unscoped network handler applies to every window in the session, superseding only the default in 17685 decision 11. Decision 9 here links to it. All eight inline comments are addressed in 84e560a and 6b5dd14.


Generated by Claude Code

@diemol diemol left a comment

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.

I am approving this as the two comments I added are simple and after addressing them, this ADR can be merged from my point of view.

@qodo-code-review

Copy link
Copy Markdown
Contributor

Code review by qodo was updated up to the latest commit 960f84a

@selenium-ci

Copy link
Copy Markdown
Member

/agentic_review

@qodo-code-review

Copy link
Copy Markdown
Contributor

Code review by qodo was updated up to the latest commit 3f6512d

@titusfortner titusfortner left a comment

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.

First, with #18299 and #18300 we don't need this to support the Python deprecation plan, so there is no urgency to approve this.

The parts Diego approved I agree with. This is essentially what Watir has always done, and (apart from activate) none of it needs BiDi:

  • a window object that carries its handle
  • opening a window without switching to it
  • window management on the window object: close, activate and switch

I also agree with a windows domain for the window handle methods and for the handler management to come.

My objection is to the rest of 3 through 6, the page commands on the window. There is no feature that requires this, and the alternative I prefer is not discussed in the ADR: the driver stores the current window handle, and users must explicitly switch to the window they want to send commands to. I don't think this precludes bindings from deciding to implement language-specific wrappers with things like Python's Context Manager that switches to the window, takes actions and switches back.

Most of the rest of this ADR pulls in scope that doesn't need to be decided here: user contexts, when navigation returns, result objects, and the navigation and download handlers.

For the browsing context handlers themselves, I have minor issues with some of the specific syntax, but maybe we should decide those for all handlers instead of just this one. Regardless, I think we need to adjust the scope before I can make more detailed requests.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-needs decision TLC needs to discuss and agree

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants