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=webkitCache & 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→ runplaywright 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 webkitto pull the heavy dependency set. - Cache
~/.cache/ms-playwrightkeyed on the Playwright version.
Related guides
How to Install Playwright Browsers in CIInstall Playwright browser binaries in CI: use install --with-deps, cache by version, install only the browse…
How to Install Headless Chromium in CIInstall headless Chromium in CI: add the shared libraries it needs, choose distro Chromium vs a managed downl…
How to Install Firefox and geckodriver in CIInstall Firefox and geckodriver in CI for Selenium/WebDriver: match versions, add system libraries, run headl…
Self-Healing CI: Missing System Packages and Setup GapsA missing system library or tool fails the build until someone installs it. See the manual fix and how self-h…