Support for Multi Level Shadow DOM Elements in Selenium

175 views
Skip to first unread message

Sushma J

unread,
May 6, 2021, 3:21:09 AM5/6/21
to Selenium Users
Hello everyone, 
I have been using Selenium for automating test cases in java. Currently, we are trying to automate testcases for a website which uses multi-level shadow dom elements with nesting and the regular Xpath commands  do not work . Instead I am using JavaScriptExecutor for accessing the shadow DOM elements. But it becomes very difficult to manage because if any of the shadow-roots in the chain is removed, the code has to be modified. Can you let me know if there's any support from Selenium in the new version Selenium 4 for the same or will any support be provided in future release versions?

Thanks in advance!

Serguei Kouzmine

unread,
May 23, 2021, 10:44:22 PM5/23/21
to Selenium Users

Check third  party projects e.g. https://github.com/sergueik/shadow-automation-selenium
that returns  the shadow element resultsas regular elements e.g.:
```
 Shadow shadow = new Shadow(driver);
        WebElement element = shadow.findElement("paper-tab[title='Settings']")
```

Suriya Elamparithy

unread,
Apr 20, 2023, 5:13:57 AM4/20/23
to Selenium Users
Reply all
Reply to author
Forward
0 new messages