playwright: [BUG] Error: browserType.launch: Failed to launch chromium because executable doesn't exist at /home/jenkins/.cache/ms-playwright/chromium-844399/chrome-linux/chrome

Context:

  • Playwright Version: [1.8]
  • Operating System: [Unix / jenkins]
  • Node.js version: [10.14]
  • Browser: Chromium]

We are attempting to install playwright thru yarn but it fails intermittently with this error. Our project is monorepo and uses “yarn”

any idea how to resolve this issue?

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 11
  • Comments: 21 (4 by maintainers)

Commits related to this issue

Most upvoted comments

i found that working too https://playwright.dev/docs/browsers#managing-browser-binaries-1

fixed with two env vars in our github actions and changed command order (npx playwright install after yarn install)

env:
  PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1 # Skip downloading during yarn install
  PLAYWRIGHT_BROWSERS_PATH: 0 # Places binaries to node_modules/@playwright/test

jobs:
  e2e:
    runs-on: ubuntu-latest

    steps:
      - name: Install dependencies
        run: |
            npx playwright install-deps

      - name: Setup
        run: |
            yarn install
            npx playwright install

How can I force download the Chromium Binary only?

You can use playwright command line interface to install the browser:

npx playwright install chromium

It passes intermittently so I doubt it’s SKIPPING the browser download. It does not install with yarn command, and behaves flaky.

I’m not familiar with Jenkins, does it merely run the same script as you do locally or does it get a copy of files created by running the installation scripts elsewhere? Like I said if the browser hasn’t been downloaded the install step should fail.

@tanvee38 this sounds like a different bug, it’d be better to discuss it separately. Also it’d be helpful if you could share your Dockerfile.

Just to add to this. I am setting up playwright tests in gitlab CI. When running npm ci it installs different builds of the browsers

Playwright build of chromium v901522 downloaded to /root/.cache/ms-playwright/chromium-901522
Playwright build of ffmpeg v1005 downloaded to /root/.cache/ms-playwright/ffmpeg-1005
Playwright build of firefox v1278 downloaded to /root/.cache/ms-playwright/firefox-1278
Playwright build of webkit v1516 downloaded to /root/.cache/ms-playwright/webkit-1516

But when running tests, it expects different build

browserType.launch: Failed to launch chromium because executable doesn't exist at /root/.cache/ms-playwright/chromium-888113/chrome-linux/chrome

@vaghelmt - We use https://codecept.io/ to run our tests on both Playwright as well as on Web drivers.

npx playwright install does not always install libraries, and it’s been a known issue for a long.

So, as per the medium artical, we pre-installed the Browser Binaries in our CI Docker, and SKIP the browser downloads during npx playwright install. It’s a very generic approach regardless of the framework, and it works for us. Let me know if you face any issues!

This means that browser download failed(may well be a network issue) during playwright installation. You need to reinstall playwright in this case, it will try to download missing browsers again.

@yury-s Our Jenkins job downloads all other dependencies fine, so I doubt on Network issue. As I mentioned, this is the intermittent issue, but it fails our build often. Even upon reinstalling or rerunning the Job again, it fails for the same reason. Pls advice.

npx playwright install并不总是安装库,而且长期以来一直是一个已知问题。

因此,根据中篇文章,我们在 CI Docker 中预装了浏览器二进制文件,并在 .无论框架如何,这都是一种非常通用的方法,它对我们有用。如果您遇到任何问题,请告诉我!npx playwright install

@vaghelmt

I’m glad it worked for you 👏

Feel free to post/share your feedback on medium post - https://gkushang.medium.com/playwright-failed-to-launch-browsers-how-to-solve-8b01d03fe5b9.

感谢您的及时回复!

在中型文章中,你提供了用于下载二进制文件并始终从默认位置加载二进制文件的代码。

这是我的Docker文件,我把它们放在正确的位置了吗?

FROM mcr.microsoft.com/playwright:focal as BASE


WORKDIR /app

ADD package.json ./
ADD yarn.lock ./

COPY . ./

RUN PLAYWRIGHT_BROWSERS_PATH=/usr/lib/playwright yarn add playwright-chromium@1.11.1

RUN PLAYWRIGHT_BROWSERS_PATH=/usr/lib/playwright yarn add playwright-webkit@1.11.1

RUN PLAYWRIGHT_BROWSERS_PATH=/usr/lib/playwright yarn add playwright-firefox@1.11.1

RUN PLAYWRIGHT_BROWSERS_PATH=/usr/lib/playwright yarn test

I want to konw the path come from where beacuse I use the /usr/lib/playwright yarn test is error . but my dockerfile has the RUN PLAYWRIGHT_BROWSERS_PATH=/usr/lib/playwright yarn add playwright-chromium@1.11.1, you can help me to see my file ? thank

FROM alpine:3.16 AS base

RUN apk add --no-cache --update nodejs yarn npm

ENV APP_PATH=/app

WORKDIR ${APP_PATH}

FROM base AS install COPY package.json .

RUN yarn install --production

FROM base

COPY --from=install ${APP_PATH}/node_modules ./node_modules

COPY . .

RUN PLAYWRIGHT_BROWSERS_PATH=/usr/lib/playwright yarn add playwright-chromium@1.42.1

CMD yarn serve

Some implementation details: the way playwright works is it downloads corresponding chromium revision into the .cache folder (/home/jenkins/.cache/ms-playwright/chromium-844399 in your case) and then when you run the tests it will try to launch chromium from that directory.

Error: browserType.launch: Failed to launch chromium because executable doesn't exist at /home/jenkins/.cache/ms-playwright/chromium-844399/chrome-linux/chrome error indicates that the file is not there, perhaps it gets deleted by someone intermittently. You need to find out why the content of /home/jenkins/.cache/ms-playwright/chromium-844399/ changes between the installation and test runs.