Open
Description
Description
- Run below code with breakpoint on
System.out.println
- Open Developer Tools in Chrome
Browser gets closed automatically
It is reproducing with/without Selenium Grid, on Windows and Mac.
Using Chrome version 137.0.7151.41 and Selenium 4.32.0
If options.enableBiDi();
is commented, issue is not reproducing.
If
driver.switchTo().window(newWindowHandle).close();
driver.switchTo().window(currentWindowHandle);
is commented, issue is not reproducing with BiDi enabled.
Once driver.switchTo().window(newWindowHandle).close();
is executed, opening Developer Tools will cause browser to close.
Reproducible Code
ChromeOptions options = new ChromeOptions();
options.enableBiDi();
WebDriver driver = new ChromeDriver(options);
driver.get("https://www.selenium.dev");
WebElement element = driver.findElement(By.cssSelector("[href='https://opencollective.com/selenium']"));
new Actions(driver).scrollToElement(element).perform();
element.click();
String currentWindowHandle = driver.getWindowHandle();
String newWindowHandle = driver.getWindowHandles().stream()
.filter(handle -> !handle.equals(currentWindowHandle)).findFirst().get();
driver.switchTo().window(newWindowHandle).close();
driver.switchTo().window(currentWindowHandle);
System.out.println("Put breakpoint here and open Dev Tools in browser, browser will close");
Debugging Logs
https://gist.github.com/Zlaman/62c3c6ca9cecb9514e5e2ebc71a10bf1