
Description
query-selector-shadow-dom is a small JavaScript library from the WebdriverIO project that lets you use querySelector-style syntax to find elements inside nested shadow DOM roots, without having to know the full path through each shadow root. It exposes querySelectorDeep, which returns the first match, querySelectorAllDeep, which returns all matches, and collectAllElementsDeep, which gathers every element on the page including those inside shadow roots. Both query methods accept an optional starting node, so you can search from a point inside the page. A WebdriverIO plugin adds a custom selector strategy. The project notes that it was written for test environments and tools such as WebDriver, Playwright and Puppeteer, and that production use is not advised. Known limits include that result order follows the query rather than the page order when a query has several comma-separated selectors. Firefox setValue does not work through it, and the README says Safari support is poor. Puppeteer has had built-in shadow DOM selectors since version 5.4.0.…
Highlights
- querySelectorDeep and querySelectorAllDeep
- Finds elements in nested shadow roots
- WebdriverIO custom selector plugin
- Built for test tools, not production code
Ratings & Reviews
No ratings yet
Be the first to rate query-selector-shadow-dom.
People also visit

shadow-dom-testing-library
An extension of DOM-testing-library to provide hooks into the shadow dom
query-selector-shadow-dom FAQ
What does query-selector-shadow-dom do?
It finds elements that sit inside one or more nested shadow DOM roots using ordinary querySelector-style selectors.
Which functions does it provide?
querySelectorDeep for the first match, querySelectorAllDeep for all matches, and collectAllElementsDeep to collect every element including shadow DOM content.
Is it meant for production code?
No. The README says production use is not advised. It is for test environments and tools such as WebDriver, Playwright and Puppeteer.
Does it work in every browser?
Not fully. The README says Firefox setValue does not work and Safari support is poor.
Does Puppeteer already support this?
The README says Puppeteer has a built-in shadow DOM selector since version 5.4.0, so the library may not be needed there.
What are the best query-selector-shadow-dom alternatives?
Popular alternatives to query-selector-shadow-dom include shadow-dom-testing-library, @webcomponents/shadydom and @lwc/synthetic-shadow. See all query-selector-shadow-dom alternatives








