Skip to content

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

docs: Browsers page rework (#21051)

Debbie O'Briend0d1d144f127
diff --git a/docs/src/browsers.md b/docs/src/browsers.md
index d920c47c7d..fd66307bc9 100644
--- a/docs/src/browsers.md
+++ b/docs/src/browsers.md
@@ -3,371 +3,433 @@ id: browsers
title: "Browsers"
---
-Each version of Playwright needs specific versions of browser binaries to operate. Depending on the language you use, Playwright will either download these browsers at package install time for you, or you will need to use [Playwright CLI](./cli.md) to install these browsers.
+Each version of Playwright needs specific versions of browser binaries to operate. You will need to use the Playwright CLI to install these browsers.
With every release, Playwright updates the versions of the browsers it supports, so that the latest Playwright would support the latest browsers at any moment. It means that every time you update playwright, you might need to re-run the `install` CLI command.
-## Chromium
+## Install browsers
-For Google Chrome, Microsoft Edge and other Chromium-based browsers, by default, Playwright uses open source Chromium builds.
-Since Chromium project is ahead of the branded browsers, when the world is on Google Chrome N, Playwright already supports
-Chromium N+1 that will be released in Google Chrome and Microsoft Edge in a few weeks.
+Playwright can install supported browsers. Running the command without arguments will install the default browsers.
-There is also a way to opt into using Google Chrome's or Microsoft Edge's branded builds for testing. For details
-on when to opt into stable channels, refer to the [Google Chrome & Microsoft Edge](#google-chrome--microsoft-edge) section below.
+```bash js
+npx playwright install
+```
-## Firefox
+```bash java
+mvn exec:java -e -D exec.mainClass=com.microsoft.playwright.CLI -D exec.args="install"
+```
-Playwright's Firefox version matches the recent [Firefox Stable](https://www.mozilla.org/en-US/firefox/new/)
-build.
+```bash python
+playwright install
+```
-## WebKit
+```bash csharp
+pwsh bin/Debug/netX/playwright.ps1 install
+```
-Playwright's WebKit version matches the recent WebKit trunk build, before it is used in Apple Safari and
-other WebKit-based browsers. This gives a lot of lead time to react on the potential browser update issues.
+You can also install specific browsers by providing an argument:
-## Google Chrome & Microsoft Edge
+```bash js
+npx playwright install webkit
+```
-While Playwright can download and use the recent Chromium build, it can operate against the stock Google
-Chrome and Microsoft Edge browsers available on the machine (note that Playwright doesn't install them by
-default). In particular, current Playwright version will support Stable and Beta channels of these browsers.
-Here is how you can opt into using the stock browser:
+```bash java
+mvn exec:java -e -D exec.mainClass=com.microsoft.playwright.CLI -D exec.args="install webkit"
+```
-```js tab=js-js
-// @ts-check
+```bash python
+playwright install webkit
+```
-const { defineConfig } = require('@playwright/test');
+```bash csharp
+pwsh bin/Debug/netX/playwright.ps1 install webkit
+```
-module.exports = defineConfig({
- use: {
- channel: 'chrome',
- },
-});
+See all supported browsers:
+
+```bash js
+npx playwright install --help
```
-```js tab=js-ts
-import { defineConfig } from '@playwright/test';
-export default defineConfig({
- use: {
- channel: 'chrome',
- },
-});
+```bash java
+mvn exec:java -e -D exec.mainClass=com.microsoft.playwright.CLI -D exec.args="install --help"
```
-```js tab=js-library
-const { chromium } = require('playwright');
-const browser = await chromium.launch({
- channel: 'chrome' // or 'msedge', 'chrome-beta', 'msedge-beta', 'msedge-dev', etc.
-});
+```bash python
+playwright install --help
```
-```java
-import com.microsoft.playwright.*;
+```bash csharp
+pwsh bin/Debug/netX/playwright.ps1 install --help
+```
-public class Example {
- public static void main(String[] args) {
- try (Playwright playwright = Playwright.create()) {
- BrowserType chromium = playwright.chromium();
- // Can be "msedge", "chrome-beta", "msedge-beta", "msedge-dev", etc.
- Browser browser = chromium.launch(new BrowserType.LaunchOptions().setChannel("chrome"));
- }
- }
+### Install browsers via API
+* langs: csharp
+
+It's possible to run Command line tools commands via the .NET API:
+
+```csharp
+var exitCode = Microsoft.Playwright.Program.Main(new[] {"install"});
+if (exitCode != 0)
+{
+ throw new Exception($"Playwright exited with code {exitCode}");
}
```
-```python async
-# Can be "msedge", "chrome-beta", "msedge-beta", "msedge-dev", etc.
-browser = await playwright.chromium.launch(channel="chrome")
-```
+### Install system dependencies
-```python sync
-# Can be "msedge", "chrome-beta", "msedge-beta", "msedge-dev", etc.
-browser = playwright.chromium.launch(channel="chrome")
+System dependencies can get installed automatically. This is useful for CI environments.
+
+```bash js
+npx playwright install-deps
```
-```csharp
-using Microsoft.Playwright;
+```bash java
+mvn exec:java -e -D exec.mainClass=com.microsoft.playwright.CLI -D exec.args="install-deps"
+```
-using var playwright = await Playwright.CreateAsync();
-var chromium = playwright.Chromium;
-// Can be "msedge", "chrome-beta", "msedge-beta", "msedge-dev", etc.
-var browser = await chromium.LaunchAsync(new BrowserTypeLaunchOptions { Channel = "chrome" });
+```bash python
+playwright install-deps
```
-### Installing Google Chrome & Microsoft Edge
+```bash csharp
+pwsh bin/Debug/netX/playwright.ps1 install-deps
+```
-If stock Google Chrome or Microsoft Edge is not available on your machine, you can install
-them using Playwright command line tool:
+You can also install the dependencies for a single browser by passing it as an argument:
-```bash lang=js
-npx playwright install msedge
+```bash js
+npx playwright install-deps chromium
```
-```bash lang=python
-playwright install msedge
+```bash java
+mvn exec:java -e -D exec.mainClass=com.microsoft.playwright.CLI -D exec.args="install-deps chromium"
```
-```bash lang=csharp
-pwsh bin/Debug/netX/playwright.ps1 install msedge
+```bash python
+playwright install-deps chromium
```
-```batch lang=java
-mvn exec:java -e -D exec.mainClass=com.microsoft.playwright.CLI -D exec.args="install msedge"
+```bash csharp
+pwsh bin/Debug/netX/playwright.ps1 install-deps chromium
```
-Run with `--help` option to see full list of the browsers that can be installed this way.
+It's also possible to combine `install-deps` with `install` so that the browsers and OS dependencies are installed with a single command.
-:::warning
-Google Chrome or Microsoft Edge installations will not be isolated. They will be installed at the
-default global location that depends on your operating system.
-:::
+```bash js
+npx playwright install --with-deps chromium
+```
-### When to use Google Chrome & Microsoft Edge and when not to?
+```bash java
+mvn exec:java -e -D exec.mainClass=com.microsoft.playwright.CLI -D exec.args="install --with-deps chromium"
+```
-**Defaults**
+```bash python
+playwright install --with-deps chromium
+```
-Using default Playwright configuration with the latest Chromium is a good idea most of the time.
-Since Playwright is ahead of Stable channels for the browsers, it gives peace of mind that the
-upcoming Google Chrome or Microsoft Edge releases won't break your site. You catch breakage
-early and have a lot of time to fix it before the official Chrome update.
+```bash csharp
+pwsh bin/Debug/netX/playwright.ps1 install --with-deps chromium
+```
-**Regression testing**
+## Update Playwright regulary
-Having said that, testing policies often require regression testing to be performed against
-the current publicly available browsers. In this case, you can opt into one of the stable channels,
-`"chrome"` or `"msedge"`.
+By keeping your Playwright version up to date you will be able to use new features and test your app on the latest browser versions and catch failures before the latest browser version is released to the public.
-**Media codecs**
+```bash js
+# Update playwright
+npm install -D @playwright/test@latest
-Another reason for testing using official binaries is to test functionality related to media codecs.
-Chromium does not have all the codecs that Google Chrome or Microsoft Edge are bundling due to
-various licensing considerations and agreements. If your site relies on this kind of codecs (which is
-rarely the case), you also want to use official channel.
+# Install new browsers
+npx playwright install
+```
+Check the [release notes](./release-notes.md) to see what the latest version is and what changes have been released.
-**Enterprise policy**
+```bash js
+# See what version of Playwright you have by running the following command
+npx playwright --version
+```
-Google Chrome and Microsoft Edge respect enterprise policies, which include limitations to the capabilities,
-network proxy, mandatory extensions that stand in the way of testing. So if you are a part of the
-organization that uses such policies, it is the easiest to use bundled Chromium for your local testing,
-you can still opt into stable channels on the bots that are typically free of such restrictions.
+## Configure Browsers
-## Installing browsers
-* langs: csharp
+Playwright can run tests on chromium, webkit and firefox browsers as well as branded browsers such as Google Chrome and Microsoft Edge. It can also run on emulated tablet and mobile devices. See the [registry of device parameters](https://github.com/microsoft/playwright/blob/main/packages/playwright-core/src/server/deviceDescriptorsSource.json) for a complete list of selected desktop, tablet and mobile devices.
-To invoke Playwright CLI commands, you need to invoke a PowerShell script:
+### Run tests on different browsers
+* langs: js
-```bash
-pwsh bin/Debug/netX/playwright.ps1 --help
-```
+Playwright can run your tests in multiple browsers and configurations by setting up **projects** in the config. You can also add [different options](./test-configuration) for each project.
-Playwright can install supported browsers by means of the CLI tool.
+```js
+import { defineConfig, devices } from '@playwright/test';
-```bash csharp
-# Running without arguments will install all browsers
-pwsh bin/Debug/netX/playwright.ps1 install
+export default defineConfig({
+ projects: [
+ /* Test against desktop browsers */
+ {
+ name: 'chromium',
+ use: { ...devices['Desktop Chrome'] },
+ },
+ {
+ name: 'firefox',
+ use: { ...devices['Desktop Firefox'] },
+ },
+ {
+ name: 'webkit',
+ use: { ...devices['Desktop Safari'] },
+ },
+ /* Test against mobile viewports. */
+ {
+ name: 'Mobile Chrome',
+ use: { ...devices['Pixel 5'] },
+ },
+ {
+ name: 'Mobile Safari',
+ use: { ...devices['iPhone 12'] },
+ },
+ /* Test against branded browsers. */
+ {
+ name: 'Google Chrome',
+ use: { ...devices['Desktop Chrome'], channel: 'chrome' }, // or 'chrome-beta'
+ },
+ {
+ name: 'Microsoft Edge',
+ use: { ...devices['Desktop Edge'], channel: 'msedge' }, // or 'msedge-dev'
+ },
+ ],
+});
```
-You can also install specific browsers by providing an argument:
+Playwright will run all projects by default.
-```bash csharp
-# Install WebKit
-pwsh bin/Debug/netX/playwright.ps1 install webkit
-```
+```bash
+npx playwright test
-See all supported browsers:
+Running 7 tests using 5 workers
-```bash csharp
-pwsh bin/Debug/netX/playwright.ps1 install --help
+ ✓ [chromium] › example.spec.ts:3:1 › basic test (2s)
+ ✓ [firefox] › example.spec.ts:3:1 › basic test (2s)
+ ✓ [webkit] › example.spec.ts:3:1 › basic test (2s)
+ ✓ [Mobile Chrome] › example.spec.ts:3:1 › basic test (2s)
+ ✓ [Mobile Safari] › example.spec.ts:3:1 › basic test (2s)
+ ✓ [Google Chrome] › example.spec.ts:3:1 › basic test (2s)
+ ✓ [Microsoft Edge] › example.spec.ts:3:1 › basic test (2s)
```
-## Install browsers via API
-* langs: csharp
+Use the `--project` command line option to run a single project.
-It's possible to run [Command line tools](./cli.md) commands via the .NET API:
+```bash
+npx playwright test --project=firefox
-```csharp
-var exitCode = Microsoft.Playwright.Program.Main(new[] {"install"});
-if (exitCode != 0)
-{
- throw new Exception($"Playwright exited with code {exitCode}");
-}
+Running 1 test using 1 worker
+
+ ✓ [firefox] › example.spec.ts:3:1 › basic test (2s)
```
-## Managing browser binaries
+The VS Code test runner runs your tests on the default browser of Chrome. To run on other/multiple browsers click the play button's dropdown from the testing sidebar and choose another profile or modify the default profile by clicking **Select Default Profile** and select the browsers you wish to run your tests on.
-Playwright downloads Chromium, WebKit and Firefox browsers into the OS-specific cache folders:
+<img width="1464" alt="selecting browsers" src="https://user-images.githubusercontent.com/13063165/221136731-9d4bc18f-38a4-4adb-997b-5b98c98aec7f.png" />
-- `%USERPROFILE%\AppData\Local\ms-playwright` on Windows
-- `~/Library/Caches/ms-playwright` on MacOS
-- `~/.cache/ms-playwright` on Linux
+Choose a specific profile, various profiles or all profiles to run tests on.
-These browsers will take a few hundred megabytes of disk space when installed:
+<img width="1536" alt="choosing default profiles" src="https://user-images.githubusercontent.com/13063165/221669537-e5df8672-f50d-4ff1-96f9-141cd67e12f8.png" />
+
+### Run tests on different browsers
+* langs: python
+
+Run tests on a specific browser:
```bash
-du -hs ~/Library/Caches/ms-playwright/*
-281M chromium-XXXXXX
-187M firefox-XXXX
-180M webkit-XXXX
+pytest test_login.py --browser webkit
```
-You can override default behavior using environment variables. When installing Playwright, ask it to download browsers into a specific location:
+Run tests on multiple browsers:
-```bash tab=bash-bash lang=js
-PLAYWRIGHT_BROWSERS_PATH=$HOME/pw-browsers npx playwright install
+```bash
+pytest test_login.py --browser webkit --browser firefox
```
-```batch tab=bash-batch lang=js
-set PLAYWRIGHT_BROWSERS_PATH=%USERPROFILE%\pw-browsers
-npx playwright install
-```
+Test against mobile viewports:
-```powershell tab=bash-powershell lang=js
-$env:PLAYWRIGHT_BROWSERS_PATH="$env:USERPROFILE\pw-browsers"
-npx playwright install
+```bash
+pytest test_login.py --device iphone_13
```
+Test against branded browsers:
-```bash tab=bash-bash lang=python
-pip install playwright
-PLAYWRIGHT_BROWSERS_PATH=$HOME/pw-browsers python -m playwright install
+```bash
+pytest test_login.py --browser-channel msedge
```
-```batch tab=bash-batch lang=python
-set PLAYWRIGHT_BROWSERS_PATH=%USERPROFILE%\pw-browsers
-pip install playwright
-playwright install
-```
+### Run tests on different browsers
+* langs: java
-```powershell tab=bash-powershell lang=python
-$env:PLAYWRIGHT_BROWSERS_PATH="$env:USERPROFILE\pw-browsers"
-pip install playwright
-playwright install
-```
+```java
+import com.microsoft.playwright.*;
-```bash tab=bash-bash lang=java
-PLAYWRIGHT_BROWSERS_PATH=$HOME/pw-browsers mvn exec:java -e -D exec.mainClass=com.microsoft.playwright.CLI -D exec.args="install"
+public class Example {
+ public static void main(String[] args) {
+ try (Playwright playwright = Playwright.create()) {
+ // Launch chromium, firefox or webkit.
+ Browser browser = playwright.chromium().launch();
+ Page page = browser.newPage();
+ // ...
+ }
+ }
+}
```
-```batch tab=bash-batch lang=java
-set PLAYWRIGHT_BROWSERS_PATH=%USERPROFILE%\pw-browsers
-mvn exec:java -e -D exec.mainClass=com.microsoft.playwright.CLI -D exec.args="install"
-```
+### Run tests on different browsers
+* langs: csharp
-```powershell tab=bash-powershell lang=java
-$env:PLAYWRIGHT_BROWSERS_PATH="$env:USERPROFILE\pw-browsers"
-mvn exec:java -e -D exec.mainClass=com.microsoft.playwright.CLI -D exec.args="install"
-```
+Run tests on a specific browser:
-```bash tab=bash-bash lang=csharp
-PLAYWRIGHT_BROWSERS_PATH=$HOME/pw-browsers
-pwsh bin/Debug/netX/playwright.ps1 install
+```bash
+dotnet test -- Playwright.BrowserName=webkit
```
-```batch tab=bash-batch lang=csharp
-set PLAYWRIGHT_BROWSERS_PATH=%USERPROFILE%\pw-browsers
-pwsh bin/Debug/netX/playwright.ps1 install
+To run your test on multiple browsers or configurations you need to invoke the `dotnet test` command multiple times. You can either specify the `BROWSER` environment variable or set the `Playwright.BrowserName` via the runsettings file:
+
+```bash
+dotnet test --settings:chromium.runsettings
+dotnet test --settings:firefox.runsettings
+dotnet test --settings:webkit.runsettings
```
-```powershell tab=bash-powershell lang=csharp
-$env:PLAYWRIGHT_BROWSERS_PATH="$env:USERPROFILE\pw-browsers"
-pwsh bin/Debug/netX/playwright.ps1 install
+```xml
+<?xml version="1.0" encoding="utf-8"?>
+ <RunSettings>
+ <Playwright>
+ <BrowserName>chromium</BrowserName>
+ </Playwright>
+ </RunSettings>
```
-When running Playwright scripts, ask it to search for browsers in a shared location.
+### Chromium
-```bash tab=bash-bash lang=js
-PLAYWRIGHT_BROWSERS_PATH=$HOME/pw-browsers npx playwright test
-```
+For Google Chrome, Microsoft Edge and other Chromium-based browsers, by default, Playwright uses open source Chromium builds. Since the Chromium project is ahead of the branded browsers, when the world is on Google Chrome N, Playwright already supports Chromium N+1 that will be released in Google Chrome and Microsoft Edge a few weeks later.
-```batch tab=bash-batch lang=js
-set PLAYWRIGHT_BROWSERS_PATH=%USERPROFILE%\pw-browsers
-npx playwright test
-```
+### Google Chrome & Microsoft Edge
-```powershell tab=bash-powershell lang=js
-$env:PLAYWRIGHT_BROWSERS_PATH="$env:USERPROFILE\pw-browsers"
-npx playwright test
-```
+While Playwright can download and use the recent Chromium build, it can operate against the branded Google Chrome and Microsoft Edge browsers available on the machine (note that Playwright doesn't install them by default). In particular, the current Playwright version will support Stable and Beta channels of these browsers.
-```bash tab=bash-bash lang=python
-# Linux/macOS
-PLAYWRIGHT_BROWSERS_PATH=$HOME/pw-browsers python playwright_script.py
-```
+Available channels are `chrome`, `msedge`, `chrome-beta`, `msedge-beta` or `msedge-dev`.
-```batch tab=bash-batch lang=python
-set PLAYWRIGHT_BROWSERS_PATH=%USERPROFILE%\pw-browsers
-python playwright_script.py
+```js
+import { defineConfig, devices } from '@playwright/test';
+
+export default defineConfig({
+ projects: [
+ /* Test against branded browsers. */
+ {
+ name: 'Google Chrome',
+ use: { ...devices['Desktop Chrome'], channel: 'chrome' }, // or 'chrome-beta'
+ },
+ {
+ name: 'Microsoft Edge',
+ use: { ...devices['Desktop Edge'], channel: 'msedge' }, // or "msedge-beta" or 'msedge-dev'
+ },
+ ],
+});
```
-```powershell tab=bash-powershell lang=python
+```java
+import com.microsoft.playwright.*;
-$env:PLAYWRIGHT_BROWSERS_PATH="$env:USERPROFILE\pw-browsers"
-python playwright_script.py
+public class Example {
+ public static void main(String[] args) {
+ try (Playwright playwright = Playwright.create()) {
+ // Channel can be "chrome", "msedge", "chrome-beta", "msedge-beta" or "msedge-dev".
+ Browser browser = playwright.chromium().launch(new BrowserType.LaunchOptions().setChannel("chrome"));
+ Page page = browser.newPage();
+ // ...
+ }
+ }
+}
```
-```bash tab=bash-bash lang=java
-PLAYWRIGHT_BROWSERS_PATH=$HOME/pw-browsers mvn test
+```bash python
+pytest test_login.py --browser-channel msedge
```
-```batch tab=bash-batch lang=java
-set PLAYWRIGHT_BROWSERS_PATH=%USERPROFILE%\pw-browsers
-mvn test
+```xml csharp
+<?xml version="1.0" encoding="utf-8"?>
+<RunSettings>
+ <Playwright>
+ <BrowserName>chromium</BrowserName>
+ <LaunchOptions>
+ <Channel>msedge</Channel>
+ </LaunchOptions>
+ </Playwright>
+</RunSettings>
```
-```powershell tab=bash-powershell lang=java
-$env:PLAYWRIGHT_BROWSERS_PATH="$env:USERPROFILE\pw-browsers"
-mvn test
+```csharp
+dotnet test -- Playwright.BrowserName=chromium Playwright.LaunchOptions.Channel=msedge
```
-```bash tab=bash-bash lang=csharp
-PLAYWRIGHT_BROWSERS_PATH=$HOME/pw-browsers dotnet test
+#### Installing Google Chrome & Microsoft Edge
+
+If Google Chrome or Microsoft Edge is not available on your machine, you can install
+them using the Playwright command line tool:
+
+```bash lang=js
+npx playwright install msedge
```
-```batch tab=bash-batch lang=csharp
-set PLAYWRIGHT_BROWSERS_PATH=%USERPROFILE%\pw-browsers
-dotnet test
+```bash lang=python
+playwright install msedge
```
-```powershell tab=bash-powershell lang=csharp
-$env:PLAYWRIGHT_BROWSERS_PATH="$env:USERPROFILE\pw-browsers"
-dotnet test
+```bash lang=csharp
+pwsh bin/Debug/netX/playwright.ps1 install msedge
```
-Playwright keeps track of packages that need those browsers and will garbage collect them as you update Playwright to the newer versions.
+```batch lang=java
+mvn exec:java -e -D exec.mainClass=com.microsoft.playwright.CLI -D exec.args="install msedge"
+```
-:::note
-Developers can opt-in in this mode via exporting `PLAYWRIGHT_BROWSERS_PATH=$HOME/pw-browsers` in their `.bashrc`.
+:::warning
+Google Chrome or Microsoft Edge installations will be installed at the
+default global location of your operating system overriding your current browser installation.
:::
-### Hermetic install
-* langs: js
+Run with the `--help` option to see a full a list of browsers that can be installed.
-You can opt into the hermetic install and place binaries in the local folder:
+#### When to use Google Chrome & Microsoft Edge and when not to?
+##### Defaults
-```bash tab=bash-bash
-# Places binaries to node_modules/playwright-core/.local-browsers
-PLAYWRIGHT_BROWSERS_PATH=0 npx playwright install
-```
+Using the default Playwright configuration with the latest Chromium is a good idea most of the time.
+Since Playwright is ahead of Stable channels for the browsers, it gives peace of mind that the
+upcoming Google Chrome or Microsoft Edge releases won't break your site. You catch breakage
+early and have a lot of time to fix it before the official Chrome update.
-```batch tab=bash-batch
-# Places binaries to node_modules\playwright-core\.local-browsers
-set PLAYWRIGHT_BROWSERS_PATH=0
-npx playwright install
-```
+##### Regression testing
-```powershell tab=bash-powershell
-# Places binaries to node_modules\playwright-core\.local-browsers
-$env:PLAYWRIGHT_BROWSERS_PATH=0
-npx playwright install
-```
+Having said that, testing policies often require regression testing to be performed against
+the current publicly available browsers. In this case, you can opt into one of the stable channels,
+`"chrome"` or `"msedge"`.
-:::note
-`PLAYWRIGHT_BROWSERS_PATH` does not change installation path for Google Chrome and Microsoft Edge.
-:::
+##### Media codecs
+
+Another reason for testing using official binaries is to test functionality related to media codecs.
+Chromium does not have all the codecs that Google Chrome or Microsoft Edge are bundling due to
+various licensing considerations and agreements. If your site relies on this kind of codecs (which is
+rarely the case), you will also want to use the official channel.
+
+##### Enterprise policy
+
+Google Chrome and Microsoft Edge respect enterprise policies, which include limitations to the capabilities, network proxy, mandatory extensions that stand in the way of testing. So if you are part of the organization that uses such policies, it is easiest to use bundled Chromium for your local testing, you can still opt into stable channels on the bots that are typically free of such restrictions.
+
+### Firefox
+
+Playwright's Firefox version matches the recent [Firefox Stable](https://www.mozilla.org/en-US/firefox/new/) build. Playwright doesn't work with the branded version of Firefox since it relies on patches. Instead you can test against the recent Firefox Stable build.
+### WebKit
+
+Playwright's WebKit version matches the recent WebKit trunk build, before it is used in Apple Safari and other WebKit-based browsers. This gives a lot of lead time to react on the potential browser update issues. Playwright doesn't work with the branded version of Safari since it relies on patches. Instead you can test against the recent Webkit build.
## Install behind a firewall or a proxy
-By default, Playwright downloads browsers from Microsoft CDN.
+By default, Playwright downloads browsers from Microsoft's 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.
@@ -519,10 +581,9 @@ pwsh bin/Debug/netX/playwright.ps1 install
$env:PLAYWRIGHT_DOWNLOAD_CONNECTION_TIMEOUT="120000"
pwsh bin/Debug/netX/playwright.ps1 install
```
-
## Download from artifact repository
-By default, Playwright downloads browsers from Microsoft CDN.
+By default, Playwright downloads browsers from Microsoft's CDN.
Sometimes companies maintain an internal artifact repository to host browser
binaries. In this case, Playwright can be configured to download from a custom
@@ -686,14 +747,199 @@ $env:PLAYWRIGHT_DOWNLOAD_HOST="192.0.2.1"
$env:PLAYWRIGHT_FIREFOX_DOWNLOAD_HOST="203.0.113.3"
pwsh bin/Debug/netX/playwright.ps1 install
```
+## Managing browser binaries
+
+Playwright downloads Chromium, WebKit and Firefox browsers into the OS-specific cache folders:
+
+- `%USERPROFILE%\AppData\Local\ms-playwright` on Windows
+- `~/Library/Caches/ms-playwright` on MacOS
+- `~/.cache/ms-playwright` on Linux
+
+These browsers will take a few hundred megabytes of disk space when installed:
+
+```bash
+du -hs ~/Library/Caches/ms-playwright/*
+281M chromium-XXXXXX
+187M firefox-XXXX
+180M webkit-XXXX
+```
+
+You can override default behavior using environment variables. When installing Playwright, ask it to download browsers into a specific location:
+
+```bash tab=bash-bash lang=js
+PLAYWRIGHT_BROWSERS_PATH=$HOME/pw-browsers npx playwright install
+```
+
+```batch tab=bash-batch lang=js
+set PLAYWRIGHT_BROWSERS_PATH=%USERPROFILE%\pw-browsers
+npx playwright install
+```
+
+```powershell tab=bash-powershell lang=js
+$env:PLAYWRIGHT_BROWSERS_PATH="$env:USERPROFILE\pw-browsers"
+npx playwright install
+```
+
+```bash tab=bash-bash lang=python
+pip install playwright
+PLAYWRIGHT_BROWSERS_PATH=$HOME/pw-browsers python -m playwright install
+```
+
+```batch tab=bash-batch lang=python
+set PLAYWRIGHT_BROWSERS_PATH=%USERPROFILE%\pw-browsers
+pip install playwright
+playwright install
+```
+
+```powershell tab=bash-powershell lang=python
+$env:PLAYWRIGHT_BROWSERS_PATH="$env:USERPROFILE\pw-browsers"
+pip install playwright
+playwright install
+```
+
+```bash tab=bash-bash lang=java
+PLAYWRIGHT_BROWSERS_PATH=$HOME/pw-browsers mvn exec:java -e -D exec.mainClass=com.microsoft.playwright.CLI -D exec.args="install"
+```
+
+```batch tab=bash-batch lang=java
+set PLAYWRIGHT_BROWSERS_PATH=%USERPROFILE%\pw-browsers
+mvn exec:java -e -D exec.mainClass=com.microsoft.playwright.CLI -D exec.args="install"
+```
+
+```powershell tab=bash-powershell lang=java
+$env:PLAYWRIGHT_BROWSERS_PATH="$env:USERPROFILE\pw-browsers"
+mvn exec:java -e -D exec.mainClass=com.microsoft.playwright.CLI -D exec.args="install"
+```
+
+```bash tab=bash-bash lang=csharp
+PLAYWRIGHT_BROWSERS_PATH=$HOME/pw-browsers
+pwsh bin/Debug/netX/playwright.ps1 install
+```
+
+```batch tab=bash-batch lang=csharp
+set PLAYWRIGHT_BROWSERS_PATH=%USERPROFILE%\pw-browsers
+pwsh bin/Debug/netX/playwright.ps1 install
+```
+
+```powershell tab=bash-powershell lang=csharp
+$env:PLAYWRIGHT_BROWSERS_PATH="$env:USERPROFILE\pw-browsers"
+pwsh bin/Debug/netX/playwright.ps1 install
+```
+
+When running Playwright scripts, ask it to search for browsers in a shared location.
+
+```bash tab=bash-bash lang=js
+PLAYWRIGHT_BROWSERS_PATH=$HOME/pw-browsers npx playwright test
+```
+
+```batch tab=bash-batch lang=js
+set PLAYWRIGHT_BROWSERS_PATH=%USERPROFILE%\pw-browsers
+npx playwright test
+```
+
+```powershell tab=bash-powershell lang=js
+$env:PLAYWRIGHT_BROWSERS_PATH="$env:USERPROFILE\pw-browsers"
+npx playwright test
+```
+
+```bash tab=bash-bash lang=python
+# Linux/macOS
+PLAYWRIGHT_BROWSERS_PATH=$HOME/pw-browsers python playwright_script.py
+```
+
+```batch tab=bash-batch lang=python
+set PLAYWRIGHT_BROWSERS_PATH=%USERPROFILE%\pw-browsers
+python playwright_script.py
+```
+
+```powershell tab=bash-powershell lang=python
+
+$env:PLAYWRIGHT_BROWSERS_PATH="$env:USERPROFILE\pw-browsers"
+python playwright_script.py
+```
-## Skip browser downloads
+```bash tab=bash-bash lang=java
+PLAYWRIGHT_BROWSERS_PATH=$HOME/pw-browsers mvn test
+```
+
+```batch tab=bash-batch lang=java
+set PLAYWRIGHT_BROWSERS_PATH=%USERPROFILE%\pw-browsers
+mvn test
+```
+
+```powershell tab=bash-powershell lang=java
+$env:PLAYWRIGHT_BROWSERS_PATH="$env:USERPROFILE\pw-browsers"
+mvn test
+```
+
+```bash tab=bash-bash lang=csharp
+PLAYWRIGHT_BROWSERS_PATH=$HOME/pw-browsers dotnet test
+```
+
+```batch tab=bash-batch lang=csharp
+set PLAYWRIGHT_BROWSERS_PATH=%USERPROFILE%\pw-browsers
+dotnet test
+```
+
+```powershell tab=bash-powershell lang=csharp
+$env:PLAYWRIGHT_BROWSERS_PATH="$env:USERPROFILE\pw-browsers"
+dotnet test
+```
+
+Playwright keeps track of packages that need those browsers and will garbage collect them as you update Playwright to the newer versions.
+
+:::note
+Developers can opt-in in this mode via exporting `PLAYWRIGHT_BROWSERS_PATH=$HOME/pw-browsers` in their `.bashrc`.
+:::
+
+### Hermetic install
+* langs: js
+
+You can opt into the hermetic install and place binaries in the local folder:
+
+
+```bash tab=bash-bash
+# Places binaries to node_modules/playwright-core/.local-browsers
+PLAYWRIGHT_BROWSERS_PATH=0 npx playwright install
+```
+
+```batch tab=bash-batch
+# Places binaries to node_modules\playwright-core\.local-browsers
+set PLAYWRIGHT_BROWSERS_PATH=0
+npx playwright install
+```
+
+```powershell tab=bash-powershell
+# Places binaries to node_modules\playwright-core\.local-browsers
+$env:PLAYWRIGHT_BROWSERS_PATH=0
+npx playwright install
+```
+
+:::note
+`PLAYWRIGHT_BROWSERS_PATH` does not change installation path for Google Chrome and Microsoft Edge.
+:::
+
+### Skip browser downloads
In certain cases, it is desired to avoid browser downloads altogether because
browser binaries are managed separately.
This can be done by setting `PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD` variable before installation.
+```bash tab=bash-bash lang=js
+PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 npx playwright install
+```
+
+```batch tab=bash-batch lang=js
+set PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1
+npx playwright install
+```
+
+```powershell tab=bash-powershell lang=js
+$env:PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1
+npx playwright install
+```
+
```bash tab=bash-bash lang=python
pip install playwright
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 python -m playwright install
@@ -739,20 +985,8 @@ $env:PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1
pwsh bin/Debug/netX/playwright.ps1 install
```
-## Download single browser binary
-* langs: python
-
-Playwright downloads Chromium, Firefox and WebKit browsers by default. To install a specific browser, pass it as an argument during installation.
-
-```bash
-pip install playwright
-playwright install firefox
-```
-
-## Stale browser removal
+### Stale browser removal
-Playwright 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 instances of
-different versions and at the same time, you don't waste disk space for the browsers that are no longer in use.
+Playwright keeps track of the clients that use its browsers. When there are no more clients that require a particular version of the browser, that version is deleted from the system. That way you can safely use Playwright 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.