mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
Update examples/screenshot.js to use Page.saveScreenshot
This commit is contained in:
parent
52e2633f32
commit
7bf3684039
@ -14,14 +14,11 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
var Browser = require('./lib/Browser');
|
var Browser = require('../lib/Browser');
|
||||||
var Page = require('./lib/Page');
|
|
||||||
var fs = require('fs');
|
|
||||||
var browser = new Browser();
|
var browser = new Browser();
|
||||||
|
|
||||||
browser.newPage().then(async page => {
|
browser.newPage().then(async page => {
|
||||||
await page.navigate('http://example.com');
|
await page.navigate('http://example.com');
|
||||||
var screenshotBuffer = await page.screenshot(Page.ScreenshotTypes.PNG);
|
await page.saveScreenshot('example.png');
|
||||||
fs.writeFileSync('example.png', screenshotBuffer);
|
|
||||||
browser.close();
|
browser.close();
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user