forked from zephyrproject-rtos/pr-dashboard
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathscreenshot.js
More file actions
40 lines (30 loc) · 1.07 KB
/
screenshot.js
File metadata and controls
40 lines (30 loc) · 1.07 KB
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
30
31
32
33
34
35
36
37
38
39
40
const puppeteer = require('puppeteer');
const fs = require('fs');
async function takeScreenshot(page, url, index) {
try {
console.log(`Navigating to ${url}...`);
await page.goto(url, { waitUntil: 'networkidle0' });
const filename = `screenshot-${index}.png`;
await page.screenshot({ path: filename, fullPage: true });
console.log(`Screenshot for ${url} saved as ${filename}`);
} catch (error) {
console.error(`Error taking screenshot for ${url}:`, error);
}
}
(async () => {
const urlsToScreenshot = [
'http://localhost:8080/?username=fabiobaltieri',
'http://localhost:8080/?username=kartben',
];
const browser = await puppeteer.launch({
headless: 'new',
args: ['--no-sandbox']
});
const page = await browser.newPage();
await page.setViewport({ width: 1600, height: 900 });
for (const [index, url] of urlsToScreenshot.entries()) {
await takeScreenshot(page, url, index);
}
await browser.close();
console.log('All screenshots complete!');
})();