QA Interview Hub · Knowledge base · Quizzes · Українська

Playwright › Architecture and isolation

Packages, browsers and channels

Playwright consists of the package, the browser builds and the system libraries, and a channel (channel) picks which browser runs. Every package version expects its own Chromium, Firefox and WebKit builds, which npx playwright install downloads; on a bare Linux CI image --with-deps is added. channel: 'chrome' or 'msedge' runs the Google Chrome or Edge installed on the machine instead of the bundled Chromium.

Playwright · Architecture

Green locally, but in CI: "Executable doesn't exist". What was not installed?

A developer bumped the version of @playwright/test, ran the install locally and everything passed. In CI the tests failed before the first step: the browser was not found. The package was updated, but the browsers in the cache were left from the old version. This is the classic mix-up between the package, the browsers and system libraries. The lesson splits them into layers and shows what breaks where.

How it works and why. Playwright does not use browsers from the system. Each package version expects specific builds of Chromium, Firefox and WebKit: this guarantees the library's protocol matches the browser, and tests do not depend on which Chrome version the OS updated. npx playwright install downloads the builds into the user cache (change the path with the PLAYWRIGHT_BROWSERS_PATH variable). So a project has three layers at once, and each is installed by its own command.

Three layers and what installs each

1. package @playwright/testnpm ci version sets the builds 2. browser builds in the cachenpx playwright install they need OS packages 3. Linux system librariesinstall --with-deps
Figure 1. Each layer is installed separately: upgrading the package does not upgrade the browsers, and a bare Linux image has no libraries to start a browser.

Which package. playwright is a browser automation library without a runner: chromium.launch(), newContext(), newPage(). Use it for scripts, screenshots, PDF generation or integration with someone else's runner (Jest, Mocha). @playwright/test is the full runner: fixtures, expect with retries, reporters, parallelism, retries, trace. For tests, use the second. The scaffold comes from npm init playwright@latest: it adds the dependency, a config and an example test, and offers to download browsers.

Which package to take

Better

@playwright/test

Runner and library together: fixtures, expect with retries, parallelism, reporters, trace. The usual choice for tests.

playwright

Only browser control: scripts, screenshots, PDF, someone else's runner. It has no runner or expect.

Figure 2. Tests need the runner; scripts are fine with the library.

Example: "works for me, fails in CI". After a package upgrade the pipeline fails:

Error: browserType.launch: Executable doesn't exist at
  …/ms-playwright/chromium-…/…
Looks like Playwright Test or Playwright was just installed or updated.
Please run the following command to download new browsers:
    npx playwright install

The log is shortened, but the shape is the same. The error points straight at layer 2: the new package version expects a build that is not in the cache. The usual cause: a browser cache between runs whose key does not include the Playwright version, or an install step missing altogether. The fix:

# before: only the package in the pipeline
npm ci
npx playwright test

# after: package, browsers and system libraries
npm ci
npx playwright install --with-deps chromium
npx playwright test --project=chromium

Why it works: --with-deps also installs the Linux system packages without which a browser does not start on a bare image (layer 3), and chromium limits the download to one browser when that is all the project uses. If you cache browsers, the key must include the Playwright version, otherwise after an upgrade the runner finds outdated builds. The official documentation actually advises against caching them: restoring a cache takes almost as long as downloading, and the cache does not cover system dependencies. Another route: the official Docker image of the same version as the package, where browsers are already installed.

Channel: branded browsers. Besides the builds Playwright downloads itself (Chromium, which since version 1.57 uses Chrome for Testing builds, plus Firefox and WebKit), you can run an installed Google Chrome or Microsoft Edge through channel:

import { defineConfig, devices } from '@playwright/test';

export default defineConfig({
  projects: [
    { name: 'chromium', use: { ...devices['Desktop Chrome'] } },
    { name: 'firefox', use: { ...devices['Desktop Firefox'] } },
    { name: 'webkit', use: { ...devices['Desktop Safari'] } },
    {
      name: 'google-chrome',
      use: { ...devices['Desktop Chrome'], channel: 'chrome' },
    },
    {
      name: 'edge',
      use: { ...devices['Desktop Edge'], channel: 'msedge' },
    },
  ],
});

channel needs the browser installed: npx playwright install chrome or the one already on the machine. Separate projects with channel make sense when the business needs the branded browser verified: codecs, corporate policies, extensions. The price: Chrome updates itself, so tests stop being tied to the Playwright version. Regular tests are fine on Playwright's own builds.

Limits: what WebKit means. WebKit in Playwright is an engine close to the one in Safari, not Safari itself. It catches differences in rendering, CSS and API behaviour well, including on Linux and in CI, but it does not replace a real iPhone, gestures, the on-screen keyboard or mobile Safari specifics. The devices['iPhone 15'] emulation sets the viewport, user agent and touch, while the engine stays the same. Compared with other tools: Selenium drives a driver and a browser from the system (Selenium Manager can fetch them automatically), Cypress runs browsers from the system or its bundled Electron (the default, but already marked as deprecated). In Playwright the browser is part of the project's dependencies, which buys reproducibility at the cost of a download.

Common mistakes.

  • Upgrading @playwright/test without running npx playwright install: the "Executable doesn't exist" error.
  • Forgetting --with-deps in CI on a bare Linux image: the browser fails to start because of missing system libraries.
  • Caching browsers with a key that has no Playwright version: after a package upgrade the cache returns old builds.
  • Using a Docker image of a different version than the package: its browser builds do not match the expected ones.
  • Switching every project to channel: 'chrome' "for realism": tests depend on the Chrome version on a particular machine instead of the Playwright version.
  • Treating a green WebKit project as proof that everything works in Safari on an iPhone.

Check yourself

CI fails at launch with "Executable doesn't exist at …/chromium-…". Locally everything works. Which layer is the problem in, and what do you check first?

Answer

Layer 2 (browser builds). Check whether the pipeline runs npx playwright install and whether the browser cache is tied to an old package version. It works locally because the needed build is already installed there.

The browser is downloaded, but on a bare Linux image it does not start because of missing libraries. Which command fixes it, and why does npm ci not help here?

Answer

npx playwright install --with-deps: the flag installs the system packages. npm ci installs only JavaScript dependencies and does not touch OS libraries.

Does a green webkit project prove the app works in Safari on an iPhone?

Answer

No. It is a close engine that catches rendering and CSS differences well, but it is not a real device: gestures, the on-screen keyboard and mobile Safari behaviour stay unverified.

In an interview. Junior: For tests I use @playwright/test. I install browsers with npx playwright install, because they are tied to the package version, and on Linux in CI I add --with-deps. Middle/Senior: I tell three layers apart: the package, the browser builds and the system libraries, and I know that upgrading the package without reinstalling browsers gives "Executable doesn't exist". If there is a cache or a Docker image, I tie its version to the package. I add channel projects when Google Chrome or Edge matter, and I treat WebKit as an approximation of Safari, not a replacement for a real device.

More articles in this chapter