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

getText returns '' for content in shadowRoot #1417

Open
coreyfarrell opened this issue Nov 4, 2018 · 3 comments
Open

getText returns '' for content in shadowRoot #1417

coreyfarrell opened this issue Nov 4, 2018 · 3 comments

Comments

@coreyfarrell
Copy link

System

  • Version: 0.23.0
  • Platform: Linux / Fedora 28 x86_64
  • Firefox: 63.0 (64-bit)
  • Selenium: node.js, selenium-webdriver 4.0.0-alpha.1

Testcase

<html>
<body>
  <div id="test1">non-shadow</div>
  <div id="test2"></div>
  <script>
    document.getElementById('test2').attachShadow({mode:'open'}).innerHTML = 'shadow';
  </script>
</body>
</html>

When testing this page with chromedriver getText on test2 returns 'shadow', geckodriver returns '' (blank string) for the same.

Trace-level log

I'm unable to obtain this. I'm using node.js to run tests. Although node.js geckodriver is 0.21.0 I manually installed 0.23.0 and verified this is still an issue in the latest release.

@andreastt
Copy link
Contributor

This could be related to Chrome having a different shadow DOM implementation than Firefox, but it’s really very hard to tell. In theory, Chrome and Firefox should have the same getText implementation as they both use the Selenium atoms, but I don’t know if they have any additional patches to make it work with shadow DOM.

In principle, shadow DOM is not supported in WebDriver so I’m somewhat inclined to say this currently unspecified behaviour. See w3c/webdriver#1320 for a larger discussion on handling shadow DOM in WebDriver.

@coreyfarrell
Copy link
Author

I don't want to unnecessarily bother people but maybe this is a bug in Firefox itself and I should be posting something to bugzilla.mozilla.org? After all the shadow DOM implementation is still very new, if geckodriver vs chromedriver don't handle getText differently then the browser itself is the next layer?

@coreyfarrell
Copy link
Author

It seems like this behavior has changed since I posted this bug. It seems like now getText works the same for both Firefox and Chrome. If the shadowRoot has mode: 'open' I get text, if the shadowRoot is mode: 'closed' then I get nothing (reasonable IMO).

Is this the result of an intentional fix or is this a 'bug in my favor'?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants