selenium: [🐛 Bug]: "Get Text" atom returns an empty string for elements within a closed ShadowDOM
What happened?
Originally filed as a geckodriver issue: https://github.com/mozilla/geckodriver/issues/2097
Since Firefox 108 the Get Text atom only returns an empty string for elements inside of a ShadowDOM. Over on https://bugzilla.mozilla.org/show_bug.cgi?id=1824664 I’ve made some investigations and manually reverted the changes of javascript/atoms/dom.js until the problem is gone. The causing change is the following:
How can we reproduce the issue?
A test that I was using internally with Marionette is:
self.marionette.navigate("https://opensource.adobe.com/spectrum-web-components/storybook/iframe.html?id=button-primary-fill-sizes--m&args=&viewMode=story")
button = self.marionette.find_element(By.CSS_SELECTOR, "#root-inner > sp-story-decorator:nth-child(2) > sp-button:nth-child(1)")
assert button.text == "Click Me"
Relevant log output
Nothing
Operating System
All
Selenium version
Latest
What are the browser(s) and version(s) where you see this issue?
Firefox since version 108
What are the browser driver(s) and version(s) where you see this issue?
geckodriver 0.33.0
Are you using Selenium Grid?
No
About this issue
- Original URL
- State: closed
- Created 8 months ago
- Comments: 27 (24 by maintainers)
Commits related to this issue
- "Get Text" atom has to return the visible text from an element within a closed ShadowDOM. As discussed on issue #13132 the "Get Text" atom currently fails for elements that are located within a close... — committed to whimboo/selenium by whimboo 7 months ago
- "Get Text" atom has to return the visible text from an element within a closed ShadowDOM (#13211) "Get Text" atom has to return the visible text from an element within a closed ShadowDOM. As discu... — committed to SeleniumHQ/selenium by whimboo 7 months ago
- "Get Text" atom has to return the visible text from an element within a closed ShadowDOM (#13211) "Get Text" atom has to return the visible text from an element within a closed ShadowDOM. As discu... — committed to RevealOscar/selenium by whimboo 7 months ago
i’m still super curious what the problem is so will be sure to track the other related issues
let me know if it ultimately does come back here and is a selenium problem after all
@43081j that was actually a great idea to copy all the methods and remove deps for the Google modules. It’s indeed passing for me as well when everything is executed from within the web page. As such I’ve also copied the full generated minified atom code for
getVisibleTextand used it the same way. And by surprise it works as well!So that means that something actually causes trouble for us in Firefox when we run this generated atom code in privileged code. As such I’ll go ahead and take the reduced code from your jsfiddle to try to find out what’s actually broken on our side. Work will be continued to be tracked on https://bugzilla.mozilla.org/show_bug.cgi?id=1824664.
That said it looks like that there is actually no bug in the Selenium atoms code and that we do not need to keep this issue open. Sorry for wasting your time on that issue, but on the other side also a big thank you for preparing that code that I can now easily use!
I tested with
shownset totruebut that doesn’t help. Because the surrounding method passesnullforwhitespaceandtextTransformas well I also tested that but without changes.