Skip to content

Commit

Permalink
chery-pick(docs): sync with ToT docs (#16533)
Browse files Browse the repository at this point in the history
This PR cherry-picks the following commits:

- b089d0a
- 13f210a
- 2bdf51d
- 32adf50
- 4352722
- 8170432
  • Loading branch information
playwrightmachine committed Aug 15, 2022
1 parent 3bc6b4b commit 3401463
Show file tree
Hide file tree
Showing 19 changed files with 212 additions and 133 deletions.
38 changes: 19 additions & 19 deletions docs/src/browsers.md
Expand Up @@ -134,27 +134,27 @@ you can still opt into stable channels on the bots that are typically free of su
To invoke Playwright CLI commands, you need to invoke a PowerShell script:

```bash
pwsh bin\Debug\netX\playwright.ps1 --help
pwsh bin/Debug/netX/playwright.ps1 --help
```

Playwright can install supported browsers by means of the CLI tool.

```bash csharp
# Running without arguments will install all browsers
pwsh bin\Debug\netX\playwright.ps1 install
pwsh bin/Debug/netX/playwright.ps1 install
```

You can also install specific browsers by providing an argument:

```bash csharp
# Install WebKit
pwsh bin\Debug\netX\playwright.ps1 install webkit
pwsh bin/Debug/netX/playwright.ps1 install webkit
```

See all supported browsers:

```bash csharp
pwsh bin\Debug\netX\playwright.ps1 install --help
pwsh bin/Debug/netX/playwright.ps1 install --help
```

## Install browsers via API
Expand Down Expand Up @@ -236,17 +236,17 @@ mvn test

```bash tab=bash-bash lang=csharp
PLAYWRIGHT_BROWSERS_PATH=$HOME/pw-browsers
pwsh bin\Debug\netX\playwright.ps1 install
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
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
pwsh bin/Debug/netX/playwright.ps1 install
```

When running Playwright scripts, ask it to search for browsers in a shared location.
Expand Down Expand Up @@ -405,17 +405,17 @@ mvn test
```

```bash tab=bash-bash lang=csharp
HTTPS_PROXY=https://192.0.2.1 pwsh bin\Debug\netX\playwright.ps1 install
HTTPS_PROXY=https://192.0.2.1 pwsh bin/Debug/netX/playwright.ps1 install
```

```batch tab=bash-batch lang=csharp
set HTTPS_PROXY=https://192.0.2.1
pwsh bin\Debug\netX\playwright.ps1 install
pwsh bin/Debug/netX/playwright.ps1 install
```

```powershell tab=bash-powershell lang=csharp
$env:HTTPS_PROXY="https://192.0.2.1"
pwsh bin\Debug\netX\playwright.ps1 install
pwsh bin/Debug/netX/playwright.ps1 install
```

If the requests of the proxy get intercepted with a custom untrusted certificate authority (CA) and it yields to `Error: self signed certificate in certificate chain` while downloading the browsers, you must set your custom root certificates via the [`NODE_EXTRA_CA_CERTS`](https://nodejs.org/api/cli.html#node_extra_ca_certsfile) environment variable before installing the browsers:
Expand Down Expand Up @@ -500,17 +500,17 @@ mvn test
```

```bash tab=bash-bash lang=csharp
PLAYWRIGHT_DOWNLOAD_HOST=192.0.2.1 pwsh bin\Debug\netX\playwright.ps1 install
PLAYWRIGHT_DOWNLOAD_HOST=192.0.2.1 pwsh bin/Debug/netX/playwright.ps1 install
```

```batch tab=bash-batch lang=csharp
set PLAYWRIGHT_DOWNLOAD_HOST=192.0.2.1
pwsh bin\Debug\netX\playwright.ps1 install
pwsh bin/Debug/netX/playwright.ps1 install
```

```powershell tab=bash-powershell lang=csharp
$env:PLAYWRIGHT_DOWNLOAD_HOST="192.0.2.1"
pwsh bin\Debug\netX\playwright.ps1 install
pwsh bin/Debug/netX/playwright.ps1 install
```

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
Expand Down Expand Up @@ -584,19 +584,19 @@ mvn test
```

```bash tab=bash-bash lang=csharp
PLAYWRIGHT_FIREFOX_DOWNLOAD_HOST=203.0.113.3 PLAYWRIGHT_DOWNLOAD_HOST=192.0.2.1 pwsh bin\Debug\netX\playwright.ps1 install
PLAYWRIGHT_FIREFOX_DOWNLOAD_HOST=203.0.113.3 PLAYWRIGHT_DOWNLOAD_HOST=192.0.2.1 pwsh bin/Debug/netX/playwright.ps1 install
```

```batch tab=bash-batch lang=csharp
set PLAYWRIGHT_FIREFOX_DOWNLOAD_HOST=203.0.113.3
set PLAYWRIGHT_DOWNLOAD_HOST=192.0.2.1
pwsh bin\Debug\netX\playwright.ps1 install
pwsh bin/Debug/netX/playwright.ps1 install
```

```powershell tab=bash-powershell lang=csharp
$env:PLAYWRIGHT_DOWNLOAD_HOST="192.0.2.1"
$env:PLAYWRIGHT_FIREFOX_DOWNLOAD_HOST="203.0.113.3"
pwsh bin\Debug\netX\playwright.ps1 install
pwsh bin/Debug/netX/playwright.ps1 install
```

## Skip browser downloads
Expand Down Expand Up @@ -638,17 +638,17 @@ mvn test
```

```bash tab=bash-bash lang=csharp
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 pwsh bin\Debug\netX\playwright.ps1 install
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 pwsh bin/Debug/netX/playwright.ps1 install
```

```batch tab=bash-batch lang=csharp
set PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1
pwsh bin\Debug\netX\playwright.ps1 install
pwsh bin/Debug/netX/playwright.ps1 install
```

```powershell tab=bash-powershell lang=csharp
$env:PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1
pwsh bin\Debug\netX\playwright.ps1 install
pwsh bin/Debug/netX/playwright.ps1 install
```

## Download single browser binary
Expand Down
2 changes: 1 addition & 1 deletion docs/src/ci.md
Expand Up @@ -32,7 +32,7 @@ configurations for common CI providers.
mvn exec:java -e -Dexec.mainClass=com.microsoft.playwright.CLI -Dexec.args="install --with-deps"
```
```bash csharp
pwsh bin\Debug\netX\playwright.ps1 install --with-deps
pwsh bin/Debug/netX/playwright.ps1 install --with-deps
```

1. **Run your tests**:
Expand Down
38 changes: 19 additions & 19 deletions docs/src/cli.md
Expand Up @@ -23,7 +23,7 @@ playwright

```bash csharp
# Use the tools.
pwsh bin\Debug\netX\playwright.ps1 --help
pwsh bin/Debug/netX/playwright.ps1 --help
```

```json js
Expand Down Expand Up @@ -56,7 +56,7 @@ playwright install

```bash csharp
# Running without arguments will install default browsers
pwsh bin\Debug\netX\playwright.ps1 install
pwsh bin/Debug/netX/playwright.ps1 install
```

You can also install specific browsers by providing an argument:
Expand All @@ -78,7 +78,7 @@ playwright install webkit

```bash csharp
# Install WebKit
pwsh bin\Debug\netX\playwright.ps1 install webkit
pwsh bin/Debug/netX/playwright.ps1 install webkit
```

See all supported browsers:
Expand All @@ -96,7 +96,7 @@ playwright install --help
```

```bash csharp
pwsh bin\Debug\netX\playwright.ps1 install --help
pwsh bin/Debug/netX/playwright.ps1 install --help
```

## Install system dependencies
Expand All @@ -120,7 +120,7 @@ playwright install-deps

```bash csharp
# See command help
pwsh bin\Debug\netX\playwright.ps1 install-deps
pwsh bin/Debug/netX/playwright.ps1 install-deps
```

You can also install the dependencies for a single browser only by passing it as an argument:
Expand All @@ -138,7 +138,7 @@ playwright install-deps chromium
```

```bash csharp
pwsh bin\Debug\netX\playwright.ps1 install-deps chromium
pwsh bin/Debug/netX/playwright.ps1 install-deps chromium
```

It's also possible to combine `install-deps` with `install` and install by that the browsers and OS dependencies with a single command. This would do both for Chromium, but you can also leave it out.
Expand All @@ -156,7 +156,7 @@ playwright install --with-deps chromium
```

```bash csharp
pwsh bin\Debug\netX\playwright.ps1 install --with-deps chromium
pwsh bin/Debug/netX/playwright.ps1 install --with-deps chromium
```

## Generate code
Expand All @@ -174,7 +174,7 @@ playwright codegen wikipedia.org
```

```bash csharp
pwsh bin\Debug\netX\playwright.ps1 codegen wikipedia.org
pwsh bin/Debug/netX/playwright.ps1 codegen wikipedia.org
```

Run `codegen` and perform actions in the browser. Playwright CLI will generate JavaScript code for the user interactions. `codegen` will attempt to generate resilient text-based selectors.
Expand Down Expand Up @@ -204,7 +204,7 @@ playwright codegen --save-storage=auth.json
```

```bash csharp
pwsh bin\Debug\netX\playwright.ps1 codegen --save-storage=auth.json
pwsh bin/Debug/netX/playwright.ps1 codegen --save-storage=auth.json
# Perform authentication and exit.
# auth.json will contain the storage state.
```
Expand All @@ -231,8 +231,8 @@ playwright codegen --load-storage=auth.json my.web.app
```

```bash csharp
pwsh bin\Debug\netX\playwright.ps1 open --load-storage=auth.json my.web.app
pwsh bin\Debug\netX\playwright.ps1 codegen --load-storage=auth.json my.web.app
pwsh bin/Debug/netX/playwright.ps1 open --load-storage=auth.json my.web.app
pwsh bin/Debug/netX/playwright.ps1 codegen --load-storage=auth.json my.web.app
# Perform actions in authenticated state.
```

Expand Down Expand Up @@ -351,7 +351,7 @@ playwright open example.com

```bash csharp
# Open page in Chromium
pwsh bin\Debug\netX\playwright.ps1 open example.com
pwsh bin/Debug/netX/playwright.ps1 open example.com
```

```bash js
Expand All @@ -371,7 +371,7 @@ playwright wk example.com

```bash csharp
# Open page in WebKit
pwsh bin\Debug\netX\playwright.ps1 wk example.com
pwsh bin/Debug/netX/playwright.ps1 wk example.com
```

### Emulate devices
Expand All @@ -394,7 +394,7 @@ playwright open --device="iPhone 11" wikipedia.org

```bash csharp
# Emulate iPhone 11.
pwsh bin\Debug\netX\playwright.ps1 open --device="iPhone 11" wikipedia.org
pwsh bin/Debug/netX/playwright.ps1 open --device="iPhone 11" wikipedia.org
```

### Emulate color scheme and viewport size
Expand All @@ -416,7 +416,7 @@ playwright open --viewport-size=800,600 --color-scheme=dark twitter.com

```bash csharp
# Emulate screen size and color scheme.
pwsh bin\Debug\netX\playwright.ps1 open --viewport-size=800,600 --color-scheme=dark twitter.com
pwsh bin/Debug/netX/playwright.ps1 open --viewport-size=800,600 --color-scheme=dark twitter.com
```

### Emulate geolocation, language and timezone
Expand All @@ -442,7 +442,7 @@ playwright open --timezone="Europe/Rome" --geolocation="41.890221,12.492348" --l
```bash csharp
# Emulate timezone, language & location
# Once page opens, click the "my location" button to see geolocation in action
pwsh bin\Debug\netX\playwright.ps1 open --timezone="Europe/Rome" --geolocation="41.890221,12.492348" --lang="it-IT" maps.google.com
pwsh bin/Debug/netX/playwright.ps1 open --timezone="Europe/Rome" --geolocation="41.890221,12.492348" --lang="it-IT" maps.google.com
```

## Inspect selectors
Expand Down Expand Up @@ -542,7 +542,7 @@ playwright screenshot \

```bash csharp
# Wait 3 seconds before capturing a screenshot after page loads ('load' event fires)
pwsh bin\Debug\netX\playwright.ps1 screenshot \
pwsh bin/Debug/netX/playwright.ps1 screenshot \
--device="iPhone 11" \
--color-scheme=dark \
--wait-for-timeout=3000 \
Expand All @@ -566,7 +566,7 @@ playwright screenshot --full-page en.wikipedia.org wiki-full.png

```bash csharp
# Capture a full page screenshot
pwsh bin\Debug\netX\playwright.ps1 screenshot --full-page en.wikipedia.org wiki-full.png
pwsh bin/Debug/netX/playwright.ps1 screenshot --full-page en.wikipedia.org wiki-full.png
```

## Generate PDF
Expand All @@ -590,5 +590,5 @@ playwright pdf https://en.wikipedia.org/wiki/PDF wiki.pdf

```bash csharp
# See command help
pwsh bin\Debug\netX\playwright.ps1 pdf https://en.wikipedia.org/wiki/PDF wiki.pdf
pwsh bin/Debug/netX/playwright.ps1 pdf https://en.wikipedia.org/wiki/PDF wiki.pdf
```
2 changes: 1 addition & 1 deletion docs/src/codegen-intro.md
Expand Up @@ -25,7 +25,7 @@ playwright codegen playwright.dev
```

```bash csharp
pwsh bin\Debug\netX\playwright.ps1 codegen playwright.dev
pwsh bin/Debug/netX/playwright.ps1 codegen playwright.dev
```

Run `codegen` and perform actions in the browser. Playwright will generate the code for the user interactions. `Codegen` will attempt to generate resilient text-based selectors.
Expand Down
16 changes: 8 additions & 8 deletions docs/src/codegen.md
Expand Up @@ -20,7 +20,7 @@ playwright codegen playwright.dev
```

```bash csharp
pwsh bin\Debug\netX\playwright.ps1 codegen playwright.dev
pwsh bin/Debug/netX/playwright.ps1 codegen playwright.dev
```

Run `codegen` and perform actions in the browser. Playwright will generate the code for the user interactions. `Codegen` will attempt to generate resilient text-based selectors.
Expand All @@ -45,7 +45,7 @@ playwright codegen --viewport-size=800,600 playwright.dev
```

```bash csharp
pwsh bin\Debug\netX\playwright.ps1 codegen --viewport-size=800,600 playwright.dev
pwsh bin/Debug/netX/playwright.ps1 codegen --viewport-size=800,600 playwright.dev
```


Expand All @@ -69,7 +69,7 @@ playwright codegen --device="iPhone 11" playwright.dev
```

```bash csharp
pwsh bin\Debug\netX\playwright.ps1 codegen --device="iPhone 11" playwright.dev
pwsh bin/Debug/netX/playwright.ps1 codegen --device="iPhone 11" playwright.dev
```

<img width="1239" alt="Codegen generating code for tests for playwright.dev website emulated for iPhone 11" src="https://user-images.githubusercontent.com/13063165/182360089-9dc6d33d-480e-4bb2-86a3-fec51c1c228e.png" />
Expand All @@ -92,7 +92,7 @@ playwright codegen --color-scheme=dark playwright.dev
```

```bash csharp
pwsh bin\Debug\netX\playwright.ps1 codegen --color-scheme=dark playwright.dev
pwsh bin/Debug/netX/playwright.ps1 codegen --color-scheme=dark playwright.dev
```

<img width="1258" alt="Codegen generating code for tests for playwright.dev website in dark mode" src="https://user-images.githubusercontent.com/13063165/182359371-0bb4a7a2-abbb-4f73-8550-d67e0101f0ad.png" />
Expand All @@ -114,7 +114,7 @@ playwright codegen --timezone="Europe/Rome" --geolocation="41.890221,12.492348"
```

```bash csharp
pwsh bin\Debug\netX\playwright.ps1 codegen --timezone="Europe/Rome" --geolocation="41.890221,12.492348" --lang="it-IT" maps.google.com
pwsh bin/Debug/netX/playwright.ps1 codegen --timezone="Europe/Rome" --geolocation="41.890221,12.492348" --lang="it-IT" maps.google.com
```

<img width="1276" alt="Codegen generating code for tests for google maps showing timezone, geoloation as Rome, Italy and in Italian language" src="https://user-images.githubusercontent.com/13063165/182394434-73e1c2a8-767e-411a-94e4-0912c1c50ecc.png" />
Expand All @@ -138,7 +138,7 @@ playwright codegen --save-storage=auth.json
```

```bash csharp
pwsh bin\Debug\netX\playwright.ps1 codegen --save-storage=auth.json
pwsh bin/Debug/netX/playwright.ps1 codegen --save-storage=auth.json
```

<img width="1264" alt="Screenshot 2022-08-03 at 13 28 02" src="https://user-images.githubusercontent.com/13063165/182599605-df2fbd05-622b-4cd7-8a32-0abdfea7d38d.png" />
Expand All @@ -158,7 +158,7 @@ playwright codegen --load-storage=auth.json github.com/microsoft/playwright
```

```bash csharp
pwsh bin\Debug\netX\playwright.ps1 codegen --load-storage=auth.json github.com/microsoft/playwright
pwsh bin/Debug/netX/playwright.ps1 codegen --load-storage=auth.json github.com/microsoft/playwright
```

<img width="1261" alt="Screenshot 2022-08-03 at 13 33 40" src="https://user-images.githubusercontent.com/13063165/182599680-05297b4e-c258-4416-8daa-b8637c1db120.png" />
Expand All @@ -178,7 +178,7 @@ playwright open --load-storage=auth.json github.com/microsoft/playwright
```

```bash csharp
pwsh bin\Debug\netX\playwright.ps1 open --load-storage=auth.json github.com/microsoft/playwright
pwsh bin/Debug/netX/playwright.ps1 open --load-storage=auth.json github.com/microsoft/playwright
```


Expand Down
2 changes: 1 addition & 1 deletion docs/src/debug.md
Expand Up @@ -193,7 +193,7 @@ playwright codegen wikipedia.org
```

```bash csharp
pwsh bin\Debug\netX\playwright.ps1 codegen wikipedia.org
pwsh bin/Debug/netX/playwright.ps1 codegen wikipedia.org
```

### Stepping through the Playwright script
Expand Down

0 comments on commit 3401463

Please sign in to comment.