Shadow DOM feature of HtmlUnit doesn't appear to work
See original GitHub issueHtmlUnitDriver 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
Issue Analytics
- State:
- Created 3 years ago
- Comments:12 (3 by maintainers)
Top Results From Across the Web
The javascript engine of htmlunit can't load the generated ...
I am trying to get content of script-generated web page but unfortunately HtmlUnit doesn't seem to work properly. I think the problem is...
Read more >Not rendering shadow dom elements · Issue #430 - GitHub
I am working on a new project using polymer webcomponents. The problem is that html2canvas is not rendering the shadow dom.
Read more >Test your elements - Polymer Project
This guide shows you the basics of using Polymer CLI to run unit tests, and how to accomplish various tasks and scenarios using...
Read more >Working with Shadow DOM Elements using Webdriver
When we try to find Shadow DOM elements using selenium locators, it will throw 'NoSuchElementException'. To access these Shadow DOM elements ...
Read more >Elemental - [GWT] -
Elemental is a new library for fast, lightweight, and “to the metal” web programming in GWT. It's intended for developers who are comfortable...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Have written some words - more will follow (see my last commit).
No idea - i expect we can use the same classes as base classes as we have for the real dom.
Maybe you can start with ShadowRoot as subclass of DocumentFragment and DomShadowRoot as subclass of DomDocumentFragment.
@rbri I’ve started a pull request in my fork of the HtmlUnit project: https://github.com/sbabcoc/htmlunit/pull/1