HtmlUnitDriver version 2.40.0
I see evidence in the code that the shadow DOM feature is supported by HtmlUnit with version set to "chrome". When I try using this, however, it doesn't appear to actually work.
package com.nordstrom.automation.selenium.model; import org.openqa.selenium.By; import org.openqa.selenium.JavascriptExecutor; import org.openqa.selenium.MutableCapabilities; import org.openqa.selenium.WebElement; import org.openqa.selenium.htmlunit.HtmlUnitDriver; import org.testng.annotations.Test; public class FooBar { @Test public void foo() { MutableCapabilities caps = new MutableCapabilities(); caps.setCapability("browserName", "htmlunit"); caps.setCapability("browserVersion", "chrome"); caps.setCapability("javascriptEnabled", true); HtmlUnitDriver driver = new HtmlUnitDriver(caps); driver.get("file:/C:/github/Selenium-Foundation/target-s3/test-classes/ExamplePage.html"); WebElement elem = driver.findElement(By.cssSelector("div#shadow-root-a")); Object bar = ((JavascriptExecutor) driver).executeScript("return arguments[0].shadowRoot;", elem); } }
The value of [bar] comes up null