简体   繁体   中英

How to handle Shadow-dom elements using selenium Webdriver for Firefox

I'm testing an application using java-selenium Webdriver where there are some shadow-dom elements. How can I test them for Firefox driver?

I tried the following code

WebElement ele = (WebElement) ((JavascriptExecutor)driver).executeScript("return arguments[0].shadowRoot",element);
return ele;

This works for Chrome. But for Firefox, I get a "Javascript Exception: Cyclic object error". Could you please help

Not a fix, but as a work around..

Instead of "return arguments[0].shadowRoot" use "return arguments[0].shadowRoot.children" This will return a collection of the root nodes and you can index or use your favorite collection query method to move forward.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM