4 examples of 'page screenshot puppeteer' in JavaScript

Every line of 'page screenshot puppeteer' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
this disclaimer
48export function screenShot (window) {
49 if (window) {
50 window.webContents.capturePage((image) => {
51 let opts = {
52 title: 'Save Screen Shot',
53 defaultPath: app.getPath('documents'),
54 filters: [
55 {name: 'PNG', extensions: ['png']},
56 {name: 'JPG', extensions: ['jpg']}
57 ]
58 }
59 let cb = (path) => {
60 if (path) {
61 let png = S(path.toLowerCase()).endsWith('png')
62
63 let buf = png ? image.toPNG() : image.toJPEG(100)
64 fs.writeFile(path, buf, 'binary', (wError) => {
65 if (wError) {
66 dialog.showErrorBox("Something went wrong :'(", 'Screen shot could not be saved to that path')
67 } else {
68 dialog.showMessageBox(window, {
69 type: 'info',
70 title: 'Done',
71 message: 'Screen shot saved',
72 buttons: ['Ok']
73 }, (r) => console.log(r))
74 }
75 })
76 }
77 }
78 dialog.showSaveDialog(window, opts, cb)
79 })
80 }
81}
Important

Use secure code every time

Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code

83function takeScreenshot(driver) {
84 return GalenUtils.takeScreenshot(driver);
85}
22public async click(element: ElementHandle): Promise<void> {
23 await element.click();
24}
28public async newPage(): Promise<PuppeteerPage> {
29 const page = await this.context.newPage();
30 return new PuppeteerPage(page);
31}

Related snippets