A JavaScript library that enables querySelector to pierce nested Shadow DOM roots, designed for automated testing of Web Components.
query-selector-shadow-dom is a JavaScript library that extends querySelector functionality to penetrate nested Shadow DOM boundaries. It solves the problem of accessing elements inside Web Components' shadow roots during automated testing, eliminating the need to manually traverse each shadow root layer. The library provides drop-in replacements for standard querySelector methods that work across multiple testing frameworks.
Test automation engineers and developers writing automated tests for Web Components using frameworks like Selenium, Puppeteer, Playwright, or WebdriverIO. It's particularly useful for teams building or testing component libraries with Shadow DOM encapsulation.
Developers choose this library because it dramatically simplifies test code for Shadow DOM components, reducing complex multi-step element access to single selector calls. Unlike some framework-specific solutions, it provides consistent behavior across multiple testing tools and handles deeply nested shadow roots that other methods can't reach.
querySelector that can pierce Shadow DOM roots without knowing the path through nested shadow roots. Useful for automated testing of Web Components. Production use is not advised, this is for test environments/tools such as Web Driver, Playwright, Puppeteer
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Finds elements through any number of nested shadow roots with a single CSS selector, eliminating the need for manual traversal chains as shown in the Chrome downloads example.
Offers plugins for WebdriverIO, Puppeteer, Playwright, and Protractor, making it easy to adopt in diverse test environments without rewriting existing code.
Mirrors native querySelector and querySelectorAll methods, reducing the learning curve and allowing developers to use standard CSS selectors effortlessly.
Works with Shady DOM polyfills, ensuring functionality in older browsers or environments where native shadow DOM is not fully supported.
Firefox requires workarounds for input interactions like setValue, and Safari has poor support, limiting reliable cross-browser testing out of the box.
Does not preserve the native DOM source order for results with multiple selectors, which can break tests that depend on precise element sequences, as admitted in the README.
Becomes less necessary as frameworks like Puppeteer and Playwright add native shadow DOM support, potentially adding maintenance overhead without clear benefits.