2020-07-27 19:31:57 +09:00
|
|
|
const playwright = require("playwright");
|
|
|
|
|
|
|
|
async function main() {
|
2020-07-27 20:06:30 +09:00
|
|
|
// NOTE: Unhandled promise rejection terminates Node.js process with non-zero exit code.
|
|
|
|
process.on("unhandledRejection", (event) => {
|
|
|
|
throw event;
|
|
|
|
});
|
|
|
|
|
2020-07-27 19:31:57 +09:00
|
|
|
for (const browserType of ["chromium", "firefox", "webkit"]) {
|
|
|
|
const browser = await playwright[browserType].launch();
|
|
|
|
const context = await browser.newContext();
|
|
|
|
const page = await context.newPage();
|
|
|
|
await page.goto("http://whatsmyuseragent.org/");
|
|
|
|
await page.screenshot({
|
2020-07-27 20:56:41 +09:00
|
|
|
path: `screenshots/${browserType}.png`,
|
2020-07-27 19:31:57 +09:00
|
|
|
});
|
|
|
|
await browser.close();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
main();
|