Web components are a fantastic way to speed up front end development and standardize design aspects across a large team. But they pose a huge problem when it comes to writing tests.
executeScript() function, you can find the element or value that is hidden by a shadow DOM and return its value or WebElement.
The easiest nut to crack (cross your fingers) is when a site has already incorporated jQuery. This will allow you to use a
$ selector to access elements within the shadow DOM. This is one of those programming problems where I spent hours working out the solution and the answer was a single line of code. Assuming you’ve named your selenium-webdriver instance
driver, you can simply run the following:
1 2 3
That’s it. Now I can access the shadow DOM.