Skip to content
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

[🐛 Bug]: Regression in closed shadow root access with Chrome Beta 131 #14631

Closed
GaurangTandon opened this issue Oct 21, 2024 · 6 comments
Closed
Labels
G-chromedriver Requires fixes in ChromeDriver

Comments

@GaurangTandon
Copy link

GaurangTandon commented Oct 21, 2024

What happened?

Here's a video showing the issue: https://www.loom.com/share/1101be1e1c1a4770a439cf0041c5c882

Plain text output log for your convenience:

(venv) venv➜  test-selenium python runtest.py
Chrome 130.0.6723.59 (Official Build) (arm64)
Got exception while accessing inside closed shadow root
(venv) venv➜  test-selenium python runtest.py
Chrome 131.0.6778.3 (Official Build) beta (arm64)
Got text from inside closed shadow root inner text

Based on how Selenium has always behaved, I believe this new behavior on Chrome 131 is a regression. Running document.getElementById('root').shadowRoot still returns null in Chrome 131, so I think this might be a Selenium issue rather than Chrome issue. Please do let me know if it's otherwise and I will report it on bugs.chromium.org/p/chromedriver

How can we reproduce the issue?

Python code:

from selenium import webdriver
from selenium.webdriver.chrome.service import Service as ChromeService
from selenium.webdriver.common.by import By
 
options = webdriver.ChromeOptions()
options.add_argument("--disable-features=ChromeWhatsNewUI,PrivacySandboxSettings4")
options.add_argument("--disable-search-engine-choice-screen")
options.binary_location = '/Applications/Google Chrome Beta.app/Contents/MacOS/Google Chrome Beta'

driver = webdriver.Chrome(service=ChromeService(), options=options)

driver.get('chrome://version')
try:
  print('Chrome', driver.find_element(By.ID, 'version').text)
  driver.get('file:///Users/blazegt/test-selenium/test.html')
  root = driver.find_element(By.ID, 'root')
  shadow_root = root.shadow_root
  inner = shadow_root.find_element(By.ID, 'inner')
  print('Got text from inside closed shadow root', inner.text)
except:
  print('Got exception while accessing inside closed shadow root')

HTML file:

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Shadow root</title>
</head>

<body>
    <div id="root"></div>
    <script>
        const shadow = root.attachShadow({ mode: 'closed', });
        const inner = document.createElement('inner');
        inner.id = 'inner';
        inner.textContent = 'inner text';
        shadow.appendChild(inner);
    </script>
</body>

</html>

Install selenium and run python runtest.py two times, once with the binary_location set to Chrome beta (as it is right now) and other without it (so it runs stable version). The video shows the step clearly.

Relevant log output

When I put

logger = logging.getLogger('selenium')
logger.setLevel(logging.DEBUG)

at the top of the Python file above, I don't get any logs output on the terminal.

Operating System

macOS

Selenium version

4.25.0

What are the browser(s) and version(s) where you see this issue?

Chrome 131 beta

What are the browser driver(s) and version(s) where you see this issue?

(automatically downloaded by Selenium)

Are you using Selenium Grid?

No response

Copy link

@GaurangTandon, thank you for creating this issue. We will troubleshoot it as soon as we can.


Info for maintainers

Triage this issue by using labels.

If information is missing, add a helpful comment and then I-issue-template label.

If the issue is a question, add the I-question label.

If the issue is valid but there is no time to troubleshoot it, consider adding the help wanted label.

If the issue requires changes or fixes from an external project (e.g., ChromeDriver, GeckoDriver, MSEdgeDriver, W3C), add the applicable G-* label, and it will provide the correct link and auto-close the issue.

After troubleshooting the issue, please add the R-awaiting answer label.

Thank you!

@navin772
Copy link
Contributor

@GaurangTandon thanks for reporting this issue.

I was able to reproduce this issue with Google Chrome Beta (131), but since this issue doesn't occurs in Chrome stable with selenium, we cannot currently say that it's a selenium issue.
I think you should go ahead and post this in chromedriver issues. I will recheck this again when Chrome 131 stable is launched.

@GaurangTandon
Copy link
Author

Sure I have posted it on Chromedriver bugs now also: https://issues.chromium.org/issues/375892677

@diemol diemol added G-chromedriver Requires fixes in ChromeDriver and removed I-defect needs-triaging labels Nov 5, 2024
Copy link

github-actions bot commented Nov 5, 2024

Hi, @GaurangTandon.
This issue has been determined to require fixes in ChromeDriver.

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.
Feel free to comment the issues that you raise back in this issue. Thank you.

@github-actions github-actions bot closed this as completed Nov 5, 2024
@navin772
Copy link
Contributor

This is the intended behaviour since Chrome 131. Webdriver can now search for closed shadow roots as per - https://chromium-review.googlesource.com/c/chromium/src/+/5923865

@diemol
Copy link
Member

diemol commented Nov 27, 2024

@whimboo helped me to understand that returning something when the shadow root is null is an error, as step 5 says: https://w3c.github.io/webdriver/#get-element-shadow-root

I will comment on the Chromium bug report as it is still valid.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
G-chromedriver Requires fixes in ChromeDriver
Projects
None yet
Development

No branches or pull requests

3 participants