-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpuppeteer.js
More file actions
29 lines (22 loc) · 886 Bytes
/
Copy pathpuppeteer.js
File metadata and controls
29 lines (22 loc) · 886 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
const puppeteer = require('puppeteer-core');
const childProcess = require('child_process');
const path = require('path');
function delay(time) {
return new Promise(function (resolve) {
setTimeout(resolve, time)
});
}
(async () => {
const electronPath = require('electron');
const electronProcess = childProcess.spawn(electronPath, ['.', '--remote-debugging-port=9222']);
await delay(2000);
const browser = await puppeteer.connect({ browserURL: 'http://localhost:9222', defaultViewport: null });
const pages = await browser.pages();
const page = pages[0];
await page.goto('https://front.serverest.dev');
page.screenshot({ path: 'screenshot.png', fullPage: true });
console.log('Screenshot tirada com sucesso!');
await delay(2000);
await browser.disconnect();
electronProcess.kill();
})();