-
-
Notifications
You must be signed in to change notification settings - Fork 8.6k
When calling webdriver.close() for the last tab, quit() the webdriver
#16714
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?
When calling webdriver.close() for the last tab, quit() the webdriver
#16714
Conversation
instead of waiting 3 seconds (which doesn't guarantee the result), just wait until sessionID becomes null. This change decreased execution time of `SessionHandlingTest` from 28 to 10 seconds!
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
Before:
Now:
🔧 Thoughts
I am not yet sure this is the right change. :)
Let it be in a "Draft" status by now.
🔄 Types of changes
PR Type
Bug fix, Enhancement
Description
Auto-quit webdriver when closing last tab instead of leaving session open
Replace hardcoded sleep with dynamic wait for session closure
Reduce SessionHandlingTest execution time from 28 to 10 seconds
Handle null window handles and improve session cleanup logic
Diagram Walkthrough
flowchart LR A["close() called"] --> B{"Last window?"} B -->|Yes| C["quit() invoked"] B -->|No| D["Return normally"] C --> E["Session ID nullified"] D --> E F["Test: sleepTight"] --> G["waitUntilBrowserFullyClosed"] G --> H["Poll until sessionId == null"]File Walkthrough
RemoteWebDriver.java
Auto-quit on last window close and improve session handlingjava/src/org/openqa/selenium/remote/RemoteWebDriver.java
close()method to return early if sessionalready closed
quit()when closing last window instead of justclosing BiDi session
before quit decision
SessionHandlingTest.java
Replace hardcoded sleeps with dynamic session closure waitsjava/test/org/openqa/selenium/SessionHandlingTest.java
sleepTight()calls withwaitUntilBrowserFullyClosed()dynamic wait method
setUp()method to verify session ID is not null before each testwaitUntilBrowserFullyClosed()helper that polls untilsession ID becomes null
shouldContinueAfterSleep()test to use assertion helpersinstead of long sleep
class