Skip to main content

Posts

Showing posts from September, 2022

Shadow DOM in Selenium 4

To access Shadow DOM elements in Selenium 4 with Chromium browsers (Microsoft Edge and Google Chrome) version 96 or greater, we can use the shadow root method: WebElement  shadowIdContent  = driver.findElement(By.cssSelector("#shadow_host")) .getShadowRoot() .findElement(By.cssSelector("#shadow_content")); What happened in v96 is that Chromium has made its shadow root values compliant with the updated W3C WebDriver specification, which now includes definitions for getting an element’s shadow root and locating elements in a shadow root.   I found this excellent video for the same : https://youtu.be/-uMLqBO2x7c Enjoyed reading this article? Please share the knowledge with your friends and colleagues.