Skip to content

Instantly share code, notes, and snippets.

@codesorter2015
Last active September 9, 2018 17:48
Show Gist options
  • Save codesorter2015/51c3df12459753f239d9d8415e64c773 to your computer and use it in GitHub Desktop.
Save codesorter2015/51c3df12459753f239d9d8415e64c773 to your computer and use it in GitHub Desktop.
example of using puppeteer frames
const puppeteer = require('puppeteer');
(async () => {
const browser = await puppeteer.launch({headless: false});
const page = await browser.newPage();
await page.setContent('<iframe></iframe>');
// the page.frames()[0] is always a main frame.
const iframe = page.frames()[1];
// fetch the body element of the iframe
const body = await iframe.$('body');
// ...
// do something with `body`..
// ...
browser.close();
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment