Skip to content

Shadow DOM feature of HtmlUnit doesn't appear to work #187

Description

@sbabcoc

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

No activity

Activity on this issue will appear here.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions