docs: make environment vars snippets cross-platform (#2564)

This commit is contained in:
Arjun Attam 2020-06-13 13:11:39 -07:00 committed by GitHub
parent 6530c18acd
commit 2659910be8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 36 additions and 2 deletions

View file

@ -4420,10 +4420,19 @@ If Playwright doesn't find them in the environment, a lowercased variant of thes
- `PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD` - set to non-empty value to skip browser downloads altogether. - `PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD` - set to non-empty value to skip browser downloads altogether.
```sh ```sh
# Linux/macOS
# Install browsers to the shared location. # Install browsers to the shared location.
$ PLAYWRIGHT_BROWSERS_PATH=$HOME/playwright-browsers npm install --save-dev playwright $ PLAYWRIGHT_BROWSERS_PATH=$HOME/playwright-browsers npm install --save-dev playwright
# Use shared location to find browsers. # Use shared location to find browsers.
$ PLAYWRIGHT_BROWSERS_PATH=$HOME/playwright-browsers node playwright-script.js $ PLAYWRIGHT_BROWSERS_PATH=$HOME/playwright-browsers node playwright-script.js
# Windows
# Install browsers to the shared location.
$ set PLAYWRIGHT_BROWSERS_PATH=%USERPROFILE%\playwright-browsers
$ npm install --save-dev playwright
# Use shared location to find browsers.
$ set PLAYWRIGHT_BROWSERS_PATH=%USERPROFILE%\playwright-browsers
$ node playwright-script.js
``` ```

View file

@ -33,19 +33,34 @@ du -hs ./Library/Caches/ms-playwright/*
You can override default behavior using environment variables. When installing Playwright, ask it to download browsers into a specific location: You can override default behavior using environment variables. When installing Playwright, ask it to download browsers into a specific location:
```sh ```sh
# Linux/macOS
$ PLAYWRIGHT_BROWSERS_PATH=$HOME/pw-browsers npm i -D playwright $ PLAYWRIGHT_BROWSERS_PATH=$HOME/pw-browsers npm i -D playwright
# Windows
$ set PLAYWRIGHT_BROWSERS_PATH=%USERPROFILE%\pw-browsers
$ npm i -D playwright
``` ```
When running Playwright scripts, ask it to search for browsers in a shared location: When running Playwright scripts, ask it to search for browsers in a shared location:
```sh ```sh
# Linux/macOS
$ PLAYWRIGHT_BROWSERS_PATH=$HOME/pw-browsers node playwright-script.js $ PLAYWRIGHT_BROWSERS_PATH=$HOME/pw-browsers node playwright-script.js
# Windows
$ set PLAYWRIGHT_BROWSERS_PATH=%USERPROFILE%\pw-browsers
$ node playwright-script.js
``` ```
Or you can opt into the hermetic install and place binaries under the `node_modules/` folder: Or you can opt into the hermetic install and place binaries under the `node_modules/` folder:
```sh ```sh
$ PLAYWRIGHT_BROWSERS_PATH=0 node playwright-script.js # Linux/macOS
$ PLAYWRIGHT_BROWSERS_PATH=0 npm i -D playwright
# Windows
$ set PLAYWRIGHT_BROWSERS_PATH=0
$ npm i -D playwright
``` ```
Playwright keeps track of packages that need those browsers and will garbage collect them as you update Playwright to the newer versions. Playwright keeps track of packages that need those browsers and will garbage collect them as you update Playwright to the newer versions.
@ -65,7 +80,12 @@ binaries. In this case, Playwright can be configured to download from a custom
location using the `PLAYWRIGHT_DOWNLOAD_HOST` env variable. location using the `PLAYWRIGHT_DOWNLOAD_HOST` env variable.
```sh ```sh
# Linux/macOS
$ PLAYWRIGHT_DOWNLOAD_HOST=192.168.1.78 npm i -D playwright $ PLAYWRIGHT_DOWNLOAD_HOST=192.168.1.78 npm i -D playwright
# Windows
$ set PLAYWRIGHT_DOWNLOAD_HOST=192.168.1.78
$ npm i -D playwright
``` ```
<br> <br>
@ -78,7 +98,12 @@ browser binaries are managed separately.
This can be done by setting `PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD` variable before installation. This can be done by setting `PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD` variable before installation.
```sh ```sh
# Linux/macOS
$ PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 npm i -D playwright $ PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 npm i -D playwright
# Windows
$ set PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1
$ npm i -D playwright
``` ```
<br> <br>
@ -108,6 +133,6 @@ const { webkit } = require('playwright-webkit');
(async () => { (async () => {
const browser = await webkit.launch(); const browser = await webkit.launch();
// .... // ...
})(); })();
``` ```