bug6172: try to quit() the Selenium web driver properly when closing all windows

This commit is contained in:
Axel Uhl
2025-10-27 10:44:20 +01:00
parent 96af40784c
commit 7faa24bbda
@@ -108,12 +108,18 @@ public class WindowManager {
}
private boolean isDriverAlive(WebDriver driver) {
try {
driver.getWindowHandles();
return true;
} catch (NoSuchSessionException | SessionNotCreatedException e) {
return false;
boolean result;
if (driver == null) {
result = false;
} else {
try {
driver.getWindowHandles();
result = true;
} catch (NoSuchSessionException | SessionNotCreatedException e) {
result = false;
}
}
return result;
}
private void setWindowMaximized(WebDriver driver) {
@@ -137,6 +143,8 @@ public class WindowManager {
public void closeAllWindows() {
forEachOpenedWindow(WebDriverWindow::close);
driver.quit();
driver = null;
}
private class ManagedWebDriverWindow extends WebDriverWindow {