Skip to content

Instantly share code, notes, and snippets.

@rwinscot
Created May 23, 2018 14:29
Show Gist options
  • Select an option

  • Save rwinscot/81a078296ac9e62bd1be6c2428564675 to your computer and use it in GitHub Desktop.

Select an option

Save rwinscot/81a078296ac9e62bd1be6c2428564675 to your computer and use it in GitHub Desktop.
Screenshot HTTP 404 ( not found )
// NodeJS v8.11.1
// Puppeteer v1.4.0
// https://github.com/GoogleChrome/puppeteer/tree/v1.4.0
const browser = await puppeteer.launch();
const page = await browser.newPage();
page.on('console', msg => {
if (msg.type() == 'error' && msg.text().indexOf('404') >= 0) {
page.screenshot({path: './screenshot.png'});
}
});
await page.goto('http://www.google.com/page_does_not_exist.html', {waitUntil: 'networkidle2'});
await browser.close();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment