-
-
Notifications
You must be signed in to change notification settings - Fork 8.6k
#16645 switch DevTools connection between tabs/windows #16647
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: trunk
Are you sure you want to change the base?
#16645 switch DevTools connection between tabs/windows #16647
Conversation
1. When `createSessionIfThereIsNotOne(tab1)` is called, CDP session is opened - and attached to the first tab. 2. When `createSessionIfThereIsNotOne(tab2)` is called, we detach connection from the first tab, and attach to the second tab (a new CDP session ID is created). An alternative solution would be holding map of CDP sessions for all existing tabs.
PR Compliance Guide 🔍Below is a summary of compliance checks for this PR:
Compliance status legend🟢 - Fully Compliant🟡 - Partial Compliant 🔴 - Not Compliant ⚪ - Requires Further Human Verification 🏷️ - Compliance label |
||||||||||||||||||||||||
PR Code Suggestions ✨Explore these optional code suggestions:
|
||||||||||||||||||
User description
createSessionIfThereIsNotOne(tab1)is called, CDP session is opened - and attached to the first tab.createSessionIfThereIsNotOne(tab2)is called, we detach connection from the first tab, and attach to the second tab (a new CDP session ID is created).🔗 Related Issues
Fixes #16645
🔧 Implementation Notes
Current implementation holds only one CDP session at a time.
When user wants to switch to other tab, the previous CDP session gets closed.
An alternative solution would be holding map of CDP sessions for all existing tabs.
🔄 Types of changes
PR Type
Bug fix
Description
Switch DevTools CDP session between tabs/windows dynamically
Track current window handle to detect tab switches
Disconnect from previous tab and attach to new tab
Refactor session attachment logic into separate methods
Diagram Walkthrough
File Walkthrough
DevTools.java
Implement dynamic DevTools tab switching with session managementjava/src/org/openqa/selenium/devtools/DevTools.java
windowHandlefield to track current tab/window connectioncreateSessionIfThereIsNotOne()to detect tab switches andreconnect
attachToWindow()andattachToTarget()methods@Nullableand@NonNullannotations for better null-safetywindowHandlewhen disconnecting session