How to search for shadow-root selector in Chrome DevTools?

Viewed 724

I'm using Chrome dev tools to check my css selectors when writing E2E-Tests using Playwright (or Puppeteer).

To verify a selector is valid and can be found I use the cmd+f search-bar in Elements-Tab in DevTools like this:

found selector outside shadow-root

But how can I find selectors inside shadow-root?

no match

Just to make clear: This selector can be found via code. I just can't find it in the DevTools

1 Answers

This can be done in two stages using shadowRoot.

First assign element with shadow dom to a constant, then use querySelector to target element(s) inside shadow.

const element = document.querySelector('wc-article-editor'):
element.shadowRoot.querySelector('.myclass');
Related