Reputation: 3418
const playwright = require("playwright");
(async () => {
const browsers = ["chromium", "firefox", "webkit"];
for (const browserType of browsers) {
const browser = await playwright[browserType].launch({args: ['--no-sandbox']});
const context = await browser.newContext();
const page = await context.newPage("http://whatsmyuseragent.org/");
await page.screenshot({ path: `example-${browserType}.png` });
}
})();
after running this script, I got
UnhandledPromiseRejectionWarning: Error: Firefox revision is not
downloaded. Run "npm install" or "yarn install" in the console.
How to fix it?
Upvotes: 5
Views: 1834
Reputation: 3152
You can use the Playwright CLI to install the browsers:
npx playwright install
The reason that the revisions can't be found is mostly due that NPM's cache is not configured properly when node_modules
are e.g. cached on some CI environment. Since NPM thinks Playwright is installed but the actual browsers are stored in another location. See here for reference.
Upvotes: 0