Last active
September 9, 2018 17:48
-
-
Save codesorter2015/51c3df12459753f239d9d8415e64c773 to your computer and use it in GitHub Desktop.
example of using puppeteer frames
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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