Skip to content
Latchkey

How to Run WebKit Tests in CI with Playwright

WebKit on Linux needs a specific set of GStreamer and graphics libraries that Playwright bundles knowledge of but you still have to install.

There is no standalone WebKit you install with apt for testing - Playwright ships a maintained WebKit build. CI just needs its system dependencies, which --with-deps provides.

Why it fails in CI

  • WebKit needs WPE/GStreamer and woff2 libraries that slim images lack → launch fails.
  • The WebKit binary was not installed (only chromium was).
  • A stale browser cache mismatched to the Playwright version.

Install it reliably

Install the WebKit browser with its dependencies through Playwright, then run the WebKit project headless.

Terminal
npm ci
npx playwright install --with-deps webkit

npx playwright test --project=webkit

Cache & speed

Cache the Playwright browser directory keyed on the Playwright version. WebKit launches can be flaky on Linux; larger managed runners and auto-retry of transient failures help.

.github/workflows/ci.yml
- uses: actions/cache@v4
  with:
    path: ~/.cache/ms-playwright
    key: playwright-${{ runner.os }}-${{ hashFiles('**/package-lock.json') }}

Common errors

  • browserType.launch: ... error while loading shared libraries → run playwright install --with-deps webkit.
  • Executable doesn't exist → WebKit was not installed; install that browser specifically.
  • Target page, context or browser has been closed → flaky launch; retry on a larger runner.

Key takeaways

  • Use Playwright's WebKit build - there is no standalone apt WebKit for testing.
  • Install with --with-deps webkit to pull the heavy dependency set.
  • Cache ~/.cache/ms-playwright keyed on the Playwright version.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →