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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
[馃悰 Bug]: driver.execute_script() does not work with chromedriver/msedgedriver v96 - return dict and not WebDriver object #10019
Comments
@fenchu, thank you for creating this issue. We will troubleshoot it as soon as we can. Info for maintainersTriage this issue by using labels.
If information is missing, add a helpful comment and then
If the issue is a question, add the
If the issue is valid but there is no time to troubleshoot it, consider adding the
After troubleshooting the issue, please add the Thank you! |
I have tried to recreate it, I don't have chrome 96, but the following worked with Chrome 95. >>> driver.get("https://www.trk.qa-04.buypass.no/key-registration")
>>> el = driver.find_element(By.XPATH, "//bp-button[@text='Buypass ID']")
>>> shadow_root = driver.execute_script(f"return arguments[0].shadowRoot", el)
>>> shadow_root
<selenium.webdriver.remote.webelement.WebElement (session="a46ecc2a0b50436187cb24175222129a", element="f6839afa-c89f-449d-8892-943c1e38bf06")>
>>> shadow_root.find_element(By.CSS_SELECTOR, "button").click()
>>> driver.quit() Please log chromedriver issues with the chromedriver project. https://sites.google.com/a/chromium.org/chromedriver/help Please be sure to include a completely reproducible test script for them, without a way to reproduce the issue you are seeing there is no good way for them to fix the problem. A reproducible test script includes a WebDriver script and a link to the page in question. If you can not provide a link, create one using jsfiddle.net |
please can you link to the issue when you have raised it in the chromium bug tracker |
Seems it is the chromedriver v96 only, I can run chrome v96 with chromedriver v95 and it works fine. submittet chromium bug: https://bugs.chromium.org/p/chromedriver/issues/detail?id=3948 |
This doesn't seem like a Chromedriver bug for me. It returns the expected response: a shadow element reference, e.g.:
I just implemented the shadow commands defined in the spec in this WebdriverIO PR and it allows me to fetch shadow elements using // open example page
await browser.url('chrome://downloads')
const element = await browser.findElement('tag name', 'downloads-manager')
// get shadow root either using execute command
const shadowRoot = await browser.execute(
(elem) => elem.shadowRoot, element)
// or get shadow root with the protocol command
const shadowRoot = await browser.getElementShadowRoot(
element['element-6066-11e4-a52e-4f735466cecf']
)
// fetch element within that shadow root
const elementRef = await browser.findElementFromShadowRoot(
shadowRoot['shadow-6066-11e4-a52e-4f735466cecf'],
'css selector',
'#no-downloads span'
)
console.log(await browser.$(elementRef).getText());
// returns "Files you download appear here" |
Thanks for that @christian-bromann , we realised that in the TLC meeting yesterday and I will be getting this sorted for 4.1 |
So there is no workaround until this is fixed in selenium 4.1?, |
Can confirm that the problem exists with Chrome v96, but not in Chrome v95. If you happen to be on a Debian based system, the following might work to downgrade Chrome: CHROME_VERSION=95.0.4638.69-1
wget --no-verbose -O /tmp/chrome.deb https://dl.google.com/linux/chrome/deb/pool/main/g/google-chrome-stable/google-chrome-stable_${CHROME_VERSION}_amd64.deb
sudo apt remove -y google-chrome-stable
sudo apt install -y /tmp/chrome.deb |
we can confirm this problem with chromedriver 96, all fine with driver 95.x on newest chrome-browser 96.x my workaround at the moment is to use or downgrade to version 95.0.4638.69. good on this constellation is that we got no (error-)message like hope the next stable of chromium-browser 97 is also compatible to chromedriver 95 or |
Fixed in 0c10993 for python. |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
What happened?
After updating chrome and/or msedge to v96, driver.execute_script() no longer works it returns a dict(hash) instead of webDriver element:
I need to execute a shadowRoot pseudo-element in order to get the properties inside the element.
I think there are changes in the browser driver that prevent this from working,
I think this can be reproduceable with any pseudo-elements that needs javascript executing.
I've tried all combinations of:
Current workaround is not updating beyond v95 of chrome/msedge
How can we reproduce the issue?
Relevant log output
chrome v96 does not work:
msedgev97 does not work:
Operating System
windows10, ubuntu20.04LTS
Selenium version
4.0.0
What are the browser(s) and version(s) where you see this issue?
Chrome96, MSEdge96, MSEdge97
What are the browser driver(s) and version(s) where you see this issue?
chromedriverVersion: '96.0.4664.35, msedgedriverVersion: 97.0.1060.2
Are you using Selenium Grid?
Na
The text was updated successfully, but these errors were encountered: