Skip to content

Commit

Permalink
feat(roll): roll to ToT Playwright (19-11-22) (microsoft#855)
Browse files Browse the repository at this point in the history
  • Loading branch information
playwrightmachine authored Nov 19, 2022
1 parent d9f5028 commit 98aaa73
Show file tree
Hide file tree
Showing 260 changed files with 38,460 additions and 16,848 deletions.
42 changes: 21 additions & 21 deletions dotnet/docs/actionability.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import HTMLCard from '@site/src/components/HTMLCard';

Playwright performs a range of actionability checks on the elements before making actions to ensure these actions behave as expected. It auto-waits for all the relevant checks to pass and only then performs the requested action. If the required checks do not pass within the given `timeout`, action fails with the `TimeoutError`.

For example, for [Page.ClickAsync(selector, options)](/api/class-page.mdx#page-click), Playwright will ensure that:
For example, for [Page.ClickAsync();](/api/class-page.mdx#page-click), Playwright will ensure that:
- element is [Attached] to the DOM
- element is [Visible]
- element is [Stable], as in not animating or completed animation
Expand Down Expand Up @@ -45,29 +45,29 @@ Here is the complete list of actionability checks performed for each action:

## Forcing actions

Some actions like [Page.ClickAsync(selector, options)](/api/class-page.mdx#page-click) support `force` option that disables non-essential actionability checks, for example passing truthy `force` to [Page.ClickAsync(selector, options)](/api/class-page.mdx#page-click) method will not check that the target element actually receives click events.
Some actions like [Page.ClickAsync();](/api/class-page.mdx#page-click) support `force` option that disables non-essential actionability checks, for example passing truthy `force` to [Page.ClickAsync();](/api/class-page.mdx#page-click) method will not check that the target element actually receives click events.

## Assertions

You can check the actionability state of the element using one of the following methods as well. This is typically not necessary, but it helps writing assertive tests that ensure that after certain actions, elements reach actionable state:
- [ElementHandle.IsCheckedAsync()](/api/class-elementhandle.mdx#element-handle-is-checked)
- [ElementHandle.IsDisabledAsync()](/api/class-elementhandle.mdx#element-handle-is-disabled)
- [ElementHandle.IsEditableAsync()](/api/class-elementhandle.mdx#element-handle-is-editable)
- [ElementHandle.IsEnabledAsync()](/api/class-elementhandle.mdx#element-handle-is-enabled)
- [ElementHandle.IsHiddenAsync()](/api/class-elementhandle.mdx#element-handle-is-hidden)
- [ElementHandle.IsVisibleAsync()](/api/class-elementhandle.mdx#element-handle-is-visible)
- [Page.IsCheckedAsync(selector, options)](/api/class-page.mdx#page-is-checked)
- [Page.IsDisabledAsync(selector, options)](/api/class-page.mdx#page-is-disabled)
- [Page.IsEditableAsync(selector, options)](/api/class-page.mdx#page-is-editable)
- [Page.IsEnabledAsync(selector, options)](/api/class-page.mdx#page-is-enabled)
- [Page.IsHiddenAsync(selector, options)](/api/class-page.mdx#page-is-hidden)
- [Page.IsVisibleAsync(selector, options)](/api/class-page.mdx#page-is-visible)
- [Locator.IsCheckedAsync(options)](/api/class-locator.mdx#locator-is-checked)
- [Locator.IsDisabledAsync(options)](/api/class-locator.mdx#locator-is-disabled)
- [Locator.IsEditableAsync(options)](/api/class-locator.mdx#locator-is-editable)
- [Locator.IsEnabledAsync(options)](/api/class-locator.mdx#locator-is-enabled)
- [Locator.IsHiddenAsync(options)](/api/class-locator.mdx#locator-is-hidden)
- [Locator.IsVisibleAsync(options)](/api/class-locator.mdx#locator-is-visible)
- [ElementHandle.IsCheckedAsync();](/api/class-elementhandle.mdx#element-handle-is-checked)
- [ElementHandle.IsDisabledAsync();](/api/class-elementhandle.mdx#element-handle-is-disabled)
- [ElementHandle.IsEditableAsync();](/api/class-elementhandle.mdx#element-handle-is-editable)
- [ElementHandle.IsEnabledAsync();](/api/class-elementhandle.mdx#element-handle-is-enabled)
- [ElementHandle.IsHiddenAsync();](/api/class-elementhandle.mdx#element-handle-is-hidden)
- [ElementHandle.IsVisibleAsync();](/api/class-elementhandle.mdx#element-handle-is-visible)
- [Page.IsCheckedAsync();](/api/class-page.mdx#page-is-checked)
- [Page.IsDisabledAsync();](/api/class-page.mdx#page-is-disabled)
- [Page.IsEditableAsync();](/api/class-page.mdx#page-is-editable)
- [Page.IsEnabledAsync();](/api/class-page.mdx#page-is-enabled)
- [Page.IsHiddenAsync();](/api/class-page.mdx#page-is-hidden)
- [Page.IsVisibleAsync();](/api/class-page.mdx#page-is-visible)
- [Locator.IsCheckedAsync();](/api/class-locator.mdx#locator-is-checked)
- [Locator.IsDisabledAsync();](/api/class-locator.mdx#locator-is-disabled)
- [Locator.IsEditableAsync();](/api/class-locator.mdx#locator-is-editable)
- [Locator.IsEnabledAsync();](/api/class-locator.mdx#locator-is-enabled)
- [Locator.IsHiddenAsync();](/api/class-locator.mdx#locator-is-hidden)
- [Locator.IsVisibleAsync();](/api/class-locator.mdx#locator-is-visible)

<br/>

Expand Down Expand Up @@ -95,7 +95,7 @@ Element is considered editable when it is [enabled] and does not have `readonly`

Element is considered receiving pointer events when it is the hit target of the pointer event at the action point. For example, when clicking at the point `(10;10)`, Playwright checks whether some other element (usually an overlay) will instead capture the click at `(10;10)`.

For example, consider a scenario where Playwright will click `Sign Up` button regardless of when the [Page.ClickAsync(selector, options)](/api/class-page.mdx#page-click) call was made:
For example, consider a scenario where Playwright will click `Sign Up` button regardless of when the [Page.ClickAsync();](/api/class-page.mdx#page-click) call was made:
- page is checking that user name is unique and `Sign Up` button is disabled;
- after checking with the server, the disabled `Sign Up` button is replaced with another one that is now enabled.

Expand Down
2 changes: 1 addition & 1 deletion dotnet/docs/api-testing.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ The following test creates a new issue via user interface in the browser and the

## Reuse authentication state

Web apps use cookie-based or token-based authentication, where authenticated state is stored as [cookies](https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies). Playwright provides [ApiRequestContext.StorageStateAsync(options)](/api/class-apirequestcontext.mdx#api-request-context-storage-state) method that can be used to retrieve storage state from an authenticated context and then create new contexts with that state.
Web apps use cookie-based or token-based authentication, where authenticated state is stored as [cookies](https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies). Playwright provides [ApiRequestContext.StorageStateAsync();](/api/class-apirequestcontext.mdx#api-request-context-storage-state) method that can be used to retrieve storage state from an authenticated context and then create new contexts with that state.

Storage state is interchangeable between [BrowserContext] and [APIRequestContext]. You can use it to log in via API calls and then create a new context with cookies already there. The following code snippet retrieves state from an authenticated [APIRequestContext] and creates a new [BrowserContext] with that state.

Expand Down
22 changes: 15 additions & 7 deletions dotnet/docs/api/class-accessibility.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,12 @@ Rendering engines of Chromium, Firefox and WebKit have a concept of "accessibili
Most of the accessibility tree gets filtered out when converting from internal browser AX Tree to Platform-specific AX-Tree or by assistive technologies themselves. By default, Playwright tries to approximate this filtering, exposing only the "interesting" nodes of the tree.


- [Accessibility.SnapshotAsync(options)](/api/class-accessibility.mdx#accessibility-snapshot)
---

## Accessibility.SnapshotAsync(options) {#accessibility-snapshot}
## SnapshotAsync {#accessibility-snapshot}

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

- `options` &#60;`AccessibilitySnapshotOptions?`&#62;
- `InterestingOnly`<a aria-hidden="true" tabindex="-1" class="list-anchor-link" id="accessibility-snapshot-option-interesting-only"/> &#60;[bool]?&#62; Prune uninteresting nodes from the tree. Defaults to `true`.<a href="#accessibility-snapshot-option-interesting-only" class="list-anchor">#</a>
- `Root`<a aria-hidden="true" tabindex="-1" class="list-anchor-link" id="accessibility-snapshot-option-root"/> &#60;[ElementHandle]?&#62; The root DOM element for the snapshot. Defaults to the whole page.<a href="#accessibility-snapshot-option-root" class="list-anchor">#</a>
- returns:<a aria-hidden="true" tabindex="-1" class="list-anchor-link" id="accessibility-snapshot-return"/> &#60;[JsonElement]?&#62;<a href="#accessibility-snapshot-return" class="list-anchor">#</a>

**DEPRECATED** This method is deprecated. Please use other libraries such as [Axe](https://www.deque.com/axe/) if you need to test page accessibility. See our Node.js [guide](https://playwright.dev/docs/accessibility-testing) for integration with Axe.

Captures the current state of the accessibility tree. The returned object represents the root accessible node of the page.
Expand All @@ -50,6 +45,19 @@ var accessibilitySnapshot = await page.Accessibility.SnapshotAsync();
Console.WriteLine(System.Text.Json.JsonSerializer.Serialize(accessibilitySnapshot));
```

#### Usage

```csharp
await Accessibility.SnapshotAsync(options);
```

#### Parameters
- `options` &#60;`AccessibilitySnapshotOptions?`&#62;
- `InterestingOnly` &#60;[bool]?&#62; Prune uninteresting nodes from the tree. Defaults to `true`.<a aria-hidden="true" tabindex="-1" class="list-anchor-link" id="accessibility-snapshot-option-interesting-only"/><a href="#accessibility-snapshot-option-interesting-only" class="list-anchor">#</a>
- `Root` &#60;[ElementHandle]?&#62; The root DOM element for the snapshot. Defaults to the whole page.<a aria-hidden="true" tabindex="-1" class="list-anchor-link" id="accessibility-snapshot-option-root"/><a href="#accessibility-snapshot-option-root" class="list-anchor">#</a>

#### Returns
- &#60;[JsonElement]?&#62;<a aria-hidden="true" tabindex="-1" class="list-anchor-link" id="accessibility-snapshot-return"/><a href="#accessibility-snapshot-return" class="list-anchor">#</a>

[Accessibility]: /api/class-accessibility.mdx "Accessibility"
[APIRequest]: /api/class-apirequest.mdx "APIRequest"
Expand Down
35 changes: 22 additions & 13 deletions dotnet/docs/api/class-apirequest.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -9,34 +9,43 @@ import HTMLCard from '@site/src/components/HTMLCard';
Exposes API that can be used for the Web API testing. This class is used for creating [APIRequestContext] instance which in turn can be used for sending web requests. An instance of this class can be obtained via [Playwright.APIRequest](/api/class-playwright.mdx#playwright-request). For more information see [APIRequestContext].


- [ApiRequest.NewContextAsync(options)](/api/class-apirequest.mdx#api-request-new-context)
---

## ApiRequest.NewContextAsync(options) {#api-request-new-context}
## NewContextAsync {#api-request-new-context}

<font size="2" style={{position: "relative", top: "-20px"}}>Added in: v1.16</font>

Creates new instances of [APIRequestContext].

#### Usage

```csharp
await ApiRequest.NewContextAsync(options);
```

#### Parameters
- `options` &#60;`ApiRequestNewContextOptions?`&#62;
- `BaseURL`<a aria-hidden="true" tabindex="-1" class="list-anchor-link" id="api-request-new-context-option-base-url"/> &#60;[string]?&#62; Methods like [ApiRequestContext.GetAsync(url, options)](/api/class-apirequestcontext.mdx#api-request-context-get) take the base URL into consideration by using the [`URL()`](https://developer.mozilla.org/en-US/docs/Web/API/URL/URL) constructor for building the corresponding URL. Examples:<a href="#api-request-new-context-option-base-url" class="list-anchor">#</a>
- `BaseURL` &#60;[string]?&#62; Methods like [ApiRequestContext.GetAsync();](/api/class-apirequestcontext.mdx#api-request-context-get) take the base URL into consideration by using the [`URL()`](https://developer.mozilla.org/en-US/docs/Web/API/URL/URL) constructor for building the corresponding URL. Examples:<a aria-hidden="true" tabindex="-1" class="list-anchor-link" id="api-request-new-context-option-base-url"/><a href="#api-request-new-context-option-base-url" class="list-anchor">#</a>
* baseURL: `http://localhost:3000` and sending request to `/bar.html` results in `http://localhost:3000/bar.html`
* baseURL: `http://localhost:3000/foo/` and sending request to `./bar.html` results in `http://localhost:3000/foo/bar.html`
* baseURL: `http://localhost:3000/foo` (without trailing slash) and navigating to `./bar.html` results in `http://localhost:3000/bar.html`
- `ExtraHTTPHeaders`<a aria-hidden="true" tabindex="-1" class="list-anchor-link" id="api-request-new-context-option-extra-http-headers"/> &#60;[IDictionary]?<[string], [string]>&#62; An object containing additional HTTP headers to be sent with every request.<a href="#api-request-new-context-option-extra-http-headers" class="list-anchor">#</a>
- `HttpCredentials`<a aria-hidden="true" tabindex="-1" class="list-anchor-link" id="api-request-new-context-option-http-credentials"/> &#60;HttpCredentials?&#62; Credentials for [HTTP authentication](https://developer.mozilla.org/en-US/docs/Web/HTTP/Authentication).<a href="#api-request-new-context-option-http-credentials" class="list-anchor">#</a>
- `ExtraHTTPHeaders` &#60;[IDictionary]?<[string], [string]>&#62; An object containing additional HTTP headers to be sent with every request.<a aria-hidden="true" tabindex="-1" class="list-anchor-link" id="api-request-new-context-option-extra-http-headers"/><a href="#api-request-new-context-option-extra-http-headers" class="list-anchor">#</a>
- `HttpCredentials` &#60;HttpCredentials?&#62; Credentials for [HTTP authentication](https://developer.mozilla.org/en-US/docs/Web/HTTP/Authentication).<a aria-hidden="true" tabindex="-1" class="list-anchor-link" id="api-request-new-context-option-http-credentials"/><a href="#api-request-new-context-option-http-credentials" class="list-anchor">#</a>
- `Username` &#60;[string]&#62;
- `Password` &#60;[string]&#62;
- `IgnoreHTTPSErrors`<a aria-hidden="true" tabindex="-1" class="list-anchor-link" id="api-request-new-context-option-ignore-https-errors"/> &#60;[bool]?&#62; Whether to ignore HTTPS errors when sending network requests. Defaults to `false`.<a href="#api-request-new-context-option-ignore-https-errors" class="list-anchor">#</a>
- `Proxy`<a aria-hidden="true" tabindex="-1" class="list-anchor-link" id="api-request-new-context-option-proxy"/> &#60;Proxy?&#62; Network proxy settings.<a href="#api-request-new-context-option-proxy" class="list-anchor">#</a>
- `IgnoreHTTPSErrors` &#60;[bool]?&#62; Whether to ignore HTTPS errors when sending network requests. Defaults to `false`.<a aria-hidden="true" tabindex="-1" class="list-anchor-link" id="api-request-new-context-option-ignore-https-errors"/><a href="#api-request-new-context-option-ignore-https-errors" class="list-anchor">#</a>
- `Proxy` &#60;Proxy?&#62; Network proxy settings.<a aria-hidden="true" tabindex="-1" class="list-anchor-link" id="api-request-new-context-option-proxy"/><a href="#api-request-new-context-option-proxy" class="list-anchor">#</a>
- `Server` &#60;[string]&#62; Proxy to be used for all requests. HTTP and SOCKS proxies are supported, for example `http://myproxy.com:3128` or `socks5://myproxy.com:3128`. Short form `myproxy.com:3128` is considered an HTTP proxy.
- `Bypass` &#60;[string]?&#62; Optional comma-separated domains to bypass proxy, for example `".com, chromium.org, .domain.com"`.
- `Username` &#60;[string]?&#62; Optional username to use if HTTP proxy requires authentication.
- `Password` &#60;[string]?&#62; Optional password to use if HTTP proxy requires authentication.
- `StorageState`<a aria-hidden="true" tabindex="-1" class="list-anchor-link" id="api-request-new-context-option-storage-state"/> &#60;[string]?&#62; Populates context with given storage state. This option can be used to initialize context with logged-in information obtained via [BrowserContext.StorageStateAsync(options)](/api/class-browsercontext.mdx#browser-context-storage-state) or [ApiRequestContext.StorageStateAsync(options)](/api/class-apirequestcontext.mdx#api-request-context-storage-state). Either a path to the file with saved storage, or the value returned by one of [BrowserContext.StorageStateAsync(options)](/api/class-browsercontext.mdx#browser-context-storage-state) or [ApiRequestContext.StorageStateAsync(options)](/api/class-apirequestcontext.mdx#api-request-context-storage-state) methods.<a href="#api-request-new-context-option-storage-state" class="list-anchor">#</a>
- `StorageStatePath`<a aria-hidden="true" tabindex="-1" class="list-anchor-link" id="api-request-new-context-option-storage-state-path"/> &#60;[string]?&#62; Populates context with given storage state. This option can be used to initialize context with logged-in information obtained via [BrowserContext.StorageStateAsync(options)](/api/class-browsercontext.mdx#browser-context-storage-state). Path to the file with saved storage state. <font size="2">Added in: v1.18</font><a href="#api-request-new-context-option-storage-state-path" class="list-anchor">#</a>
- `Timeout`<a aria-hidden="true" tabindex="-1" class="list-anchor-link" id="api-request-new-context-option-timeout"/> &#60;[double]?&#62; Maximum time in milliseconds to wait for the response. Defaults to `30000` (30 seconds). Pass `0` to disable timeout.<a href="#api-request-new-context-option-timeout" class="list-anchor">#</a>
- `UserAgent`<a aria-hidden="true" tabindex="-1" class="list-anchor-link" id="api-request-new-context-option-user-agent"/> &#60;[string]?&#62; Specific user agent to use in this context.<a href="#api-request-new-context-option-user-agent" class="list-anchor">#</a>
- returns:<a aria-hidden="true" tabindex="-1" class="list-anchor-link" id="api-request-new-context-return"/> &#60;[APIRequestContext]&#62;<a href="#api-request-new-context-return" class="list-anchor">#</a>
- `StorageState` &#60;[string]?&#62; Populates context with given storage state. This option can be used to initialize context with logged-in information obtained via [BrowserContext.StorageStateAsync();](/api/class-browsercontext.mdx#browser-context-storage-state) or [ApiRequestContext.StorageStateAsync();](/api/class-apirequestcontext.mdx#api-request-context-storage-state). Either a path to the file with saved storage, or the value returned by one of [BrowserContext.StorageStateAsync();](/api/class-browsercontext.mdx#browser-context-storage-state) or [ApiRequestContext.StorageStateAsync();](/api/class-apirequestcontext.mdx#api-request-context-storage-state) methods.<a aria-hidden="true" tabindex="-1" class="list-anchor-link" id="api-request-new-context-option-storage-state"/><a href="#api-request-new-context-option-storage-state" class="list-anchor">#</a>
- `StorageStatePath` &#60;[string]?&#62; Populates context with given storage state. This option can be used to initialize context with logged-in information obtained via [BrowserContext.StorageStateAsync();](/api/class-browsercontext.mdx#browser-context-storage-state). Path to the file with saved storage state. <font size="2">Added in: v1.18</font><a aria-hidden="true" tabindex="-1" class="list-anchor-link" id="api-request-new-context-option-storage-state-path"/><a href="#api-request-new-context-option-storage-state-path" class="list-anchor">#</a>
- `Timeout` &#60;[double]?&#62; Maximum time in milliseconds to wait for the response. Defaults to `30000` (30 seconds). Pass `0` to disable timeout.<a aria-hidden="true" tabindex="-1" class="list-anchor-link" id="api-request-new-context-option-timeout"/><a href="#api-request-new-context-option-timeout" class="list-anchor">#</a>
- `UserAgent` &#60;[string]?&#62; Specific user agent to use in this context.<a aria-hidden="true" tabindex="-1" class="list-anchor-link" id="api-request-new-context-option-user-agent"/><a href="#api-request-new-context-option-user-agent" class="list-anchor">#</a>

Creates new instances of [APIRequestContext].
#### Returns
- &#60;[APIRequestContext]&#62;<a aria-hidden="true" tabindex="-1" class="list-anchor-link" id="api-request-new-context-return"/><a href="#api-request-new-context-return" class="list-anchor">#</a>

[Accessibility]: /api/class-accessibility.mdx "Accessibility"
[APIRequest]: /api/class-apirequest.mdx "APIRequest"
Expand Down
Loading

0 comments on commit 98aaa73

Please sign in to comment.