Skip to content

Instantly share code, notes, and snippets.

@dwsmart

dwsmart/test.js

Last active Dec 6, 2019
Embed
What would you like to do?
Puppeteer Shadow Dom > Dom
const puppeteer = require('puppeteer');
const url = process.env.URL || 'https://lit-element.polymer-project.org/';
(async () => {
const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.goto(url);
await page.evaluate(() => {
// loop through elements and copy shadow to inner
for (let element of document.getElementsByTagName('*')) {
if (element.shadowRoot) element.innerHTML = element.shadowRoot.innerHTML;
}
});
let bodyHTML = await page.content();
console.log(bodyHTML);
await browser.close();
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment