Shadow DOM
An element inside a shadow root isn't reachable by a normal
document.querySelector — the shadow boundary blocks it.
Selenium needs to explicitly step into the shadow root; Playwright's
locator engine pierces open shadow roots automatically.
A closed shadow root is off-limits to both, by design.
Open Shadow Root
Shadow DOM boundary
How to reach the button inside
Nested Shadow Roots
Outer shadow root
How to reach the inner button
Closed Shadow Root
Closed shadow root
Try it in the console: document.getElementById('shadow-closed-host').shadowRoot
returns null here, even though the content below is visibly rendered.
Why this can't be automated normally
Shadow DOM Form Input
Shadow DOM boundary
How to fill this input