docs(dotnet): TestRunParameters -> Playwright runsettings node (#16505)

This commit is contained in:
Max Schmitt 2022-08-12 23:35:08 +02:00 committed by GitHub
parent 2bdf51d284
commit 32adf50e65
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 52 additions and 68 deletions

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

@ -154,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
@ -180,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>true</Headless>
<Channel>msedge</Channel>
</LaunchOptions>
</Playwright>
</RunSettings> </RunSettings>
``` ```
@ -363,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
@ -389,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>
``` ```