-
-
Notifications
You must be signed in to change notification settings - Fork 8.5k
[🐛 Bug]: Chrome extension windows are no longer included in window_handles - Remote debugging window #15685
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
Comments
@rookes, thank you for creating this issue. We will troubleshoot it as soon as we can. Selenium Triage Team: remember to follow the Triage Guide |
Does it still work with selenium 4.29 and Chrome 136? Or were you using an older version of Chrome/ChromeDriver when it worked? |
No, 4.29 has the same issues with 136, it seems to be due to a Chrome update. I was using an older version of chrome when it worked, 135.xx |
So nothing has changed in the window handle code on the Selenium side, so this is a regression in either Chrome or Chromedriver. |
Hi, @rookes. You can see if the feature is passing in the Web Platform Tests. If it is something new, please create an issue with the ChromeDriver team. |
FWIW this has been reported here: https://groups.google.com/g/chromedriver-users/c/4367H-1kHwU Since I haven't found any official bug report I created one here: https://issues.chromium.org/issues/416666972 |
Ahah, since ChromeDriver v136, a new let driver = await new Builder()
.forBrowser("chrome")
.setChromeOptions(
new chrome.Options({
'goog:chromeOptions': {
'enableExtensionTargets': true,
}
})
.addArguments([
`load-extension=./test-extension`
])
.setChromeBinaryPath(chromeBinary)
)
.setChromeService(new chrome.ServiceBuilder(chromeDriverBinary))
.build(); See also the PSA by the ChromeDriver team and the example code here. It seems to me that this should be documented somewhere in Selenium as well, just to make life easier for others running into this issue. |
Thanks for looking into this, I'm glad it's an easy fix! So does the error calling window_handles need to be addressed? When enableExtensionTargets is off and the only windows open are extension windows, there will be an error generated (see original post for example trace). It seems like ideally this call would just return an empty list or something like that. Is that something that needs to be handled on the ChromeDriver side too? |
I had to log into my GitHub account to say that this works.
|
I personally don't think Selenium should treat this in any specific way and instead continue raising the underlying ChromeDriver error. As a developer, that exception would have probably pointed me in the right direction, whereas an empty list would have certainly caused more confusion. |
Includes a hack to enable Selenium access to extension windows. See SeleniumHQ/selenium#15685
Uh oh!
There was an error while loading. Please reload this page.
Description
When connecting to an existing session via remote debugging, Chrome extension windows are not included in driver.window_handles. This issue is new in the past few weeks, but I'm not sure exactly when it started.
To reproduce, open a chrome window with the option
--remote-debugging-port=9222
, then run the code. The code prints out the title of every window in window_handles. Note that if there is any chrome extension tab open, it will not be included. I have tested this with multiple valid extensions, extension popups, and invalid extension URLs as well. All give the same result.Example output with two tabs open: "chrome-extension://a" and the default "New Tab"
New Tab
Further, if the Chrome extension is the only tab open, then an error will be generated:
Reproducible Code
Debugging Logs
What version of Selenium are you currently using?
4.31.0
The following statements are true
Did this work for you before?
Yes this is a regression
If yes, what version of Selenium did it work with?
4.29.0
Operating System
Windows
Selenium Language Binding
Python
Which browsers are you experiencing the issue with?
Chrome
Are you using Selenium Grid?
No
The text was updated successfully, but these errors were encountered: