You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Passing a list of options (WebDriver(options=[...])) built a broken new-session payload: create_matches crashed or dropped capabilities for 3+/mixed-browser lists, and start_session double-wrapped the result.
Now alwaysMatch keeps only capabilities identical across all options (disjoint from firstMatch), and the W3C object is no longer wrapped twice.
🔧 Implementation Notes
🤖 AI assistance
No substantial AI assistance used
AI assisted (complete below)
Tool(s): Claude code
I reviewed all AI output and can explain the change
Fix W3C capability matching for option lists and avoid double-wrapping
🐞 Bug fix🧪 Tests🕐 20-40 Minutes
AI Description
• Compute W3C alwaysMatch as the true intersection across all provided options.
• Prevent start_session from re-wrapping already-formed W3C capability payloads.
• Add regressions for 3+ options and mixed-browser option lists.
Diagram
graph TD
A["Caller"] --> B["WebDriver.__init__"] --> C["create_matches(options[])" ] --> D{"W3C caps?"}
D -->|"Yes"| E["Deepcopy + add se:remoteUrl"] --> F["Execute NEW_SESSION"] --> G["Remote end"]
D -->|"No"| H["_create_caps wrapper"] --> F --> G
Loading
High-Level Assessment
The following are alternative approaches to this PR:
1. Build firstMatch entries without mutating option dicts
➕ Avoids in-place deletion of keys from dicts returned by to_capabilities()
➕ Makes the transformation more obviously side-effect free
➖ Slightly more code (need filtered copies per option)
➖ Does not materially change correctness given current usage pattern
2. Compute intersection via iterative dict filtering (reduce-style)
➕ Can be expressed compactly and generalized (progressively narrow alwaysMatch)
➖ Harder to read than the current 'compare against first set' approach
➖ Still needs explicit handling for unhashable list/dict values
Recommendation: Keep the PR’s approach: deriving alwaysMatch by validating each key/value from the first option against all others is straightforward, spec-aligned, and avoids unhashable-set pitfalls. If future contributors worry about side effects, consider a follow-up refactor to build filtered firstMatch copies instead of deleting keys in-place.
Files changed (2) +69 / -27
Bug fix (1) +26 / -27
webdriver.pyFix create_matches intersection logic and prevent W3C double-wrapping+26/-27
Fix create_matches intersection logic and prevent W3C double-wrapping
• Replaces adjacent-pair matching with a true all-options intersection for alwaysMatch, keeping non-shared capabilities in firstMatch. Updates start_session to detect an already-formed W3C capabilities object and only wrap flat capability dicts, while still injecting se:remoteUrl correctly.
new_session_tests.pyAdd regressions for multi-option firstMatch and new-session payload shape+43/-0
Add regressions for multi-option firstMatch and new-session payload shape
• Adds unit tests covering three-option lists with mixed browsers, ensuring unique capabilities remain in firstMatch and alwaysMatch only contains true common keys. Verifies that passing a list of options does not produce a double-wrapped capabilities payload in NEW_SESSION.
1. New tests lack type hints 📘 Rule violation✧ Quality
Description
Newly added test functions are missing parameter and return type annotations (e.g., mocker is
untyped and no -> None is declared). This violates the project requirement to annotate new
function signatures and reduces type-checking clarity.
PR Compliance ID 337802 requires explicit type annotations for parameters and return types on newly
added functions. The newly added tests define functions without return annotations, and
test_list_of_options_is_not_double_wrapped_in_new_session also introduces an untyped mocker
parameter.
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution
## Issue description
Newly added test functions are missing type annotations on their signatures (including a `-> None` return type, and a type for the `mocker` fixture parameter).
## Issue Context
Per the compliance checklist, all new/modified function and method signatures should have explicit parameter and return annotations.
## Fix Focus Areas
- py/test/unit/selenium/webdriver/remote/new_session_tests.py[145-145]
- py/test/unit/selenium/webdriver/remote/new_session_tests.py[159-159]
- py/test/unit/selenium/webdriver/remote/new_session_tests.py[174-174]
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
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
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.
🔗 Related Issues
💥 What does this PR do?
Passing a list of options (
WebDriver(options=[...])) built a broken new-session payload:create_matchescrashed or dropped capabilities for 3+/mixed-browser lists, andstart_sessiondouble-wrapped the result.Now
alwaysMatchkeeps only capabilities identical across all options (disjoint fromfirstMatch), and the W3C object is no longer wrapped twice.🔧 Implementation Notes
🤖 AI assistance
💡 Additional Considerations
🔄 Types of changes