Skip to content

Instantly share code, notes, and snippets.

@stefanolaru
Created January 30, 2019 14:34
Show Gist options
  • Save stefanolaru/94bf904e72263ce0ae1072520cce4dca to your computer and use it in GitHub Desktop.
Save stefanolaru/94bf904e72263ce0ae1072520cce4dca to your computer and use it in GitHub Desktop.
Puppeteer Screenshot Test
'use strict';
var puppeteer = require('puppeteer');
module.exports.pptr = async (event, context) => {
puppeteer.launch().then(async browser => {
const page = await browser.newPage();
await page.setViewport({
width: 1440,
height: 1220,
deviceScaleFactor: 2
});
await page.goto('https://www.sharplaunch.com', {
waitUntil: 'networkidle2',
timeout: 60000
});
await page.screenshot({
path: 'screenshot.png',
fullPage: true
});
// other actions...
await browser.close();
});
return {
statusCode: 200,
body: JSON.stringify('ok')
};
}
// module.exports.log
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment