From c9c67709295790497fffa854cc508b679dcaa88c Mon Sep 17 00:00:00 2001 From: Arjun Attam Date: Fri, 12 Jun 2020 17:26:25 -0700 Subject: [PATCH] docs: make environment vars snippets cross-platform --- docs/api.md | 9 +++++++++ docs/installation.md | 29 +++++++++++++++++++++++++++-- 2 files changed, 36 insertions(+), 2 deletions(-) diff --git a/docs/api.md b/docs/api.md index 2bc64ca19f2b9..2f69fcf64ce41 100644 --- a/docs/api.md +++ b/docs/api.md @@ -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. ```sh +# Linux/macOS # Install browsers to the shared location. $ PLAYWRIGHT_BROWSERS_PATH=$HOME/playwright-browsers npm install --save-dev playwright # Use shared location to find browsers. $ 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 ``` diff --git a/docs/installation.md b/docs/installation.md index 28634274691c1..e37a0ea383a99 100644 --- a/docs/installation.md +++ b/docs/installation.md @@ -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: ```sh +# Linux/macOS $ 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: ```sh +# Linux/macOS $ 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: ```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. @@ -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. ```sh +# Linux/macOS $ PLAYWRIGHT_DOWNLOAD_HOST=192.168.1.78 npm i -D playwright + +# Windows +$ set PLAYWRIGHT_DOWNLOAD_HOST=192.168.1.78 +$ npm i -D playwright ```
@@ -78,7 +98,12 @@ browser binaries are managed separately. This can be done by setting `PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD` variable before installation. ```sh +# Linux/macOS $ PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 npm i -D playwright + +# Windows +$ set PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 +$ npm i -D playwright ```
@@ -108,6 +133,6 @@ const { webkit } = require('playwright-webkit'); (async () => { const browser = await webkit.launch(); - // .... + // ... })(); ```