Click Element - shadowRoot

Hi.
I’m trying to point a locator of a element that is in shadowRoot tree.
I tried click on element using locator (dom:document.querySelector(“#globoads-header > globoads-header-platform”).shadowRoot.querySelector(“header > div > div.button-entrar”))

but this problem is occuring:
ElementNotInteractableException: Message: Element

could not be scrolled into view Stacktrace:

Please, can anyone help me?

Hi Rafael,

I think the key here is

Clicking an element that is hidden wouldn’t be valid as a real person wouldn’t be able to do that either (this is a testing tool after all)

  • Is there an equivalent in the “active” (non-shadowRoot tree) that you want to click? if so then you just need refine your selector to ensure it goes to the right element.
  • If this is the element you want to click then you might need to do some other activity first to make the shadowRoot tree the active tree

Note: I have seen some web apps that send a html page that has the entire app twice in the html, once was the mobile version and once was the desktop version, so if your app is like this, you might need to ensure your selectors distinguish the tree for the version you are testing otherwise you might be hitting the hidden mobile page’s element on the desktop page witch would explain this error.

Hope that helps,

Dave.

1 Like

Hi.
Thank you for your time.
Was my geckodriver version. But your point about click event is correct. In this case I used
“Execute JavaScript document.querySelector(”#globoads-header > globoads-header-platform").shadowRoot.querySelector(“header > div > div.button-entrar”).click()"

After of check if button loaded with command
“Element Text Should Be dom:document.querySelector(”#globoads-header > globoads-header-platform").shadowRoot.querySelector(“header > div > div.button-entrar”) Entrar"

Again, Thank you!

1 Like