[Feature] Native shadow DOM support
See original GitHub issueWeb Components is a growing trend and statistics show it is used more often than major libraries like React. I’ve got no statistics on how often the shadow DOM is used though. In any instance, the shadow DOM is standardized, so I would assume people will expect support out-of-the-box.
The project https://github.com/Georgegriff/query-selector-shadow-dom works perfectly for now.
const { selectorEngine } = require("query-selector-shadow-dom/plugins/playwright");
const playwright = require('playwright');
...
await playwright.selectors.register(selectorEngine, { name: 'shadow' })
...
await page.goto('chrome://downloads');
// shadow= allows a css query selector that automatically pierces shadow roots.
await page.waitForSelector('shadow=#no-downloads span', {timeout: 3000})
https://github.com/mmarkelov/jest-playwright#configuration also supports it nicely.
But seeing as it requires a new selectorEngine, means the nice selector engines like css
, xpath
and text
do not work on the shadow DOM by default.
If Playwright would support adding a penetrateShadowDOM
on a browser, browserContext or page, it would be amazing for usability.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:4
- Comments:17 (13 by maintainers)
Top Results From Across the Web
Using shadow DOM - Web Components | MDN
Shadow DOM allows hidden DOM trees to be attached to elements in the regular DOM tree — this shadow DOM tree starts with...
Read more >Shadow DOM (V1) | Can I use... Support tables for ... - CanIUse
Method of establishing and maintaining functional boundaries between DOM trees and how these trees interact with each other within a document, thus enabling ......
Read more >Shadow DOM Support - Pendo Help Center
Pendo supports Shadow DOM elements for feature tagging and page element positioning for Guides. What is a Shadow DOM? It is a web...
Read more >Shadow DOM v1 - Self-Contained Web Components
Shadow DOM allows web developers to create compartmentalized DOM and CSS for web components.
Read more >Shadow DOM Support & reusable component objects
Shadow DOM is one of the key browser features that make up web components. Web components are a really great way to build...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Just took a little look at the code changes this look fantastic! After years of trying to say to people tests shouldn’t have to care about shadow Dom boundaries and having to manually pierce shadow Dom is lame, so much so I had to write a library around it, I’m so happy that my library will be redundant in playwright 😄 excited to try it out
We definitely want to address this usecase, as it is a part of web standards. Our current approach with
>>
does not work nicely, that’s why I am changing built-in selectors to pierce shadow. We’ll likely introduce some kind of built-indeep
css selector, inspired by query-selector-shadow-dom.cc @Georgegriff