From f629cbe053b7c35fa15d45812cba325aabeb8ad1 Mon Sep 17 00:00:00 2001 From: Max Schmitt Date: Tue, 25 May 2021 07:10:22 +0200 Subject: [PATCH] docs: provide examples for PowerShell when settings env vars (#6718) --- docs/src/debug.md | 45 ++++++++++++++--- docs/src/inspector.md | 19 ++++++-- docs/src/installation.md | 102 +++++++++++++++++++++++++++++++++------ 3 files changed, 140 insertions(+), 26 deletions(-) diff --git a/docs/src/debug.md b/docs/src/debug.md index e9253b6449..2e81e1c9ca 100644 --- a/docs/src/debug.md +++ b/docs/src/debug.md @@ -109,27 +109,39 @@ composite selectors. # Linux/macOS PWDEBUG=console npm run test -# Windows +# Windows with cmd.exe set PWDEBUG=console npm run test + +# Windows with PowerShell +$env:PWDEBUG="console" +npm run test ``` ```sh java # Linux/macOS PWDEBUG=console mvn test -# Windows +# Windows with cmd.exe set PWDEBUG=console mvn test + +# Windows with PowerShell +$env:PWDEBUG="console" +mvn test ``` ```sh python # Linux/macOS PWDEBUG=console pytest -s -# Windows +# Windows with cmd.exe set PWDEBUG=console pytest -s + +# Windows with PowerShell +$env:PWDEBUG="console" +pytest -s ``` ## Selectors in Developer Tools Console @@ -176,31 +188,50 @@ Playwright supports verbose logging with the `DEBUG` environment variable. # Linux/macOS DEBUG=pw:api npm run test -# Windows +# Windows with cmd.exe set DEBUG=pw:api npm run test + +# Windows with PowerShell +$env:DEBUG="pw:api" +npm run test ``` ```sh java # Linux/macOS DEBUG=pw:api mvn test -# Windows +# Windows with cmd.exe set DEBUG=pw:api mvn test + +# Windows with PowerShell +$env:DEBUG="pw:api" +mvn test ``` ```sh python # Linux/macOS DEBUG=pw:api pytest -s -# Windows +# Windows with cmd.exe set DEBUG=pw:api pytest -s + +# Windows with PowerShell +$env:DEBUG="pw:api" +pytest -s ``` ```sh csharp -# Powershell (Win/macOS) +# Linux/macOS +DEBUG=pw:api dotnet run + +# Windows with cmd.exe +set DEBUG=pw:api +dotnet run + +# Windows with PowerShell $env:DEBUG="pw:api" dotnet run ``` \ No newline at end of file diff --git a/docs/src/inspector.md b/docs/src/inspector.md index 15c8c90190..4c260ff3f1 100644 --- a/docs/src/inspector.md +++ b/docs/src/inspector.md @@ -19,28 +19,41 @@ configures Playwright for debugging and opens the inspector. # Linux/macOS PWDEBUG=1 npm run test - # Windows + # Windows with cmd.exe set PWDEBUG=1 npm run test + + # Windows with PowerShell + $env:PWDEBUG=1 + npm run test ``` ```sh java # Linux/macOS PWDEBUG=1 PLAYWRIGHT_JAVA_SRC= mvn test - # Windows + # Windows with cmd.exe set PLAYWRIGHT_JAVA_SRC= set PWDEBUG=1 mvn test + + # Windows with PowerShell + $env:PLAYWRIGHT_JAVA_SRC="" + $env:PWDEBUG=1 + mvn test ``` ```sh python # Linux/macOS PWDEBUG=1 pytest -s - # Windows + # Windows with cmd.exe set PWDEBUG=1 pytest -s + + # Windows with PowerShell + $env:PWDEBUG=1 + pytest -s ``` Additional useful defaults are configured when `PWDEBUG=1` is set: diff --git a/docs/src/installation.md b/docs/src/installation.md index 3c49a5ea8b..7cc27aaf84 100644 --- a/docs/src/installation.md +++ b/docs/src/installation.md @@ -37,9 +37,13 @@ You can override default behavior using environment variables. When installing P # Linux/macOS PLAYWRIGHT_BROWSERS_PATH=$HOME/pw-browsers npm i -D playwright -# Windows +# Windows with cmd.exe set PLAYWRIGHT_BROWSERS_PATH=%USERPROFILE%\pw-browsers npm i -D playwright + +# Windows with PowerShell +$env:PLAYWRIGHT_BROWSERS_PATH="$env:USERPROFILE\pw-browsers" +npm i -D playwright ``` ```sh python @@ -47,10 +51,15 @@ npm i -D playwright pip install playwright PLAYWRIGHT_BROWSERS_PATH=$HOME/pw-browsers python -m playwright install -# Windows +# Windows with cmd.exe set PLAYWRIGHT_BROWSERS_PATH=%USERPROFILE%\pw-browsers pip install playwright playwright install + +# Windows with PowerShell +$env:PLAYWRIGHT_BROWSERS_PATH="$env:USERPROFILE\pw-browsers" +pip install playwright +playwright install ``` ```sh java @@ -64,24 +73,36 @@ When running Playwright scripts, ask it to search for browsers in a shared locat # Linux/macOS PLAYWRIGHT_BROWSERS_PATH=$HOME/pw-browsers node playwright-script.js -# Windows +# Windows with cmd.exe set PLAYWRIGHT_BROWSERS_PATH=%USERPROFILE%\pw-browsers node playwright-script.js + +# Windows with PowerShell +$env:PLAYWRIGHT_BROWSERS_PATH="$env:USERPROFILE\pw-browsers" +node playwright-script.js ``` ```sh python # Linux/macOS PLAYWRIGHT_BROWSERS_PATH=$HOME/pw-browsers python playwright_script.js -# Windows +# Windows with cmd.exe set PLAYWRIGHT_BROWSERS_PATH=%USERPROFILE%\pw-browsers python playwright_script.py + +# Windows with PowerShell +$env:PLAYWRIGHT_BROWSERS_PATH="$env:USERPROFILE\pw-browsers" +python playwright_script.py ``` ```sh java -# Windows +# Windows with cmd.exe set PLAYWRIGHT_BROWSERS_PATH=%USERPROFILE%\pw-browsers mvn test + +# Windows with PowerShell +$env:PLAYWRIGHT_BROWSERS_PATH="$env:USERPROFILE\pw-browsers" +mvn test ``` Or you can opt into the hermetic install and place binaries in the local folder: @@ -91,10 +112,15 @@ Or you can opt into the hermetic install and place binaries in the local folder: # Places binaries to node_modules/playwright PLAYWRIGHT_BROWSERS_PATH=0 npm i -D playwright -# Windows +# Windows with cmd.exe # Places binaries to node_modules\playwright set PLAYWRIGHT_BROWSERS_PATH=0 npm i -D playwright + +# Windows with PowerShell +# Places binaries to node_modules\playwright +$env:PLAYWRIGHT_BROWSERS_PATH=0 +npm i -D playwright ``` ```sh python @@ -102,10 +128,15 @@ npm i -D playwright pip install playwright PLAYWRIGHT_BROWSERS_PATH=0 playwright install -# Windows +# Windows with cmd.exe set PLAYWRIGHT_BROWSERS_PATH=0 pip install playwright playwright install + +# Windows with PowerShell +$env:PLAYWRIGHT_BROWSERS_PATH=0 +pip install playwright +playwright install ``` Playwright keeps track of packages that need those browsers and will garbage collect them as you update Playwright to the newer versions. @@ -125,9 +156,13 @@ resources. In this case, Playwright can be configured to download browsers via a # Linux/macOS HTTPS_PROXY=https://192.168.1.78 npm i -D playwright -# Windows +# Windows with cmd.exe set HTTPS_PROXY=https://192.168.1.78 npm i -D playwright + +# Windows with PowerShell +$env:HTTPS_PROXY="https://192.168.1.78" +npm i -D playwright ``` ```sh python @@ -135,19 +170,28 @@ npm i -D playwright pip install playwright HTTPS_PROXY=https://192.168.1.78 playwright install -# Windows +# Windows with cmd.exe set HTTPS_PROXY=https://192.168.1.78 pip install playwright playwright install + +# Windows with PowerShell +$env:HTTPS_PROXY="https://192.168.1.78" +pip install playwright +playwright install ``` ```sh java # Linux/macOS HTTPS_PROXY=https://192.168.1.78 mvn test -# Windows +# Windows with cmd.exe set HTTPS_PROXY=https://192.168.1.78 mvn test + +# Windows with PowerShell +$env:HTTPS_PROXY="https://192.168.1.78" +mvn test ``` ## Download from artifact repository @@ -162,9 +206,13 @@ location using the `PLAYWRIGHT_DOWNLOAD_HOST` env variable. # Linux/macOS PLAYWRIGHT_DOWNLOAD_HOST=192.168.1.78 npm i -D playwright -# Windows +# Windows with cmd.exe set PLAYWRIGHT_DOWNLOAD_HOST=192.168.1.78 npm i -D playwright + +# Windows with PowerShell +$env:PLAYWRIGHT_DOWNLOAD_HOST="192.168.1.78" +npm i -D playwright ``` ```sh python @@ -172,19 +220,28 @@ npm i -D playwright pip install playwright PLAYWRIGHT_DOWNLOAD_HOST=192.168.1.78 playwright install -# Windows +# Windows with cmd.exe set PLAYWRIGHT_DOWNLOAD_HOST=192.168.1.78 pip install playwright playwright install + +# Windows with PowerShell +$env:PLAYWRIGHT_DOWNLOAD_HOST="192.168.1.78" +pip install playwright +playwright install ``` ```sh java # Linux/macOS PLAYWRIGHT_DOWNLOAD_HOST=192.168.1.78 mvn test -# Windows +# Windows with cmd.exe set PLAYWRIGHT_DOWNLOAD_HOST=192.168.1.78 mvn test + +# Windows with PowerShell +$env:PLAYWRIGHT_DOWNLOAD_HOST="192.168.1.78" +mvn test ``` It is also possible to use a per-browser download hosts using `PLAYWRIGHT_CHROMIUM_DOWNLOAD_HOST`, `PLAYWRIGHT_FIREFOX_DOWNLOAD_HOST` and `PLAYWRIGHT_WEBKIT_DOWNLOAD_HOST` env variables that @@ -219,9 +276,13 @@ This can be done by setting `PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD` variable before i # Linux/macOS PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 npm i -D playwright -# Windows +# Windows with cmd.exe set PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 npm i -D playwright + +# Windows with PowerShell +$env:PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 +npm i -D playwright ``` ```sh python @@ -229,19 +290,28 @@ npm i -D playwright pip install playwright PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 python -m playwright install -# Windows +# Windows with cmd.exe set PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 pip install playwright playwright install + +# Windows with PowerShell +$env:PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 +pip install playwright +playwright install ``` ```sh java # Linux/macOS PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 mvn test -# Windows +# Windows with cmd.exe set PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 mvn test + +# Windows with PowerShell +$env:PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 +mvn test ``` ## Download single browser binary