Skip to main content

Shadow Dom Locator Builder

an advanced application and advantage of SHAFT Locator Builder is locating elements inside shadow dom.

Example

Screenshot 2023-05-23 235203

to locate the element with tagName "a" inside the nested shadow root you can follow the below code :

 public void shadowDomLocatorTest() {
driver = new SHAFT.GUI.WebDriver();
By shadowHost = SHAFT.GUI.Locator.hasTagName("shop-app").build();
By shadowElement = SHAFT.GUI.Locator.hasTagName("a")
.hasAttribute("href", "/list/mens_outerwear")
.insideShadowDom(shadowHost)
.build();
driver.browser().navigateToURL("https://shop.polymer-project.org/");
driver.element().click(shadowElement);
}

for more examples visit ShadowDomTest on Github.