docs: add tabs for shell scripts (#9289)

This commit is contained in:
Max Schmitt 2021-10-04 15:45:52 +02:00 committed by GitHub
parent 92c1aa20a7
commit a280a17157
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 169 additions and 129 deletions

View File

@ -225,109 +225,122 @@ 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:
```bash js
# Linux/macOS
```bash bash-flavor=bash lang=js
PLAYWRIGHT_BROWSERS_PATH=$HOME/pw-browsers npx playwright install
```
# Windows with cmd.exe
```bash bash-flavor=batch lang=js
set PLAYWRIGHT_BROWSERS_PATH=%USERPROFILE%\pw-browsers
npx playwright install
```
# Windows with PowerShell
```bash bash-flavor=powershell lang=js
$env:PLAYWRIGHT_BROWSERS_PATH="$env:USERPROFILE\pw-browsers"
npx playwright install
```
```bash python
# Linux/macOS
```bash bash-flavor=bash lang=python
pip install playwright
PLAYWRIGHT_BROWSERS_PATH=$HOME/pw-browsers python -m playwright install
```
# Windows with cmd.exe
```bash bash-flavor=batch lang=python
set PLAYWRIGHT_BROWSERS_PATH=%USERPROFILE%\pw-browsers
pip install playwright
playwright install
```
# Windows with PowerShell
```bash bash-flavor=powershell lang=python
$env:PLAYWRIGHT_BROWSERS_PATH="$env:USERPROFILE\pw-browsers"
pip install playwright
playwright install
```
```bash java
# Linux/macOS
```bash bash-flavor=bash lang=java
PLAYWRIGHT_BROWSERS_PATH=$HOME/pw-browsers mvn test
```
# Windows with cmd.exe
```bash bash-flavor=batch lang=java
set PLAYWRIGHT_BROWSERS_PATH=%USERPROFILE%\pw-browsers
mvn test
```
# Windows with PowerShell
```bash bash-flavor=powershell lang=java
$env:PLAYWRIGHT_BROWSERS_PATH="$env:USERPROFILE\pw-browsers"
mvn test
```
```bash csharp
# Linux/macOS
```bash bash-flavor=bash lang=csharp
PLAYWRIGHT_BROWSERS_PATH=$HOME/pw-browsers
playwright install
```
# Windows with cmd.exe
```bash bash-flavor=batch lang=csharp
set PLAYWRIGHT_BROWSERS_PATH=%USERPROFILE%\pw-browsers
playwright install
```
# Windows with PowerShell
```bash bash-flavor=powershell lang=csharp
$env:PLAYWRIGHT_BROWSERS_PATH="$env:USERPROFILE\pw-browsers"
playwright install
```
When running Playwright scripts, ask it to search for browsers in a shared location.
```bash js
# Linux/macOS
```bash bash-flavor=bash lang=js
PLAYWRIGHT_BROWSERS_PATH=$HOME/pw-browsers npx playwright test
```
# Windows with cmd.exe
```bash bash-flavor=batch lang=js
set PLAYWRIGHT_BROWSERS_PATH=%USERPROFILE%\pw-browsers
npx playwright test
```
# Windows with PowerShell
```bash bash-flavor=powershell lang=js
$env:PLAYWRIGHT_BROWSERS_PATH="$env:USERPROFILE\pw-browsers"
npx playwright test
```
```bash python
```bash bash-flavor=bash lang=python
# Linux/macOS
PLAYWRIGHT_BROWSERS_PATH=$HOME/pw-browsers python playwright_script.py
```
# Windows with cmd.exe
```bash bash-flavor=batch lang=python
set PLAYWRIGHT_BROWSERS_PATH=%USERPROFILE%\pw-browsers
python playwright_script.py
```
```bash bash-flavor=powershell lang=python
# Windows with PowerShell
$env:PLAYWRIGHT_BROWSERS_PATH="$env:USERPROFILE\pw-browsers"
python playwright_script.py
```
```bash java
# Windows with cmd.exe
```bash bash-flavor=bash lang=java
PLAYWRIGHT_BROWSERS_PATH=$HOME/pw-browsers mvn test
```
```bash bash-flavor=batch lang=java
set PLAYWRIGHT_BROWSERS_PATH=%USERPROFILE%\pw-browsers
mvn test
```
# Windows with PowerShell
```bash bash-flavor=powershell lang=java
$env:PLAYWRIGHT_BROWSERS_PATH="$env:USERPROFILE\pw-browsers"
mvn test
```
```bash csharp
# Linux/macOS
```bash bash-flavor=bash lang=csharp
PLAYWRIGHT_BROWSERS_PATH=$HOME/pw-browsers dotnet test
```
# Windows with cmd.exe
```bash bash-flavor=batch lang=csharp
set PLAYWRIGHT_BROWSERS_PATH=%USERPROFILE%\pw-browsers
dotnet test
```
# Windows with PowerShell
```bash bash-flavor=powershell lang=csharp
$env:PLAYWRIGHT_BROWSERS_PATH="$env:USERPROFILE\pw-browsers"
dotnet test
```
@ -343,17 +356,18 @@ Developers can opt-in in this mode via exporting `PLAYWRIGHT_BROWSERS_PATH=$HOME
You can opt into the hermetic install and place binaries in the local folder:
```bash
# Linux/macOS
```bash bash-flavor=bash
# Places binaries to node_modules/@playwright/test
PLAYWRIGHT_BROWSERS_PATH=0 npx playwright install
```
# Windows with cmd.exe
```bash bash-flavor=batch
# Places binaries to node_modules\@playwright\test
set PLAYWRIGHT_BROWSERS_PATH=0
npx playwright install
```
# Windows with PowerShell
```bash bash-flavor=powershell
# Places binaries to node_modules\@playwright\test
$env:PLAYWRIGHT_BROWSERS_PATH=0
npx playwright install
@ -366,44 +380,47 @@ By default, Playwright 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.
```bash python
# Linux/macOS
```bash bash-flavor=bash lang=python
pip install playwright
HTTPS_PROXY=https://192.0.2.1 playwright install
```
# Windows with cmd.exe
```bash bash-flavor=batch lang=python
set HTTPS_PROXY=https://192.0.2.1
pip install playwright
playwright install
```
# Windows with PowerShell
```bash bash-flavor=powershell lang=python
$env:HTTPS_PROXY="https://192.0.2.1"
pip install playwright
playwright install
```
```bash java
# Linux/macOS
```bash bash-flavor=bash lang=java
HTTPS_PROXY=https://192.0.2.1 mvn test
```
# Windows with cmd.exe
```bash bash-flavor=batch lang=java
set HTTPS_PROXY=https://192.0.2.1
mvn test
```
# Windows with PowerShell
```bash bash-flavor=powershell lang=java
$env:HTTPS_PROXY="https://192.0.2.1"
mvn test
```
```bash csharp
# Linux/macOS
```bash bash-flavor=bash lang=csharp
HTTPS_PROXY=https://192.0.2.1 playwright install
```
# Windows with cmd.exe
```bash bash-flavor=batch lang=csharp
set HTTPS_PROXY=https://192.0.2.1
playwright install
```
# Windows with PowerShell
```bash bash-flavor=powershell lang=csharp
$env:HTTPS_PROXY="https://192.0.2.1"
playwright install
```
@ -416,44 +433,48 @@ 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.
```bash python
# Linux/macOS
```bash bash-flavor=bash lang=python
pip install playwright
PLAYWRIGHT_DOWNLOAD_HOST=192.0.2.1 playwright install
# Windows with cmd.exe
```
```bash bash-flavor=batch lang=python
set PLAYWRIGHT_DOWNLOAD_HOST=192.0.2.1
pip install playwright
playwright install
```
# Windows with PowerShell
```bash bash-flavor=powershell lang=python
$env:PLAYWRIGHT_DOWNLOAD_HOST="192.0.2.1"
pip install playwright
playwright install
```
```bash java
# Linux/macOS
```bash bash-flavor=bash lang=java
PLAYWRIGHT_DOWNLOAD_HOST=192.0.2.1 mvn test
```
# Windows with cmd.exe
```bash bash-flavor=batch lang=java
set PLAYWRIGHT_DOWNLOAD_HOST=192.0.2.1
mvn test
```
# Windows with PowerShell
```bash bash-flavor=powershell lang=java
$env:PLAYWRIGHT_DOWNLOAD_HOST="192.0.2.1"
mvn test
```
```bash csharp
# Linux/macOS
```bash bash-flavor=bash lang=csharp
PLAYWRIGHT_DOWNLOAD_HOST=192.0.2.1 playwright install
```
# Windows with cmd.exe
```bash bash-flavor=batch lang=csharp
set PLAYWRIGHT_DOWNLOAD_HOST=192.0.2.1
playwright install
```
# Windows with PowerShell
```bash bash-flavor=powershell lang=csharp
$env:PLAYWRIGHT_DOWNLOAD_HOST="192.0.2.1"
playwright install
```
@ -484,44 +505,47 @@ browser binaries are managed separately.
This can be done by setting `PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD` variable before installation.
```bash python
# Linux/macOS
```bash bash-flavor=bash lang=python
pip install playwright
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 python -m playwright install
```
# Windows with cmd.exe
```bash bash-flavor=batch lang=python
set PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1
pip install playwright
playwright install
```
# Windows with PowerShell
```bash bash-flavor=powershell lang=python
$env:PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1
pip install playwright
playwright install
```
```bash java
# Linux/macOS
```bash bash-flavor=bash lang=java
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 mvn test
```
# Windows with cmd.exe
```bash bash-flavor=batch lang=java
set PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1
mvn test
```
# Windows with PowerShell
```bash bash-flavor=powershell lang=java
$env:PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1
mvn test
```
```bash csharp
# Linux/macOS
```bash bash-flavor=bash lang=csharp
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 playwright install
```
# Windows with cmd.exe
```bash bash-flavor=batch lang=csharp
set PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1
playwright install
```
# Windows with PowerShell
```bash bash-flavor=powershell lang=csharp
$env:PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1
playwright install
```

View File

@ -111,41 +111,44 @@ Using `PWDEBUG=console` will configure the browser for debugging in Developer to
[Playwright selectors](./selectors.md). This can be used to verify text or
composite selectors.
```bash js
# Linux/macOS
```bash bash-flavor=bash lang=js
PWDEBUG=console npm run test
```
# Windows with cmd.exe
```bash bash-flavor=batch lang=js
set PWDEBUG=console
npm run test
# Windows with PowerShell
$env:PWDEBUG="console"
npm run test
```
```bash java
# Linux/macOS
```bash bash-flavor=powershell lang=js
env:PWDEBUG="console"
npm run test
```
```bash bash-flavor=bash lang=java
PWDEBUG=console mvn test
```
# Windows with cmd.exe
```bash bash-flavor=batch lang=java
set PWDEBUG=console
mvn test
```
# Windows with PowerShell
```bash bash-flavor=powershell lang=java
$env:PWDEBUG="console"
mvn test
```
```bash python
# Linux/macOS
```bash bash-flavor=bash lang=python
PWDEBUG=console pytest -s
```
# Windows with cmd.exe
```bash bash-flavor=batch lang=python
set PWDEBUG=console
pytest -s
```
# Windows with PowerShell
```bash bash-flavor=powershell lang=python
$env:PWDEBUG="console"
pytest -s
```
@ -190,54 +193,58 @@ breakpoints.
Playwright supports verbose logging with the `DEBUG` environment variable.
```bash js
# Linux/macOS
```bash bash-flavor=bash lang=js
DEBUG=pw:api npm run test
```
# Windows with cmd.exe
```bash bash-flavor=batch lang=js
set DEBUG=pw:api
npm run test
```
# Windows with PowerShell
```bash bash-flavor=powershell lang=js
$env:DEBUG="pw:api"
npm run test
```
```bash java
# Linux/macOS
```bash bash-flavor=bash lang=java
DEBUG=pw:api mvn test
```
# Windows with cmd.exe
```bash bash-flavor=batch lang=java
set DEBUG=pw:api
mvn test
```
# Windows with PowerShell
```bash bash-flavor=powershell lang=java
$env:DEBUG="pw:api"
mvn test
```
```bash python
# Linux/macOS
```bash bash-flavor=bash lang=python
DEBUG=pw:api pytest -s
```
# Windows with cmd.exe
```bash bash-flavor=batch lang=python
set DEBUG=pw:api
pytest -s
```
# Windows with PowerShell
```bash bash-flavor=powershell lang=python
$env:DEBUG="pw:api"
pytest -s
```
```bash csharp
# Linux/macOS
```bash bash-flavor=bash lang=csharp
DEBUG=pw:api dotnet run
```
# Windows with cmd.exe
```bash bash-flavor=batch lang=csharp
set DEBUG=pw:api
dotnet run
```
# Windows with PowerShell
```bash bash-flavor=powershell lang=csharp
$env:DEBUG="pw:api"
dotnet run
```
```

View File

@ -15,43 +15,47 @@ There are several ways of opening Playwright Inspector:
- Set the `PWDEBUG` environment variable to run your scripts in debug mode. This
configures Playwright for debugging and opens the inspector.
```bash js
# Linux/macOS
PWDEBUG=1 npm run test
# Windows with cmd.exe
```bash bash-flavor=bash lang=js
PWDEBUG=1 npm run test
```
```bash bash-flavor=batch lang=js
set PWDEBUG=1
npm run test
```
# Windows with PowerShell
```bash bash-flavor=powershell lang=js
$env:PWDEBUG=1
npm run test
```
```bash java
# Linux/macOS
```bash bash-flavor=bash lang=java
PWDEBUG=1 PLAYWRIGHT_JAVA_SRC=<java src root> mvn test
```
# Windows with cmd.exe
```bash bash-flavor=batch lang=java
set PLAYWRIGHT_JAVA_SRC=<java src root>
set PWDEBUG=1
mvn test
```
# Windows with PowerShell
```bash bash-flavor=powershell lang=java
$env:PLAYWRIGHT_JAVA_SRC="<java src root>"
$env:PWDEBUG=1
mvn test
```
```bash python
# Linux/macOS
```bash bash-flavor=bash lang=python
PWDEBUG=1 pytest -s
```
# Windows with cmd.exe
```bash bash-flavor=batch lang=python
set PWDEBUG=1
pytest -s
```
# Windows with PowerShell
```bash bash-flavor=powershell lang=python
$env:PWDEBUG=1
pytest -s
```

View File

@ -155,17 +155,18 @@ with sync_playwright() as p:
If you want to bundle browsers with the executables:
```bash
# Linux/macOS
```bash bash-flavor=bash
PLAYWRIGHT_BROWSERS_PATH=0 playwright install chromium
pyinstaller -F main.py
```
# Windows with cmd.exe
```bash bash-flavor=batch
set PLAYWRIGHT_BROWSERS_PATH=0
playwright install chromium
pyinstaller -F main.py
```
# Windows with PowerShell
```bash bash-flavor=powershell
$env:PLAYWRIGHT_BROWSERS_PATH="0"
playwright install chromium
pyinstaller -F main.py

View File

@ -263,15 +263,17 @@ Running 124 tests using 6 workers
JSON reporter produces an object with all information about the test run. It is usually used together with some terminal reporter like `dot` or `line`.
Most likely you want to write the JSON to a file. When running with `--reporter=json`, use `PLAYWRIGHT_JSON_OUTPUT_NAME` environment variable:
```bash
# Linux/macOS
PLAYWRIGHT_JSON_OUTPUT_NAME=results.json npx playwright test --reporter=json,dot
# Windows with cmd.exe
```bash bash-flavor=bash
PLAYWRIGHT_JSON_OUTPUT_NAME=results.json npx playwright test --reporter=json,dot
```
```bash bash-flavor=batch
set PLAYWRIGHT_JSON_OUTPUT_NAME=results.json
npx playwright test --reporter=json,dot
```
# Windows with PowerShell
```bash bash-flavor=powershell
$env:PLAYWRIGHT_JSON_OUTPUT_NAME="results.json"
npx playwright test --reporter=json,dot
```
@ -304,15 +306,17 @@ export default config;
JUnit reporter produces a JUnit-style xml report. It is usually used together with some terminal reporter like `dot` or `line`.
Most likely you want to write the report to an xml file. When running with `--reporter=junit`, use `PLAYWRIGHT_JUNIT_OUTPUT_NAME` environment variable:
```bash
# Linux/macOS
PLAYWRIGHT_JUNIT_OUTPUT_NAME=results.xml npx playwright test --reporter=junit,line
# Windows with cmd.exe
```bash bash-flavor=bash
PLAYWRIGHT_JUNIT_OUTPUT_NAME=results.xml npx playwright test --reporter=junit,line
```
```bash bash-flavor=batch
set PLAYWRIGHT_JUNIT_OUTPUT_NAME=results.xml
npx playwright test --reporter=junit,line
```
# Windows with PowerShell
```bash bash-flavor=powershell
$env:PLAYWRIGHT_JUNIT_OUTPUT_NAME="results.xml"
npx playwright test --reporter=junit,line
```