[🐛 Bug]: [bidi] Chrome is closing after opening Developer Tools
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
@Zlaman, thank you for creating this issue. We will troubleshoot it as soon as we can.
Selenium Triage Team: remember to follow the Triage Guide
I tried to connect to a local running Chrome instance over 127.0.0.1:9222 without success. Chrome Version: 136.0.7103.49 Selenium Version: 4.32.0 Error message:
selenium.common.exceptions.SessionNotCreatedException: Message: session not created: cannot connect to chrome at 127.0.0 .1:9222 from chrome not reachable Stacktrace: GetHandleVerifier [0x00007FF6DFA1A145+76773] GetHandleVerifier [0x00007FF6DFA1A1A0+76864] (No symbol) [0x00007FF6DF7D8DAC] (No symbol) [0x00007FF6DF7C9BE1] (No symbol) [0x00007FF6DF81C082] (No symbol) [0x00007FF6DF81126E] (No symbol) [0x00007FF6DF865155] (No symbol) [0x00007FF6DF864710] (No symbol) [0x00007FF6DF857133] (No symbol) [0x00007FF6DF8204D1] (No symbol) [0x00007FF6DF821263] GetHandleVerifier [0x00007FF6DFCDA8ED+2962317] GetHandleVerifier [0x00007FF6DFCD4EC2+2939234] GetHandleVerifier [0x00007FF6DFCF2FF3+3062419] GetHandleVerifier [0x00007FF6DFA34B9A+185914] GetHandleVerifier [0x00007FF6DFA3C78F+217647] GetHandleVerifier [0x00007FF6DFA22A44+111844] GetHandleVerifier [0x00007FF6DFA22BF2+112274] GetHandleVerifier [0x00007FF6DFA08A79+5401] BaseThreadInitThunk [0x00007FFC753F84D4+20] RtlUserThreadStart [0x00007FFC75C61A11+33]
It looks like the Chrome update has broken the connection to the driver again, as it happend some weeks ago.
Heads up: This issue is reproducible in 4.33.0 as well RCA: The following line of code is causing the issue - options.enableBiDi(); , which actually interferes with DevTools and may cause socket resets. Logs gist : https://gist.github.com/Tanuj-Kandpal/08235e45f7e549652ad86a1206e8cdb5
The following piece of code needs improvement, please correct me if I'm wrong -
This bug is not reproducing on Chrome 142.0.7444.60 It was not related to Selenium