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:

https://github.com/SeleniumHQ/selenium/commit/9e5016d660bdec00eb7179c7344284862307231c#diff-53bbf9a76b3e18a714284bd37ffdbcb670cbf537319cdaee94aacca31bcc497d

CC @43081j, @shs96c

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

Most upvoted comments

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 getVisibleText and 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 shown set to true but that doesn’t help. Because the surrounding method passes null for whitespace and textTransform as well I also tested that but without changes.