forked from jlandure/alpine-chrome
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.js
26 lines (25 loc) · 915 Bytes
/
test.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
const { chromium } = require("playwright-chromium");
(async () => {
const { exec } = require("child_process");
exec(
process.env.PLAYWRIGHT_CHROMIUM_EXECUTABLE_PATH + " --version",
function callback(error, stdout, stderr) {
console.log(stdout.replace(/\n$/, ""));
}
);
})();
(async () => {
const browser = await chromium.launch({
executablePath: process.env.PLAYWRIGHT_CHROMIUM_EXECUTABLE_PATH,
// 💡 This enables logs for the communication between Playwright and Chromium
// logger: {
// isEnabled: (name, severity) => name === "browser" || "context",
// log: (name, severity, message, args) => console.log(`${name} ${message}`),
// },
});
const context = await browser.newContext();
const page = await context.newPage();
await page.goto("https://example.com/");
await page.screenshot({ path: "test/example.png" });
await browser.close();
})();