Puppeteer: get full HTML content of a webpage, like innerHTML, but including any shadow roots?

Viewed 244

When browsing a page in Puppeteer, I can usually get the full HTML content as text like this:

var content = await page.evaluate( 
  () => document.querySelector('body').innerHTML );

However I'm currently dealing with a situation where there are multiple nested shadow roots. So I assume I'll have to traverse the entire DOM and check each node for any .shadowRoot available and traverse those DOMS separately.

Is there a shortcut or simpler way to do this? Like a innerHTML variant that includes any shadowroot DOMs?

0 Answers
Related