Skip to content

Instantly share code, notes, and snippets.

@inoyakaigor
Last active November 18, 2021 11:51
Show Gist options
  • Save inoyakaigor/19ae0eeabf93fbfc04c368ffa17b6efa to your computer and use it in GitHub Desktop.
Save inoyakaigor/19ae0eeabf93fbfc04c368ffa17b6efa to your computer and use it in GitHub Desktop.
const puppeteer = require('puppeteer')
const { PendingXHR } = require('pending-xhr-puppeteer')
;( async () => {
const browser = await puppeteer.launch({
headless: true,
product: 'firefox',
// args,
})
const page = await browser.newPage()
// await page.setDefaultTimeout(120000) // to get error about "documentTitle" uncomment
const pendingXHR = new PendingXHR(page)
await page.goto(`https://twitter.com/halo/status/1289298976550731776?s=12`)
// Here all xhr requests are not finished
await pendingXHR.waitForAllXhrFinished()
await page.waitForSelector('article[role="article"]')
const element = await page.$('article[role="article"]')
await element.screenshot({path: 'screenshot.png'})
await browser.close()
})()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment