[java][bidi] Handle user prompts during BiDi navigation #17244
[java][bidi] Handle user prompts during BiDi navigation #17244krishnamohan-kothapalli wants to merge 6 commits intoSeleniumHQ:trunkfrom
Conversation
Implements get(), back(), forward(), and refresh() via BrowsingContext when webSocketUrl capability is present, falling back to Classic otherwise. Maps pageLoadStrategy to ReadinessState: normal->COMPLETE, eager->INTERACTIVE, none->NONE. Adds integration tests covering all navigation commands with BiDi enabled. Fixes SeleniumHQ#13995
- Guard BiDi path with instanceof HasBiDi check to prevent IllegalArgumentException on plain RemoteWebDriver instances - Check webSocketUrl instanceof String (not just != null) to avoid false positive on Boolean.TRUE during session setup - Handle PageLoadStrategy as both enum and String when mapping to ReadinessState to fix eager/none being silently ignored Addresses review feedback on SeleniumHQ#13995
Review Summary by QodoHandle user prompts during BiDi navigation with automatic dismissal
WalkthroughsDescription• Handle user prompts during BiDi navigation via listener • Route navigation commands (get, back, forward, refresh) through BiDi • Map pageLoadStrategy to ReadinessState for BiDi compatibility • Automatically dismiss or accept alerts per unhandledPromptBehavior capability File Changes1. java/src/org/openqa/selenium/remote/RemoteWebDriver.java
|
Code Review by Qodo
1.
|
🔗 Related Issues
💥 What does this PR do?
When navigating via BiDi (
get(),back(),forward(),refresh()), anonloadalert blocks the page from reaching its readiness state, causingbrowsingContext.navigate/traverseHistory/reloadto hang indefinitely.This fix registers a
browsingContext.userPromptOpenedlistener before eachBiDi navigation that automatically dismisses or accepts prompts according to
the
unhandledPromptBehaviorcapability (defaulting todismiss and notify).The listener is removed in a
finallyblock after navigation completes.🔧 Implementation Notes
Classic WebDriver delegated prompt handling during navigation to the browser
via the
unhandledPromptBehaviorsession capability. BiDi navigation commandsdon't have that mechanism, so we replicate it by subscribing to
browsingContext.userPromptOpenedfor the duration of each navigation call.The listener runs on the BiDi WebSocket receiver thread while
sendAndWaitblocks the caller thread — the
Connectionimplementation already handlesthis pattern safely (see the
tryLockcomment inhandleEventResponse).IGNOREbehaviour is preserved: navigation runs without a listener,leaving the alert open for the caller to handle.
💡 Additional Considerations
to replicate this behaviour for their BiDi navigation paths.
🔄 Types of changes