question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Better Support for Shadow DOM

See original GitHub issue

Since Copy JS Path has landed in Chrome DevTools, we now have a way to address nodes inside shadow DOM.

Details: https://github.com/GoogleChrome/puppeteer/issues/858#issuecomment-438540596

This, however, doesn’t simplify life much when it comes to sugar methods, such as page.click, page.select and others.

It’d be nice to have a way to address nodes in shadow DOM in these methods.

Suggestions:

  1. Teach page.click and others to accept an array of selectors. (source).
await page.select(['#container', 'select#foo'], 'value');
  1. Teach page.click and others to treat jsPaths as selectors.
await page.select("document.querySelector('body > toolbar-component > toolbar-section.left')", 'value');

cc @JoelEinbinder

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:20
  • Comments:11

github_iconTop GitHub Comments

17reactions
thernstigcommented, Feb 9, 2020

@aslushnikov Is there any planned worked for this from the Puppeteer team? Considering about %8 of page loads use custom elements (and most likely shadow dom) it feels like a prominent framework such as Puppeteer could use a more native approach 😃

17reactions
felixfbeckercommented, Mar 15, 2019

Another thing to consider that in an application where every (web)component is a shadow root, this would basically be equivalent to an exact step by step DOM path instead of a “selector”. This means you would have to update all your e2e tests every time you change anything about the DOM structure, which would be extremely annoying (no matter if it supports JS path or arrays).

Maybe another better option would be to have an option { penetrateShadowRoot: true } to the functions that would recursively dig into shadow roots.

Read more comments on GitHub >

github_iconTop Results From Across the Web

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 >
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 >
Cross Browser Compatibility Score of Shadow DOM (V1)
Shadow DOM (V1) shows a browser compatibility score of 88. This is a collective score out of 100 to represent browser support of...
Read more >
Declarative Shadow DOM - web.dev
It's best to check this.shadowRoot for any existing shadow root in your element's constructor. If there is already a value, the HTML for...
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? ... Read more about...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found