Skip to content

Instantly share code, notes, and snippets.

@SarahElson
Created April 22, 2024 07:15
How to Handle Shadow Root in Selenium Java
public WebElement fileMenu() {
final WebElement shadowHost = getDriver().findElement(By.cssSelector(".smart-ui-component"));
final SearchContext shadowRoot = shadowHost.getShadowRoot();
return shadowRoot.findElement(By.cssSelector(".smart-element .smart-menu-main-container .smart-element"));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment