-
Notifications
You must be signed in to change notification settings - Fork 5k
Description
To run Playwright on unsupported Linux distribution, you run run Playwright server in Docker while keeping your tests running on the host system:
Run Playwright Server in Docker
docker run -p 3000:3000 --rm --init -it mcr.microsoft.com/playwright:v1.41.0-jammy /bin/sh -c "cd /home/pwuser && npx -y playwright@1.41.0 run-server --port 3000 --host 0.0.0.0"It will output following when ready
Listening on ws://127.0.0.1:3000/
Point Playwright client to the server on Docker
If running @playwright/test, use environment variable, no other changes are needed.
PW_TEST_CONNECT_WS_ENDPOINT=ws://127.0.0.1:3000/ npx playwright testAlternatively, for other applications and language ports, use browserType.connect API to use remote Playwright.
const browser = await playwright['chromium'].connect('ws://127.0.0.1:3000/');Network
Make sure that the host network is available in your Docker container if you are testing local servers:
docker run --add-host=hostmachine:host-gatewayThis will make hostmachine point to the host's localhost. Note that all the tests would also need to use hostmachine in the URLs to access servers on the host. Alternatively, you can follow unconventional route and do docker run --add-host=localhost:host-gateway at your own risk.