Can Playwright run on cloud-based services?
Yes. Playwright tests are ordinary Node.js processes that drive browsers, so anything that can run Node and a browser can run them: a CI runner, a Docker container on a cloud VM, a Kubernetes job, or a hosted grid of remote browsers. "Running in the cloud" usually means one of three set-ups, and they differ in where the browsers live.
Option 1: tests and browsers on a CI runner
This is the most common set-up. The CI machine checks out your code, installs Playwright and its browsers, and runs the tests headless. A minimal GitHub Actions job looks like this:
# .github/workflows/e2e.yml
name: e2e
on: [push]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 22
- run: npm ci
- run: npx playwright install --with-deps
- run: npx playwright test
- uses: actions/upload-artifact@v4
if: always()
with:
name: playwright-report
path: playwright-report/
--with-deps installs the Linux system libraries the browsers need. Without it you get errors about missing shared libraries on a fresh image. Jenkins, GitLab CI and Azure Pipelines follow the same steps; see integrating Playwright with CI/CD tools.
Option 2: the official Docker image
Microsoft publishes a Docker image with Node, the browsers and their dependencies already installed, on mcr.microsoft.com/playwright. Pin the tag to the same version as @playwright/test in your package.json:
docker run --rm --ipc=host -v "$PWD":/work -w /work \
mcr.microsoft.com/playwright:v1.64.0-noble \
npx playwright test
The same image runs on any cloud container service. --ipc=host is recommended for Chromium, which can run out of shared memory inside a container otherwise.
Option 3: remote browsers
Here the test runner stays on your machine or CI, but the browsers run somewhere else and the runner connects to them over a WebSocket. Playwright ships a small server for this:
# on the browser machine
npx playwright run-server --port 3000
// playwright.config.ts
import { defineConfig } from '@playwright/test';
export default defineConfig({
use: {
connectOptions: {
wsEndpoint: process.env.PW_WS_ENDPOINT ?? 'ws://browser-host:3000/',
},
},
});
Hosted browser grids from several testing vendors, and a Microsoft-run service on Azure, work on the same idea: you get a WebSocket endpoint and an access token, and you put them in connectOptions (often through the vendor's own config helper). Check each provider's current documentation for supported browsers, versions and limits, because these change often.
Scaling out with sharding
When one machine is not enough, split the suite across several CI jobs:
npx playwright test --shard=1/4 # job 1
npx playwright test --shard=2/4 # job 2 ... and so on
Use the blob reporter in each shard and npx playwright merge-reports afterwards to get one HTML report. Within each machine, workers still run in parallel; see parallelism in Playwright.
Gotchas in the cloud
- Version mismatch. With remote browsers, the client and the server must run the same Playwright version. A mismatch fails at connect time.
- No display. Cloud machines have no screen, so run headless (the default). Use traces, screenshots and videos to see what happened; see tracing in Playwright.
- Localhost is not your laptop. A remote browser resolves
localhoston its own machine. PointbaseURLat an address the browser host can reach, or use the provider's tunnel. - Secrets. Keep test passwords and tokens in the CI secret store, read them with
process.env, and never commit a savedstorageStatefile. - Time zone and locale. Cloud runners often use UTC and US English. Set
timezoneIdandlocalein the config if your app shows dates in IST.
Previous question: beforeAll and afterAll hooks.
Want to master Playwright hands-on?
Join Uncodemy's Playwright Automation Testing Course in Noida — Dedicated Placement Support.
Explore the Course →