forked from puppeteer/ispuppeteerwebdriverbidiready
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.js
29 lines (26 loc) · 778 Bytes
/
build.js
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 fs = require('fs').promises;
const puppeteer = require('puppeteer');
const server = require('./server.js');
async function main() {
const browser = await puppeteer.launch();
const page = await browser.newPage();
await server.start(9001);
await page.setViewport({
width: 3840,
height: 2163,
});
await page.goto('http://localhost:9001/');
await page.waitForSelector('canvas');
await new Promise(resolve => setTimeout(resolve, 1000));
await page.evaluate(() => {
const scripts = document.querySelectorAll('script');
for (const script of scripts) {
script.remove();
}
});
const screenshot = await page.screenshot()
await fs.writeFile('dist/static.png', screenshot);
await browser.close();
await server.stop();
}
main();