Skip to content

Commit

Permalink
feat(roll): roll to 1.37 Playwright (#1121)
Browse files Browse the repository at this point in the history
Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
  • Loading branch information
playwrightmachine and github-actions[bot] authored Aug 10, 2023
1 parent 2502a44 commit 9b00ff7
Show file tree
Hide file tree
Showing 192 changed files with 2,360 additions and 1,305 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Makes the assertion check for the opposite condition. For example, this code tes
**Usage**

```csharp
Expect(ApiResponse).Not
Expect(Response).Not
```

**Type**
Expand Down
4 changes: 2 additions & 2 deletions dotnet/versioned_docs/version-stable/api/class-browser.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ await browser.CloseAsync();
Whether to ignore HTTPS errors when sending network requests. Defaults to `false`.
- `IsMobile` [bool]? *(optional)*<a aria-hidden="true" tabindex="-1" class="list-anchor-link" id="browser-new-context-option-is-mobile"/><a href="#browser-new-context-option-is-mobile" class="list-anchor">#</a>

Whether the `meta viewport` tag is taken into account and touch events are enabled. isMobile is a part of device, so you don't actually need to set it manually. Defaults to `false` and is not supported in Firefox. Learn more about [mobile emulation](../emulation.mdx#isMobile).
Whether the `meta viewport` tag is taken into account and touch events are enabled. isMobile is a part of device, so you don't actually need to set it manually. Defaults to `false` and is not supported in Firefox. Learn more about [mobile emulation](../emulation.mdx#ismobile).
- `JavaScriptEnabled` [bool]? *(optional)*<a aria-hidden="true" tabindex="-1" class="list-anchor-link" id="browser-new-context-option-java-script-enabled"/><a href="#browser-new-context-option-java-script-enabled" class="list-anchor">#</a>

Whether or not to enable JavaScript in the context. Defaults to `true`. Learn more about [disabling JavaScript](../emulation.mdx#javascript-enabled).
Expand Down Expand Up @@ -385,7 +385,7 @@ await Browser.NewPageAsync(options);
Whether to ignore HTTPS errors when sending network requests. Defaults to `false`.
- `IsMobile` [bool]? *(optional)*<a aria-hidden="true" tabindex="-1" class="list-anchor-link" id="browser-new-page-option-is-mobile"/><a href="#browser-new-page-option-is-mobile" class="list-anchor">#</a>

Whether the `meta viewport` tag is taken into account and touch events are enabled. isMobile is a part of device, so you don't actually need to set it manually. Defaults to `false` and is not supported in Firefox. Learn more about [mobile emulation](../emulation.mdx#isMobile).
Whether the `meta viewport` tag is taken into account and touch events are enabled. isMobile is a part of device, so you don't actually need to set it manually. Defaults to `false` and is not supported in Firefox. Learn more about [mobile emulation](../emulation.mdx#ismobile).
- `JavaScriptEnabled` [bool]? *(optional)*<a aria-hidden="true" tabindex="-1" class="list-anchor-link" id="browser-new-page-option-java-script-enabled"/><a href="#browser-new-page-option-java-script-enabled" class="list-anchor">#</a>

Whether or not to enable JavaScript in the context. Defaults to `true`. Learn more about [disabling JavaScript](../emulation.mdx#javascript-enabled).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,7 @@ Enabling routing disables http cache.

<font size="2" style={{position: "relative", top: "-20px"}}>Added in: v1.23</font><x-search>browserContext.RouteFromHARAsync</x-search>

If specified the network requests that are made in the context will be served from the HAR file. Read more about [Replaying from HAR](../network.mdx#replaying-from-har).
If specified the network requests that are made in the context will be served from the HAR file. Read more about [Replaying from HAR](../mock.mdx#replaying-from-har).

Playwright will not serve requests intercepted by Service Worker from the HAR file. See [this](https://github.com/microsoft/playwright/issues/1090) issue. We recommend disabling Service Workers when using request interception by setting `Browser.newContext.serviceWorkers` to `'block'`.

Expand Down
15 changes: 14 additions & 1 deletion dotnet/versioned_docs/version-stable/api/class-browsertype.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,19 @@ await BrowserType.ConnectAsync(wsEndpoint, options);

A browser websocket endpoint to connect to.
- `options` `BrowserTypeConnectOptions?` *(optional)*
- `ExposeNetwork` [string]? *(optional)* <font size="2">Added in: v1.37</font><a aria-hidden="true" tabindex="-1" class="list-anchor-link" id="browser-type-connect-option-expose-network"/><a href="#browser-type-connect-option-expose-network" class="list-anchor">#</a>

This option exposes network available on the connecting client to the browser being connected to. Consists of a list of rules separated by comma.

Available rules:
1. Hostname pattern, for example: `example.com`, `*.org:99`, `x.*.y.com`, `*foo.org`.
1. IP literal, for example: `127.0.0.1`, `0.0.0.0:99`, `[::1]`, `[0:0::1]:99`.
1. `<loopback>` that matches local loopback interfaces: `localhost`, `*.localhost`, `127.0.0.1`, `[::1]`.

Some common examples:
1. `"*"` to expose all network.
1. `"<loopback>"` to expose localhost network.
1. `"*.test.internal-domain,*.staging.internal-domain,<loopback>"` to expose test/staging deployments and localhost.
- `Headers` [IDictionary]?<[string], [string]> *(optional)* <font size="2">Added in: v1.11</font><a aria-hidden="true" tabindex="-1" class="list-anchor-link" id="browser-type-connect-option-headers"/><a href="#browser-type-connect-option-headers" class="list-anchor">#</a>

Additional HTTP headers to be sent with web socket connect request. Optional.
Expand Down Expand Up @@ -330,7 +343,7 @@ await BrowserType.LaunchPersistentContextAsync(userDataDir, options);
Whether to ignore HTTPS errors when sending network requests. Defaults to `false`.
- `IsMobile` [bool]? *(optional)*<a aria-hidden="true" tabindex="-1" class="list-anchor-link" id="browser-type-launch-persistent-context-option-is-mobile"/><a href="#browser-type-launch-persistent-context-option-is-mobile" class="list-anchor">#</a>

Whether the `meta viewport` tag is taken into account and touch events are enabled. isMobile is a part of device, so you don't actually need to set it manually. Defaults to `false` and is not supported in Firefox. Learn more about [mobile emulation](../emulation.mdx#isMobile).
Whether the `meta viewport` tag is taken into account and touch events are enabled. isMobile is a part of device, so you don't actually need to set it manually. Defaults to `false` and is not supported in Firefox. Learn more about [mobile emulation](../emulation.mdx#ismobile).
- `JavaScriptEnabled` [bool]? *(optional)*<a aria-hidden="true" tabindex="-1" class="list-anchor-link" id="browser-type-launch-persistent-context-option-java-script-enabled"/><a href="#browser-type-launch-persistent-context-option-java-script-enabled" class="list-anchor">#</a>

Whether or not to enable JavaScript in the context. Defaults to `true`. Learn more about [disabling JavaScript](../emulation.mdx#javascript-enabled).
Expand Down
2 changes: 2 additions & 0 deletions dotnet/versioned_docs/version-stable/api/class-frame.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -863,6 +863,8 @@ Frame.ParentFrame

<font size="2" style={{position: "relative", top: "-20px"}}>Added in: v1.8</font><x-search>frame.SetContentAsync</x-search>

This method internally calls [document.write()](https://developer.mozilla.org/en-US/docs/Web/API/Document/write), inheriting all its specific characteristics and behaviors.

**Usage**

```csharp
Expand Down
8 changes: 6 additions & 2 deletions dotnet/versioned_docs/version-stable/api/class-locator.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import TabItem from '@theme/TabItem';
import HTMLCard from '@site/src/components/HTMLCard';


Locators are the central piece of Playwright's auto-waiting and retry-ability. In a nutshell, locators represent a way to find element(s) on the page at any moment. Locator can be created with the [Page.Locator()](/api/class-page.mdx#page-locator) method.
Locators are the central piece of Playwright's auto-waiting and retry-ability. In a nutshell, locators represent a way to find element(s) on the page at any moment. A locator can be created with the [Page.Locator()](/api/class-page.mdx#page-locator) method.

[Learn more about locators](../locators.mdx).

Expand All @@ -20,7 +20,7 @@ Locators are the central piece of Playwright's auto-waiting and retry-ability. I

<font size="2" style={{position: "relative", top: "-20px"}}>Added in: v1.29</font><x-search>locator.AllAsync</x-search>

When locator points to a list of elements, returns array of locators, pointing to respective elements.
When the locator points to a list of elements, this returns an array of locators, pointing to their respective elements.

:::note
[Locator.AllAsync()](/api/class-locator.mdx#locator-all) does not wait for elements to match the locator, and instead immediately returns whatever is present in the page. When the list of elements changes dynamically, [Locator.AllAsync()](/api/class-locator.mdx#locator-all) will produce unpredictable and flaky results. When the list of elements is stable, but loaded dynamically, wait for the full list to finish loading before calling [Locator.AllAsync()](/api/class-locator.mdx#locator-all).
Expand Down Expand Up @@ -1937,6 +1937,10 @@ await Locator.TextContentAsync(options);

<font size="2" style={{position: "relative", top: "-20px"}}>Added in: v1.14</font><x-search>locator.TypeAsync</x-search>

:::tip
In most cases, you should use [Locator.FillAsync()](/api/class-locator.mdx#locator-fill) instead. You only need to type characters if there is special keyboard handling on the page.
:::

Focuses the element, and then sends a `keydown`, `keypress`/`input`, and `keyup` event for each character in the text.

To press a special key, like `Control` or `ArrowDown`, use [Locator.PressAsync()](/api/class-locator.mdx#locator-press).
Expand Down
4 changes: 3 additions & 1 deletion dotnet/versioned_docs/version-stable/api/class-page.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -1437,7 +1437,7 @@ Enabling routing disables http cache.

<font size="2" style={{position: "relative", top: "-20px"}}>Added in: v1.23</font><x-search>page.RouteFromHARAsync</x-search>

If specified the network requests that are made in the page will be served from the HAR file. Read more about [Replaying from HAR](../network.mdx#replaying-from-har).
If specified the network requests that are made in the page will be served from the HAR file. Read more about [Replaying from HAR](../mock.mdx#replaying-from-har).

Playwright will not serve requests intercepted by Service Worker from the HAR file. See [this](https://github.com/microsoft/playwright/issues/1090) issue. We recommend disabling Service Workers when using request interception by setting `Browser.newContext.serviceWorkers` to `'block'`.

Expand Down Expand Up @@ -2085,6 +2085,8 @@ await Page.ScreenshotAsync(options);

<font size="2" style={{position: "relative", top: "-20px"}}>Added in: v1.8</font><x-search>page.SetContentAsync</x-search>

This method internally calls [document.write()](https://developer.mozilla.org/en-US/docs/Web/API/Document/write), inheriting all its specific characteristics and behaviors.

**Usage**

```csharp
Expand Down
12 changes: 6 additions & 6 deletions dotnet/versioned_docs/version-stable/ci.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ jobs:
name: 'Playwright Tests'
runs-on: ubuntu-latest
container:
image: mcr.microsoft.com/playwright/dotnet:v1.35.0-jammy
image: mcr.microsoft.com/playwright/dotnet:v1.36.0-jammy
steps:
- uses: actions/checkout@v3
- name: Setup dotnet
Expand Down Expand Up @@ -146,7 +146,7 @@ steps:
displayName: 'Use .NET SDK'
- script: dotnet build --configuration Release
displayName: 'Build'
- script: pwsh bin/Debug/net6.0/playwright.ps1 install --with-deps
- script: pwsh bin/Release/net6.0/playwright.ps1 install --with-deps
displayName: 'Install Playwright browsers'
- script: dotnet test --configuration Release
displayName: 'Run tests'
Expand All @@ -160,7 +160,7 @@ trigger:
pool:
vmImage: ubuntu-latest
container: mcr.microsoft.com/playwright/dotnet:v1.35.0-jammy
container: mcr.microsoft.com/playwright/dotnet:v1.36.0-jammy
steps:
- task: UseDotNet@2
Expand All @@ -183,7 +183,7 @@ Running Playwright on CircleCI is very similar to running on GitHub Actions. In
executors:
pw-jammy-development:
docker:
- image: mcr.microsoft.com/playwright/dotnet:v1.35.0-jammy
- image: mcr.microsoft.com/playwright/dotnet:v1.36.0-jammy
```

Note: When using the docker agent definition, you are specifying the resource class of where playwright runs to the 'medium' tier [here](https://circleci.com/docs/configuration-reference?#docker-execution-environment). The default behavior of Playwright is to set the number of workers to the detected core count (2 in the case of the medium tier). Overriding the number of workers to greater than this number will cause unnecessary timeouts and failures.
Expand All @@ -194,7 +194,7 @@ Jenkins supports Docker agents for pipelines. Use the [Playwright Docker image](

```groovy
pipeline {
agent { docker { image 'mcr.microsoft.com/playwright/dotnet:v1.35.0-jammy' } }
agent { docker { image 'mcr.microsoft.com/playwright/dotnet:v1.36.0-jammy' } }
stages {
stage('e2e-tests') {
steps {
Expand All @@ -211,7 +211,7 @@ pipeline {
Bitbucket Pipelines can use public [Docker images as build environments](https://confluence.atlassian.com/bitbucket/use-docker-images-as-build-environments-792298897.html). To run Playwright tests on Bitbucket, use our public Docker image ([see Dockerfile](./docker.mdx)).
```yml
image: mcr.microsoft.com/playwright/dotnet:v1.35.0-jammy
image: mcr.microsoft.com/playwright/dotnet:v1.36.0-jammy
```
### GitLab CI
Expand Down
6 changes: 3 additions & 3 deletions dotnet/versioned_docs/version-stable/codegen-intro.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Playwright comes with the ability to generate tests out of the box and is a grea

**You will learn**
- [How to record a test](/codegen.mdx#recording-a-test)
- [How to generate locators](/codegen.mdx#generate-locators)
- [How to generate locators](/codegen.mdx#generating-locators)

<video width="100%" height="100%" controls muted >

Expand Down Expand Up @@ -41,9 +41,9 @@ To learn more about generating tests check out or detailed guide on [Codegen](./

### Generating locators

You can generate [locators](/locators.mdx) with the test generator.
You can generate [locators](/locators.mdx) with the test generator.
* Press the `'Record'` button to stop the recording and the `'Pick Locator'` button will appear.
* Click on the `'Pick Locator'` button and then hover over elements in the browser window to see the locator highlighted underneath each element.
* Click on the `'Pick Locator'` button and then hover over elements in the browser window to see the locator highlighted underneath each element.
* To choose a locator click on the element you would like to locate and the code for that locator will appear in the field next to the Pick Locator button.
* You can then edit the locator in this field to fine tune it or use the copy button to copy it and paste it into your code.

Expand Down
2 changes: 1 addition & 1 deletion dotnet/versioned_docs/version-stable/codegen.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ You can use the test generator to generate tests using emulation so as to genera

### Emulate viewport size

Playwright opens a browser window with it's viewport set to a specific width and height and is not responsive as tests need to be run under the same conditions. Use the `--viewport` option to generate tests with a different viewport size.
Playwright opens a browser window with its viewport set to a specific width and height and is not responsive as tests need to be run under the same conditions. Use the `--viewport` option to generate tests with a different viewport size.

```bash
pwsh bin/Debug/netX/playwright.ps1 codegen --viewport-size=800,600 playwright.dev
Expand Down
16 changes: 0 additions & 16 deletions dotnet/versioned_docs/version-stable/debug.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -195,22 +195,6 @@ Locator ()
- elements: [button]
```
#### playwright.highlight(selector)
Highlight the first occurrence of the locator:
```bash
playwright.highlight('.auth-form');
```
#### playwright.clear()
```bash
playwright.clear()
```
Clear existing highlights.
#### playwright.selector(element)
Generates selector for the given element. For example, select an element in the Elements panel and pass `$0`:
Expand Down
6 changes: 3 additions & 3 deletions dotnet/versioned_docs/version-stable/docker.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ This Docker image is intended to be used for testing and development purposes on
### Pull the image

```bash
docker pull mcr.microsoft.com/playwright/dotnet:v1.35.0-jammy
docker pull mcr.microsoft.com/playwright/dotnet:v1.36.0-jammy
```

### Run the image
Expand All @@ -34,15 +34,15 @@ By default, the Docker image will use the `root` user to run the browsers. This
On trusted websites, you can avoid creating a separate user and use root for it since you trust the code which will run on the browsers.

```bash
docker run -it --rm --ipc=host mcr.microsoft.com/playwright/dotnet:v1.35.0-jammy /bin/bash
docker run -it --rm --ipc=host mcr.microsoft.com/playwright/dotnet:v1.36.0-jammy /bin/bash
```

#### Crawling and scraping

On untrusted websites, it's recommended to use a separate user for launching the browsers in combination with the seccomp profile. Inside the container or if you are using the Docker image as a base image you have to use `adduser` for it.

```bash
docker run -it --rm --ipc=host --user pwuser --security-opt seccomp=seccomp_profile.json mcr.microsoft.com/playwright/dotnet:v1.35.0-jammy /bin/bash
docker run -it --rm --ipc=host --user pwuser --security-opt seccomp=seccomp_profile.json mcr.microsoft.com/playwright/dotnet:v1.36.0-jammy /bin/bash
```

[`seccomp_profile.json`](https://github.com/microsoft/playwright/blob/main/utils/docker/seccomp_profile.json) is needed to run Chromium with sandbox. This is a [default Docker seccomp profile](https://github.com/docker/engine/blob/d0d99b04cf6e00ed3fc27e81fc3d94e7eda70af3/profiles/seccomp/default.json) with extra user namespace cloning permissions:
Expand Down
2 changes: 1 addition & 1 deletion dotnet/versioned_docs/version-stable/emulation.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ With Playwright you can test your app on any browser as well as emulate a real d

## Devices

Playwright comes with a [registry of device parameters](https://github.com/microsoft/playwright/blob/main/packages/playwright-core/src/server/deviceDescriptorsSource.json) using [Playwright.Devices](/api/class-playwright.mdx#playwright-devices) for selected desktop, tablet and mobile devices. It can be used to simulate browser behavior for a specific device such as user agent, screen size, viewport and if it has touch enabled. All tests will run with the specified device parameters.
Playwright comes with a [registry of device parameters](https://github.com/microsoft/playwright/blob/main/packages/playwright-core/src/server/deviceDescriptorsSource.json) using [Playwright.Devices](/api/class-playwright.mdx#playwright-devices) for selected desktop, tablet and mobile devices. It can be used to simulate browser behavior for a specific device such as user agent, screen size, viewport and if it has touch enabled. All tests will run with the specified device parameters.

```csharp
using Microsoft.Playwright;
Expand Down
8 changes: 4 additions & 4 deletions dotnet/versioned_docs/version-stable/input.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,10 @@ await page.GetByRole(AriaRole.Button).DispatchEventAsync("click");

## Type characters

:::tip
Most of the time, you should input text with [Locator.FillAsync()](/api/class-locator.mdx#locator-fill). See the [Text input](#text-input) section above. You only need to type characters if there is special keyboard handling on the page.
:::

Type into the field character by character, as if it was a user with a real keyboard with [Locator.TypeAsync()](/api/class-locator.mdx#locator-type).

```csharp
Expand All @@ -115,10 +119,6 @@ await page.Locator("#area").TypeAsync("Hello World!");

This method will emit all the necessary keyboard events, with all the `keydown`, `keyup`, `keypress` events in place. You can even specify the optional `delay` between the key presses to simulate real user behavior.

:::note
Most of the time, [Page.FillAsync()](/api/class-page.mdx#page-fill) will just work. You only need to type characters if there is special keyboard handling on the page.
:::

## Keys and shortcuts

```csharp
Expand Down
2 changes: 1 addition & 1 deletion dotnet/versioned_docs/version-stable/intro.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ See our doc on [Test Runners](./test-runners.mdx) to learn more about running te
- Playwright is distributed as a .NET Standard 2.0 library. We recommend .NET 6.
- Windows 10+, Windows Server 2016+ or Windows Subsystem for Linux (WSL).
- MacOS 12 Monterey or MacOS 13 Ventura.
- Debian 11, Ubuntu 20.04 or Ubuntu 22.04.
- Debian 11, Debian 12, Ubuntu 20.04 or Ubuntu 22.04.

## What's next
- [Write tests using web first assertions, page fixtures and locators](./writing-tests.mdx)
Expand Down
Loading

0 comments on commit 9b00ff7

Please sign in to comment.