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
Will allow to open a new window in case the current window context is invalid.
🔧 Implementation Notes
The try-catch block is not needed, either the switch to the new window fails and we should stay at the old window or the switch to the new window passes, no need to try to switch back to the old window.
🤖 AI assistance
No substantial AI assistance used
AI assisted (complete below)
Tool(s):
What was generated:
I reviewed all AI output and can explain the change
1. The Java window test now fails✓ Resolved📘 Rule violation≡ Correctness
Description
newWindow no longer calls getWindowHandle(), but canHandleSwitchToNewWindowCommand still
requires GET_CURRENT_WINDOW_HANDLE before SWITCH_TO_NEW_WINDOW in its verified sequence.
Whenever the unit test runs, ordered interaction verification encounters the new-window command
while expecting the removed lookup, so it fails before covering window creation from an invalid or
closed current context.
The changed implementation begins with SWITCH_TO_NEW_WINDOW and then sends SWITCH_TO_WINDOW,
while the existing unit test still expects GET_CURRENT_WINDOW_HANDLE first. Because
verifyCommands performs strict, ordered Mockito verification and rejects missing or unexpected
interactions, this sequence mismatch makes the test fail; meanwhile, the available browser test
covers only a valid current context rather than the regression case where the active window has been
closed.
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution
## Issue description
The Java unit test for opening a new window still expects the removed current-window-handle lookup, causing strict ordered command verification to fail.
## Issue Context
`RemoteWebDriver.newWindow` now sends `SWITCH_TO_NEW_WINDOW` followed by `SWITCH_TO_WINDOW` without first requesting `GET_CURRENT_WINDOW_HANDLE`. Update the existing unit-test expectation to match that sequence, and add regression coverage for opening a new window after the active window has been closed or the current context is otherwise invalid, if supported by the fixture; the available browser test currently covers only a valid current context.
## Fix Focus Areas
- java/test/org/openqa/selenium/remote/RemoteWebDriverUnitTest.java[314-326]
- java/test/org/openqa/selenium/WindowSwitchingTest.java[100-115]
- java/src/org/openqa/selenium/remote/RemoteWebDriver.java[1345-1349]
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
Context sources
Review mode: ⚖️ Balanced: This is a localized runtime change in WebDriver window-switching error handling, where exception and session-state behavior can affect a core API contract.
Tip of the day
💡 Did you know, you can tweak Display preferences with a live preview to see your comment before it ships
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
Fixes #17754
💥 What does this PR do?
Will allow to open a new window in case the current window context is invalid.
🔧 Implementation Notes
The try-catch block is not needed, either the switch to the new window fails and we should stay at the old window or the switch to the new window passes, no need to try to switch back to the old window.
🤖 AI assistance
💡 Additional Considerations
🔄 Types of changes