【问题标题】:Playwright Error: Firefox revision is not downloaded. Run "npm install" or "yarn install"编剧错误:未下载 Firefox 修订版。运行“npm install”或“yarn install”
【发布时间】:2020-05-12 02:22:45
【问题描述】:
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` });
  }
})();

运行此脚本后,我得到 UnhandledPromiseRejectionWarning: E​​rror: Firefox revision is not download。在控制台中运行“npm install”或“yarn install”。如何解决?

【问题讨论】:

    标签: javascript playwright


    【解决方案1】:

    使用 npm 代替 yarn 后,问题得到解决。

    【讨论】:

      【解决方案2】:

      您可以使用 Playwright CLI 安装浏览器:

      npx playwright install
      

      无法找到修订版本的原因主要是由于在node_modules 时没有正确配置NPM 的缓存。缓存在某些 CI 环境中。由于 NPM 认为 Playwright 已安装,但实际浏览器存储在另一个位置。参考here

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2020-10-30
        • 2021-11-25
        • 2018-11-15
        • 1970-01-01
        • 2019-11-21
        • 1970-01-01
        • 2019-03-30
        • 1970-01-01
        相关资源
        最近更新 更多