chery-pick(docs): sync with ToT docs (#16533)

This PR cherry-picks the following commits:

- b089d0a5aa
- 13f210a1e8
- 2bdf51d284
- 32adf50e65
- 435272248f
- 8170432fab
This commit is contained in:
Playwright Service 2022-08-15 00:43:33 -07:00 committed by GitHub
parent 3bc6b4b644
commit 34014638da
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
19 changed files with 212 additions and 133 deletions

View file

@ -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: To invoke Playwright CLI commands, you need to invoke a PowerShell script:
```bash ```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. Playwright can install supported browsers by means of the CLI tool.
```bash csharp ```bash csharp
# Running without arguments will install all browsers # 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: You can also install specific browsers by providing an argument:
```bash csharp ```bash csharp
# Install WebKit # Install WebKit
pwsh bin\Debug\netX\playwright.ps1 install webkit pwsh bin/Debug/netX/playwright.ps1 install webkit
``` ```
See all supported browsers: See all supported browsers:
```bash csharp ```bash csharp
pwsh bin\Debug\netX\playwright.ps1 install --help pwsh bin/Debug/netX/playwright.ps1 install --help
``` ```
## Install browsers via API ## Install browsers via API
@ -236,17 +236,17 @@ mvn test
```bash tab=bash-bash lang=csharp ```bash tab=bash-bash lang=csharp
PLAYWRIGHT_BROWSERS_PATH=$HOME/pw-browsers 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 ```batch tab=bash-batch lang=csharp
set PLAYWRIGHT_BROWSERS_PATH=%USERPROFILE%\pw-browsers 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 ```powershell tab=bash-powershell lang=csharp
$env:PLAYWRIGHT_BROWSERS_PATH="$env:USERPROFILE\pw-browsers" $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. When running Playwright scripts, ask it to search for browsers in a shared location.
@ -405,17 +405,17 @@ mvn test
``` ```
```bash tab=bash-bash lang=csharp ```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 ```batch tab=bash-batch lang=csharp
set HTTPS_PROXY=https://192.0.2.1 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 ```powershell tab=bash-powershell lang=csharp
$env:HTTPS_PROXY="https://192.0.2.1" $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: 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:
@ -500,17 +500,17 @@ mvn test
``` ```
```bash tab=bash-bash lang=csharp ```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 ```batch tab=bash-batch lang=csharp
set PLAYWRIGHT_DOWNLOAD_HOST=192.0.2.1 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 ```powershell tab=bash-powershell lang=csharp
$env:PLAYWRIGHT_DOWNLOAD_HOST="192.0.2.1" $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 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
@ -584,19 +584,19 @@ mvn test
``` ```
```bash tab=bash-bash lang=csharp ```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 ```batch tab=bash-batch lang=csharp
set PLAYWRIGHT_FIREFOX_DOWNLOAD_HOST=203.0.113.3 set PLAYWRIGHT_FIREFOX_DOWNLOAD_HOST=203.0.113.3
set PLAYWRIGHT_DOWNLOAD_HOST=192.0.2.1 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 ```powershell tab=bash-powershell lang=csharp
$env:PLAYWRIGHT_DOWNLOAD_HOST="192.0.2.1" $env:PLAYWRIGHT_DOWNLOAD_HOST="192.0.2.1"
$env:PLAYWRIGHT_FIREFOX_DOWNLOAD_HOST="203.0.113.3" $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 ## Skip browser downloads
@ -638,17 +638,17 @@ mvn test
``` ```
```bash tab=bash-bash lang=csharp ```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 ```batch tab=bash-batch lang=csharp
set PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 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 ```powershell tab=bash-powershell lang=csharp
$env:PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 $env:PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1
pwsh bin\Debug\netX\playwright.ps1 install pwsh bin/Debug/netX/playwright.ps1 install
``` ```
## Download single browser binary ## Download single browser binary

View file

@ -32,7 +32,7 @@ configurations for common CI providers.
mvn exec:java -e -Dexec.mainClass=com.microsoft.playwright.CLI -Dexec.args="install --with-deps" mvn exec:java -e -Dexec.mainClass=com.microsoft.playwright.CLI -Dexec.args="install --with-deps"
``` ```
```bash csharp ```bash csharp
pwsh bin\Debug\netX\playwright.ps1 install --with-deps pwsh bin/Debug/netX/playwright.ps1 install --with-deps
``` ```
1. **Run your tests**: 1. **Run your tests**:

View file

@ -23,7 +23,7 @@ playwright
```bash csharp ```bash csharp
# Use the tools. # Use the tools.
pwsh bin\Debug\netX\playwright.ps1 --help pwsh bin/Debug/netX/playwright.ps1 --help
``` ```
```json js ```json js
@ -56,7 +56,7 @@ playwright install
```bash csharp ```bash csharp
# Running without arguments will install default browsers # 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: You can also install specific browsers by providing an argument:
@ -78,7 +78,7 @@ playwright install webkit
```bash csharp ```bash csharp
# Install WebKit # Install WebKit
pwsh bin\Debug\netX\playwright.ps1 install webkit pwsh bin/Debug/netX/playwright.ps1 install webkit
``` ```
See all supported browsers: See all supported browsers:
@ -96,7 +96,7 @@ playwright install --help
``` ```
```bash csharp ```bash csharp
pwsh bin\Debug\netX\playwright.ps1 install --help pwsh bin/Debug/netX/playwright.ps1 install --help
``` ```
## Install system dependencies ## Install system dependencies
@ -120,7 +120,7 @@ playwright install-deps
```bash csharp ```bash csharp
# See command help # 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: You can also install the dependencies for a single browser only by passing it as an argument:
@ -138,7 +138,7 @@ playwright install-deps chromium
``` ```
```bash csharp ```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. 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.
@ -156,7 +156,7 @@ playwright install --with-deps chromium
``` ```
```bash csharp ```bash csharp
pwsh bin\Debug\netX\playwright.ps1 install --with-deps chromium pwsh bin/Debug/netX/playwright.ps1 install --with-deps chromium
``` ```
## Generate code ## Generate code
@ -174,7 +174,7 @@ playwright codegen wikipedia.org
``` ```
```bash csharp ```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. 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.
@ -204,7 +204,7 @@ playwright codegen --save-storage=auth.json
``` ```
```bash csharp ```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. # Perform authentication and exit.
# auth.json will contain the storage state. # auth.json will contain the storage state.
``` ```
@ -231,8 +231,8 @@ playwright codegen --load-storage=auth.json my.web.app
``` ```
```bash csharp ```bash csharp
pwsh bin\Debug\netX\playwright.ps1 open --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 pwsh bin/Debug/netX/playwright.ps1 codegen --load-storage=auth.json my.web.app
# Perform actions in authenticated state. # Perform actions in authenticated state.
``` ```
@ -351,7 +351,7 @@ playwright open example.com
```bash csharp ```bash csharp
# Open page in Chromium # Open page in Chromium
pwsh bin\Debug\netX\playwright.ps1 open example.com pwsh bin/Debug/netX/playwright.ps1 open example.com
``` ```
```bash js ```bash js
@ -371,7 +371,7 @@ playwright wk example.com
```bash csharp ```bash csharp
# Open page in WebKit # Open page in WebKit
pwsh bin\Debug\netX\playwright.ps1 wk example.com pwsh bin/Debug/netX/playwright.ps1 wk example.com
``` ```
### Emulate devices ### Emulate devices
@ -394,7 +394,7 @@ playwright open --device="iPhone 11" wikipedia.org
```bash csharp ```bash csharp
# Emulate iPhone 11. # 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 ### Emulate color scheme and viewport size
@ -416,7 +416,7 @@ playwright open --viewport-size=800,600 --color-scheme=dark twitter.com
```bash csharp ```bash csharp
# Emulate screen size and color scheme. # 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 ### Emulate geolocation, language and timezone
@ -442,7 +442,7 @@ playwright open --timezone="Europe/Rome" --geolocation="41.890221,12.492348" --l
```bash csharp ```bash csharp
# Emulate timezone, language & location # Emulate timezone, language & location
# Once page opens, click the "my location" button to see geolocation in action # 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 ## Inspect selectors
@ -542,7 +542,7 @@ playwright screenshot \
```bash csharp ```bash csharp
# Wait 3 seconds before capturing a screenshot after page loads ('load' event fires) # 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" \ --device="iPhone 11" \
--color-scheme=dark \ --color-scheme=dark \
--wait-for-timeout=3000 \ --wait-for-timeout=3000 \
@ -566,7 +566,7 @@ playwright screenshot --full-page en.wikipedia.org wiki-full.png
```bash csharp ```bash csharp
# Capture a full page screenshot # 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 ## Generate PDF
@ -590,5 +590,5 @@ playwright pdf https://en.wikipedia.org/wiki/PDF wiki.pdf
```bash csharp ```bash csharp
# See command help # 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
``` ```

View file

@ -25,7 +25,7 @@ playwright codegen playwright.dev
``` ```
```bash csharp ```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. 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.

View file

@ -20,7 +20,7 @@ playwright codegen playwright.dev
``` ```
```bash csharp ```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. 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.
@ -45,7 +45,7 @@ playwright codegen --viewport-size=800,600 playwright.dev
``` ```
```bash csharp ```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
``` ```
@ -69,7 +69,7 @@ playwright codegen --device="iPhone 11" playwright.dev
``` ```
```bash csharp ```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" /> <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" />
@ -92,7 +92,7 @@ playwright codegen --color-scheme=dark playwright.dev
``` ```
```bash csharp ```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" /> <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" />
@ -114,7 +114,7 @@ playwright codegen --timezone="Europe/Rome" --geolocation="41.890221,12.492348"
``` ```
```bash csharp ```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" /> <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" />
@ -138,7 +138,7 @@ playwright codegen --save-storage=auth.json
``` ```
```bash csharp ```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" /> <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" />
@ -158,7 +158,7 @@ playwright codegen --load-storage=auth.json github.com/microsoft/playwright
``` ```
```bash csharp ```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" /> <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" />
@ -178,7 +178,7 @@ playwright open --load-storage=auth.json github.com/microsoft/playwright
``` ```
```bash csharp ```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
``` ```

View file

@ -193,7 +193,7 @@ playwright codegen wikipedia.org
``` ```
```bash csharp ```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 ### Stepping through the Playwright script

View file

@ -70,9 +70,11 @@ dotnet build
4. Install required browsers by replacing `netX` with the actual output folder name, e.g. `net6.0`: 4. Install required browsers by replacing `netX` with the actual output folder name, e.g. `net6.0`:
```bash ```bash
pwsh bin\Debug\netX\playwright.ps1 install pwsh bin/Debug/netX/playwright.ps1 install
``` ```
If `pwsh` is not available, you have to [install PowerShell](https://docs.microsoft.com/powershell/scripting/install/installing-powershell).
## Add Example Tests ## Add Example Tests
Edit the `UnitTest1.cs` file with the code below to create an example end-to-end test: Edit the `UnitTest1.cs` file with the code below to create an example end-to-end test:

View file

@ -19,7 +19,7 @@ dotnet add package Microsoft.Playwright
# Build the project # Build the project
dotnet build dotnet build
# Install required browsers - replace netX with actual output folder name, e.g. net6.0. # Install required browsers - replace netX with actual output folder name, e.g. net6.0.
pwsh bin\Debug\netX\playwright.ps1 install pwsh bin/Debug/netX/playwright.ps1 install
# If the pwsh command does not work (throws TypeNotFound), make sure to use an up-to-date version of PowerShell. # If the pwsh command does not work (throws TypeNotFound), make sure to use an up-to-date version of PowerShell.
dotnet tool update --global PowerShell dotnet tool update --global PowerShell

View file

@ -5,7 +5,7 @@ title: "Mock APIs"
Playwright provides native support for most of the browser features. However, there are some experimental APIs Playwright provides native support for most of the browser features. However, there are some experimental APIs
and APIs which are not (yet) fully supported by all browsers. Playwright usually doesn't provide dedicated and APIs which are not (yet) fully supported by all browsers. Playwright usually doesn't provide dedicated
atomation APIs in such cases. You can use mocks to test behavior of your application in such cases. This guide automation APIs in such cases. You can use mocks to test behavior of your application in such cases. This guide
gives a few examples. gives a few examples.
<!-- TOC --> <!-- TOC -->

View file

@ -719,7 +719,7 @@ playwright open --save-har=example.har --save-har-glob="**/api/**" https://examp
```bash csharp ```bash csharp
# Save API requests from example.com as "example.har" archive. # Save API requests from example.com as "example.har" archive.
pwsh bin\Debug\netX\playwright.ps1 open --save-har=example.har --save-har-glob="**/api/**" https://example.com pwsh bin/Debug/netX/playwright.ps1 open --save-har=example.har --save-har-glob="**/api/**" https://example.com
``` ```
### Recording HAR with a script ### Recording HAR with a script

View file

@ -4,6 +4,52 @@ title: "Release notes"
toc_max_heading_level: 2 toc_max_heading_level: 2
--- ---
## Version 1.25
### New .runsettings file support
`Microsoft.Playwright.NUnit` and `Microsoft.Playwright.MSTest` will now consider the `.runsettings` file and passed settings via the CLI when running end-to-end tests. See in the [documentation](https://playwright.dev/dotnet/docs/test-runners) for a full list of supported settings.
The following does now work:
```xml
<?xml version="1.0" encoding="utf-8"?>
<RunSettings>
<!-- Playwright -->
<Playwright>
<BrowserName>chromium</BrowserName>
<ExpectTimeout>5000</ExpectTimeout>
<LaunchOptions>
<Headless>true</Headless>
<Channel>msedge</Channel>
</LaunchOptions>
</Playwright>
<!-- General run configuration -->
<RunConfiguration>
<EnvironmentVariables>
<!-- For debugging selectors, it's recommend to set the following environment variable -->
<DEBUG>pw:api</DEBUG>
</EnvironmentVariables>
</RunConfiguration>
</RunSettings>
```
### Announcements
* 🪦 This is the last release with macOS 10.15 support (deprecated as of 1.21).
* ⚠️ Ubuntu 18 is now deprecated and will not be supported as of Dec 2022.
### Browser Versions
* Chromium 105.0.5195.19
* Mozilla Firefox 103.0
* WebKit 16.0
This version was also tested against the following stable channels:
* Google Chrome 104
* Microsoft Edge 104
## Version 1.24 ## Version 1.24
<div className="embed-youtube"> <div className="embed-youtube">
@ -60,7 +106,7 @@ Now you can record network traffic into a HAR file and re-use this traffic in yo
To record network into HAR file: To record network into HAR file:
```bash ```bash
pwsh bin\Debug\netX\playwright.ps1 open --save-har=example.har --save-har-glob="**/api/**" https://example.com pwsh bin/Debug/netX/playwright.ps1 open --save-har=example.har --save-har-glob="**/api/**" https://example.com
``` ```
Alternatively, you can record HAR programmatically: Alternatively, you can record HAR programmatically:
@ -354,7 +400,7 @@ Playwright Trace Viewer is now **available online** at https://trace.playwright.
- Playwright now supports **Ubuntu 20.04 ARM64**. You can now run Playwright tests inside Docker on Apple M1 and on Raspberry Pi. - Playwright now supports **Ubuntu 20.04 ARM64**. You can now run Playwright tests inside Docker on Apple M1 and on Raspberry Pi.
- You can now use Playwright to install stable version of Edge on Linux: - You can now use Playwright to install stable version of Edge on Linux:
```bash ```bash
pwsh bin\Debug\netX\playwright.ps1 install msedge pwsh bin/Debug/netX/playwright.ps1 install msedge
``` ```
@ -381,7 +427,7 @@ Read more about [`method: Locator.waitFor`].
### 🎭 Playwright Trace Viewer ### 🎭 Playwright Trace Viewer
- run trace viewer with `pwsh bin\Debug\netX\playwright.ps1 show-trace` and drop trace files to the trace viewer PWA - run trace viewer with `pwsh bin/Debug/netX/playwright.ps1 show-trace` and drop trace files to the trace viewer PWA
- better visual attribution of action targets - better visual attribution of action targets
Read more about [Trace Viewer](./trace-viewer). Read more about [Trace Viewer](./trace-viewer).

View file

@ -4,6 +4,28 @@ title: "Release notes"
toc_max_heading_level: 2 toc_max_heading_level: 2
--- ---
## Version 1.25
### New APIs & changes
- Default assertions timeout now can be changed with [`'setDefaultAssertionTimeout'`](./test-assertions#playwright-assertions-set-default-assertion-timeout).
### Announcements
* 🪦 This is the last release with macOS 10.15 support (deprecated as of 1.21).
* ⚠️ Ubuntu 18 is now deprecated and will not be supported as of Dec 2022.
### Browser Versions
* Chromium 105.0.5195.19
* Mozilla Firefox 103.0
* WebKit 16.0
This version was also tested against the following stable channels:
* Google Chrome 104
* Microsoft Edge 104
## Version 1.24 ## Version 1.24
<div className="embed-youtube"> <div className="embed-youtube">

View file

@ -4,6 +4,25 @@ title: "Release notes"
toc_max_heading_level: 2 toc_max_heading_level: 2
--- ---
## Version 1.25
### Announcements
* 🎁 We now ship Ubuntu 22.04 Jammy Jellyfish docker image: `mcr.microsoft.com/playwright/python:v1.25.0-jammy`.
* 🪦 This is the last release with macOS 10.15 support (deprecated as of 1.21).
* ⚠️ Ubuntu 18 is now deprecated and will not be supported as of Dec 2022.
### Browser Versions
* Chromium 105.0.5195.19
* Mozilla Firefox 103.0
* WebKit 16.0
This version was also tested against the following stable channels:
* Google Chrome 104
* Microsoft Edge 104
## Version 1.24 ## Version 1.24
<div className="embed-youtube"> <div className="embed-youtube">

View file

@ -31,23 +31,13 @@ You can run a single test, a set of tests or all tests. Tests can be run on diff
- Running Tests on specific browsers - Running Tests on specific browsers
```bash tab=bash-bash ```bash
BROWSER=webkit dotnet test dotnet test -- Playwright.BrowserName=webkit
```
```batch tab=bash-batch
set BROWSER=webkit
dotnet test
```
```powershell tab=bash-powershell
$env:BROWSER="webkit"
dotnet test
``` ```
- Running Tests on multiple browsers - Running Tests on multiple browsers
To run your test on multiple browsers or configurations you need to invoke the `dotnet test` command multiple times. There you can then either specify the `BROWSER` environment variable (like the previous) or pass the `browser` via the runsettings file: To run your test on multiple browsers or configurations you need to invoke the `dotnet test` command multiple times. There you can then either specify the `BROWSER` environment variable or set the `Playwright.BrowserName` via the runsettings file:
```bash ```bash
dotnet test --settings:chromium.runsettings dotnet test --settings:chromium.runsettings
@ -58,10 +48,9 @@ You can run a single test, a set of tests or all tests. Tests can be run on diff
```xml ```xml
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<RunSettings> <RunSettings>
<TestRunParameters> <Playwright>
<Parameter name="browser" value="chromium" /> <BrowserName>chromium</BrowserName>
<Parameter name="headless" value="false" /> </Playwright>
</TestRunParameters>
</RunSettings> </RunSettings>
``` ```

View file

@ -24,11 +24,13 @@ Playwright provides base classes to write tests with NUnit via the [`Microsoft.P
# Create a new project # Create a new project
dotnet new nunit -n PlaywrightTests dotnet new nunit -n PlaywrightTests
cd PlaywrightTests cd PlaywrightTests
# Add the required reference # Add the required reference
dotnet add package Microsoft.Playwright.NUnit dotnet add package Microsoft.Playwright.NUnit
dotnet build dotnet build
# Install the required browsers and operating system dependencies # Install the required browsers and operating system dependencies
pwsh bin\Debug\netX\playwright.ps1 install --with-deps pwsh bin/Debug/netX/playwright.ps1 install --with-deps
``` ```
Modify the UnitTest1.cs: Modify the UnitTest1.cs:
@ -104,7 +106,8 @@ dotnet test --filter "Name~Slogan"
### Running NUnit tests in Parallel ### Running NUnit tests in Parallel
By default NUnit will run all test files in parallel, while running tests inside each file sequentially. It will create as many processes as there are cores on the host system. You can adjust this behavior using the NUnit.NumberOfTestWorkers parameter. By default NUnit will run all test files in parallel, while running tests inside each file sequentially (`ParallelScope.Self`). It will create as many processes as there are cores on the host system. You can adjust this behavior using the NUnit.NumberOfTestWorkers parameter.
Running test in parallel using `ParallelScope.All` or `ParallelScope.Fixtures` is not supported.
For CPU-bound tests, we recommend using as many workers as there are cores on your system, divided by 2. For IO-bound tests you can use as many workers as you have cores. For CPU-bound tests, we recommend using as many workers as there are cores on your system, divided by 2. For IO-bound tests you can use as many workers as you have cores.
@ -151,24 +154,18 @@ CLI. See the following example:
```xml ```xml
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<RunSettings> <RunSettings>
<TestRunParameters> <Playwright>
<Parameter name="browser" value="chromium" /> <BrowserName>chromium</BrowserName>
<Parameter name="headless" value="false" /> <LaunchOptions>
<Parameter name="channel" value="msedge" /> <Headless>false</Headless>
</TestRunParameters> <Channel>msedge</Channel>
</LaunchOptions>
</Playwright>
</RunSettings> </RunSettings>
``` ```
```bash tab=bash-bash ```bash
dotnet test -- TestRunParameters.Parameter\(name=\"browser\", value=\"chromium\"\) TestRunParameters.Parameter\(name=\"headless\", value=\"false\"\) TestRunParameters.Parameter\(name=\"channel\", value=\"msedge\"\) dotnet test -- Playwright.BrowserName=chromium Playwright.LaunchOptions.Headless=false Playwright.LaunchOptions.Channel=msedge
```
```batch tab=bash-batch
dotnet test -- TestRunParameters.Parameter(name=\"browser\", value=\"chromium\") TestRunParameters.Parameter(name=\"headless\", value=\"false\") TestRunParameters.Parameter(name=\"channel\", value=\"msedge\")
```
```powershell tab=bash-powershell
dotnet test -- TestRunParameters.Parameter(name=\"browser\", value=\"chromium\") TestRunParameters.Parameter(name=\"headless\", value=\"false\") TestRunParameters.Parameter(name=\"channel\", value=\"msedge\")
``` ```
### Using Verbose API Logs ### Using Verbose API Logs
@ -177,29 +174,33 @@ When you have enabled the [verbose API log](./debug.md#verbose-api-logs), via th
### Using the .runsettings file ### Using the .runsettings file
When running tests from Visual Studio, you can take advantage of the `.runsettings` file. When running tests from Visual Studio, you can take advantage of the `.runsettings` file. The following shows a reference of the supported values.
For example, to specify the amount of workers (`NUnit.NumberOfTestWorkers`), you can use the following snippet: For example, to specify the amount of workers you can use `NUnit.NumberOfTestWorkers` or to enable `DEBUG` logs `RunConfiguration.EnvironmentVariables`.
```xml ```xml
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<RunSettings> <RunSettings>
<!-- NUnit adapter -->
<NUnit> <NUnit>
<NumberOfTestWorkers>24</NumberOfTestWorkers> <NumberOfTestWorkers>24</NumberOfTestWorkers>
</NUnit> </NUnit>
</RunSettings> <!-- General run configuration -->
```
If you want to enable debugging, you can set the `DEBUG` variable to `pw:api` as documented, by doing:
```xml
<?xml version="1.0" encoding="utf-8"?>
<RunSettings>
<RunConfiguration> <RunConfiguration>
<EnvironmentVariables> <EnvironmentVariables>
<!-- For debugging selectors, it's recommend to set the following environment variable -->
<DEBUG>pw:api</DEBUG> <DEBUG>pw:api</DEBUG>
</EnvironmentVariables> </EnvironmentVariables>
</RunConfiguration> </RunConfiguration>
<!-- Playwright -->
<Playwright>
<BrowserName>chromium</BrowserName>
<ExpectTimeout>5000</ExpectTimeout>
<LaunchOptions>
<Headless>false</Headless>
<Channel>msedge</Channel>
</LaunchOptions>
</Playwright>
</RunSettings> </RunSettings>
``` ```
@ -224,11 +225,13 @@ Playwright provides base classes to write tests with MSTest via the [`Microsoft.
# Create a new project # Create a new project
dotnet new mstest -n PlaywrightTests dotnet new mstest -n PlaywrightTests
cd PlaywrightTests cd PlaywrightTests
# Add the required reference # Add the required reference
dotnet add package Microsoft.Playwright.MSTest dotnet add package Microsoft.Playwright.MSTest
dotnet build dotnet build
# Install the required browsers and operating system dependencies # Install the required browsers and operating system dependencies
pwsh bin\Debug\netX\playwright.ps1 install --with-deps pwsh bin/Debug/netX/playwright.ps1 install --with-deps
``` ```
Modify the UnitTest1.cs: Modify the UnitTest1.cs:
@ -304,7 +307,8 @@ dotnet test --filter "Name~Slogan"
### Running MSTest tests in Parallel ### Running MSTest tests in Parallel
By default MSTest will run all classes in parallel, while running tests inside each class sequentially. It will create as many processes as there are cores on the host system. You can adjust this behavior by using the following CLI parameter or using a `.runsettings` file, see below. By default MSTest will run all classes in parallel, while running tests inside each class sequentially (`ExecutionScope.ClassLevel`). It will create as many processes as there are cores on the host system. You can adjust this behavior by using the following CLI parameter or using a `.runsettings` file, see below.
Running tests in parallel at the method level (`ExecutionScope.MethodLevel`) is not supported.
```bash ```bash
dotnet test --settings:.runsettings -- MSTest.Parallelize.Workers=4 dotnet test --settings:.runsettings -- MSTest.Parallelize.Workers=4
@ -357,24 +361,18 @@ CLI. See the following example:
```xml ```xml
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<RunSettings> <RunSettings>
<TestRunParameters> <Playwright>
<Parameter name="browser" value="chromium" /> <BrowserName>chromium</BrowserName>
<Parameter name="headless" value="false" /> <LaunchOptions>
<Parameter name="channel" value="msedge" /> <Headless>false</Headless>
</TestRunParameters> <Channel>msedge</Channel>
</LaunchOptions>
</Playwright>
</RunSettings> </RunSettings>
``` ```
```bash tab=bash-bash ```bash
dotnet test -- TestRunParameters.Parameter\(name=\"browser\", value=\"chromium\"\) TestRunParameters.Parameter\(name=\"headless\", value=\"false\"\) TestRunParameters.Parameter\(name=\"channel\", value=\"msedge\"\) dotnet test -- Playwright.BrowserName=chromium Playwright.LaunchOptions.Headless=false Playwright.LaunchOptions.Channel=msedge
```
```batch tab=bash-batch
dotnet test -- TestRunParameters.Parameter(name=\"browser\", value=\"chromium\") TestRunParameters.Parameter(name=\"headless\", value=\"false\") TestRunParameters.Parameter(name=\"channel\", value=\"msedge\")
```
```powershell tab=bash-powershell
dotnet test -- TestRunParameters.Parameter(name=\"browser\", value=\"chromium\") TestRunParameters.Parameter(name=\"headless\", value=\"false\") TestRunParameters.Parameter(name=\"channel\", value=\"msedge\")
``` ```
### Using Verbose API Logs ### Using Verbose API Logs
@ -383,32 +381,35 @@ When you have enabled the [verbose API log](./debug.md#verbose-api-logs), via th
### Using the .runsettings file ### Using the .runsettings file
When running tests from Visual Studio, you can take advantage of the `.runsettings` file. When running tests from Visual Studio, you can take advantage of the `.runsettings` file. The following shows a reference of the supported values.
For example, to specify the amount of workers (`MSTest.Parallelize.Workers`), you can use the following snippet: For example, to specify the number of workers, you can use `MSTest.Parallelize.Workers`. You can also enable `DEBUG` logs using `RunConfiguration.EnvironmentVariables`.
```xml ```xml
<RunSettings> <RunSettings>
<!-- MSTest adapter --> <!-- MSTest adapter -->
<MSTest> <MSTest>
<Parallelize> <Parallelize>
<Workers>4</Workers> <Workers>4</Workers>
<Scope>ClassLevel</Scope> <Scope>ClassLevel</Scope>
</Parallelize> </Parallelize>
</MSTest> </MSTest>
</RunSettings> <!-- General run configuration -->
```
If you want to enable debugging, you can set the `DEBUG` variable to `pw:api` as documented, by doing:
```xml
<?xml version="1.0" encoding="utf-8"?>
<RunSettings>
<RunConfiguration> <RunConfiguration>
<EnvironmentVariables> <EnvironmentVariables>
<!-- For debugging selectors, it's recommend to set the following environment variable -->
<DEBUG>pw:api</DEBUG> <DEBUG>pw:api</DEBUG>
</EnvironmentVariables> </EnvironmentVariables>
</RunConfiguration> </RunConfiguration>
<!-- Playwright -->
<Playwright>
<BrowserName>chromium</BrowserName>
<ExpectTimeout>5000</ExpectTimeout>
<LaunchOptions>
<Headless>false</Headless>
<Channel>msedge</Channel>
</LaunchOptions>
</Playwright>
</RunSettings> </RunSettings>
``` ```

View file

@ -101,7 +101,7 @@ playwright show-trace trace.zip
``` ```
```bash csharp ```bash csharp
pwsh bin\Debug\netX\playwright.ps1 show-trace trace.zip pwsh bin/Debug/netX/playwright.ps1 show-trace trace.zip
``` ```

View file

@ -153,7 +153,7 @@ playwright show-trace trace.zip
``` ```
```bash csharp ```bash csharp
pwsh bin\Debug\netX\playwright.ps1 show-trace trace.zip pwsh bin/Debug/netX/playwright.ps1 show-trace trace.zip
``` ```
## Actions ## Actions
@ -220,7 +220,7 @@ playwright show-trace https://example.com/trace.zip
``` ```
```bash csharp ```bash csharp
pwsh bin\Debug\netX\playwright.ps1 show-trace https://example.com/trace.zip pwsh bin/Debug/netX/playwright.ps1 show-trace https://example.com/trace.zip
``` ```
## Using [trace.playwright.dev](https://trace.playwright.dev) ## Using [trace.playwright.dev](https://trace.playwright.dev)

View file

@ -715,7 +715,7 @@ function buildBasePlaywrightCLICommand(cliTargetLang: string | undefined): strin
case 'java': case 'java':
return `mvn exec:java -e -Dexec.mainClass=com.microsoft.playwright.CLI -Dexec.args="...options.."`; return `mvn exec:java -e -Dexec.mainClass=com.microsoft.playwright.CLI -Dexec.args="...options.."`;
case 'csharp': case 'csharp':
return `pwsh bin\\Debug\\netX\\playwright.ps1`; return `pwsh bin/Debug/netX/playwright.ps1`;
default: default:
return `npx playwright`; return `npx playwright`;
} }

View file

@ -853,7 +853,7 @@ export function buildPlaywrightCLICommand(sdkLanguage: string, parameters: strin
case 'java': case 'java':
return `mvn exec:java -e -Dexec.mainClass=com.microsoft.playwright.CLI -Dexec.args="${parameters}"`; return `mvn exec:java -e -Dexec.mainClass=com.microsoft.playwright.CLI -Dexec.args="${parameters}"`;
case 'csharp': case 'csharp':
return `pwsh bin\\Debug\\netX\\playwright.ps1 ${parameters}`; return `pwsh bin/Debug/netX/playwright.ps1 ${parameters}`;
default: default:
return `npx playwright ${parameters}`; return `npx playwright ${parameters}`;
} }