1

I'm writing automated UI tests using Robot Framework with python. I'm testing a Polymer application that uses the shadow dom Robot's standard libraries don't seem to be able to locate elements in the shadow dom using xpath.

I've been sorting through selenium's repo/overflow/internets and polymer's repo/overflow/internets and haven't found the intersection of a solution for using robot with python (the selenium workaround isn't that graceful either). I was hoping someone had run into this issue with this specific framework that might be willing to share a solution (or note that there's not one).

Test Case

Wait Until Page Contains Element xpath=(//html/body/some-root-shadow-dom-element/input)

This of course results in an error because the shadow dom is not put into the main document of the DOM tree.

arturobelano
  • 135
  • 14
  • Not in a single xpath like that because they're in different documents. [Here's an answer](https://stackoverflow.com/questions/57367383/why-does-targeting-shadow-dom-elements-fail-at-the-5th-element#57368078) that might help but it uses css not xpath – pguardiario Sep 18 '19 at 02:06
  • Check [this](https://stackoverflow.com/questions/56380091/how-to-interact-with-the-elements-within-shadow-root-open-while-clearing-brow/56381495#56381495) for the solution and detailed explanation. – supputuri Sep 18 '19 at 02:50

1 Answers1

0

Open the browser console and type this into the console:

dom:document.querySelector("apply-widget").shadowRoot.querySelectorAll("div)

Make sure to hit enter after so it will be ran.

James Risner
  • 5,451
  • 11
  • 25
  • 47