Created
January 30, 2019 14:34
-
-
Save stefanolaru/94bf904e72263ce0ae1072520cce4dca to your computer and use it in GitHub Desktop.
Puppeteer Screenshot Test
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
'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