- Installing browser binaries
- Installing a single browser binary
- Managing browser binaries
- Install behind a firewall or a proxy
- Download from artifact repository
- Stale browser removal
Each version of Playwright Test needs specific versions of browser binaries to operate. Playwright Test includes Command Line Interface that can download these binaries. By default, Playwright Test downloads Chromium, WebKit and Firefox browsers into the OS-specific cache folders:
# Add dependencynpm i -D @playwright/test# Download browser binariesnpx playwright install
These browsers will take a few hundred megabytes of disk space when installed:
du -hs ~/Library/Caches/ms-playwright/*281M chromium-XXXXXX187M firefox-XXXX180M webkit-XXXX
Playwright Test downloads Chromium, Firefox and WebKit browsers by default. To install a specific browser, pass it as an argument.
npx playwright install webkit
You can override default installation behavior using environment variables. When installing browsers, ask Playwright Test to download them into a specific location.
# Linux/macOSPLAYWRIGHT_BROWSERS_PATH=$HOME/pw-browsers npx playwright install # Windows with cmd.exeset PLAYWRIGHT_BROWSERS_PATH=%USERPROFILE%\pw-browsersnpx playwright install # Windows with PowerShell$env:PLAYWRIGHT_BROWSERS_PATH="$env:USERPROFILE\pw-browsers"npx playwright install
When running tests, ask it to search for browsers in a shared location.
# Linux/macOSPLAYWRIGHT_BROWSERS_PATH=$HOME/pw-browsers npx playwright test # Windows with cmd.exeset PLAYWRIGHT_BROWSERS_PATH=%USERPROFILE%\pw-browsersnpx playwright test # Windows with PowerShell$env:PLAYWRIGHT_BROWSERS_PATH="$env:USERPROFILE\pw-browsers"npx playwright test
Or you can opt into the hermetic install and place binaries in the local folder:
# Linux/macOS# Places binaries to node_modules/@playwright/testPLAYWRIGHT_BROWSERS_PATH=0 npx playwright install # Windows with cmd.exe# Places binaries to node_modules\@playwright\testset PLAYWRIGHT_BROWSERS_PATH=0npx playwright install # Windows with PowerShell# Places binaries to node_modules\@playwright\test$env:PLAYWRIGHT_BROWSERS_PATH=0npx playwright install
Playwright Test keeps track of packages that need those browsers and will garbage collect them as you update Playwright Test to the newer versions.
By default, Playwright Test downloads browsers from Microsoft CDN.
Sometimes companies maintain an internal proxy that blocks direct access to the public resources. In this case, Playwright can be configured to download browsers via a proxy server.
# Linux/macOSHTTPS_PROXY=https://192.0.2.1 npx playwright install # Windows with cmd.exeset HTTPS_PROXY=https://192.0.2.1npx playwright install # Windows with PowerShell$env:HTTPS_PROXY="https://192.0.2.1"npx playwright install
By default, Playwright downloads browsers from Microsoft CDN.
Sometimes companies maintain an internal artifact repository to host browser binaries. In this case, Playwright can be configured to download from a custom location using the
PLAYWRIGHT_DOWNLOAD_HOST env variable.
# Linux/macOSPLAYWRIGHT_DOWNLOAD_HOST=192.0.2.1 npx playwright install # Windows with cmd.exeset PLAYWRIGHT_DOWNLOAD_HOST=192.0.2.1npx playwright install # Windows with PowerShell$env:PLAYWRIGHT_DOWNLOAD_HOST="192.0.2.1"npx playwright install
It is also possible to choose a per-browser download host using
PLAYWRIGHT_WEBKIT_DOWNLOAD_HOST env variables that take precedence over
Playwright Test keeps track of the clients that use its browsers. When there are no more clients that require particular version of the browser, that version is deleted from the system. That way you can safely use Playwright Test instances of different versions and at the same time, you don't waste disk space for the browsers that are no longer in use.
To opt-out from the unused browser removal, you can set the
PLAYWRIGHT_SKIP_BROWSER_GC=1 environment variable.