Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,271 changes: 1,211 additions & 60 deletions dotnet/versioned_docs/version-stable/api-testing.mdx

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ await ApiRequest.NewContextAsync(options);
- `FailOnStatusCode` [bool]? *(optional)* <font size="2">Added in: v1.51</font><a aria-hidden="true" tabIndex="-1" class="list-anchor-link" id="api-request-new-context-option-fail-on-status-code"/><a href="#api-request-new-context-option-fail-on-status-code" class="list-anchor">#</a>

Whether to throw on response codes other than 2xx and 3xx. By default response object is returned for all status codes.
- `HttpCredentials` HttpCredentials? *(optional)*<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>
- `HttpCredentials|HttpCredentialsList` HttpCredentials|HttpCredentialsList? | [IEnumerable]?&lt;HttpCredentials|HttpCredentialsList&gt; *(optional)*<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` [string]


Expand All @@ -94,6 +94,8 @@ await ApiRequest.NewContextAsync(options);
This option only applies to the requests sent from corresponding [APIRequestContext] and does not affect requests sent from the browser. `'always'` - `Authorization` header with basic authentication credentials will be sent with the each API request. `'unauthorized` - the credentials are only sent when 401 (Unauthorized) response with `WWW-Authenticate` header is received. Defaults to `'unauthorized'`.

Credentials for [HTTP authentication](https://developer.mozilla.org/en-US/docs/Web/HTTP/Authentication). If no origin is specified, the username and password are sent to any servers upon unauthorized responses.

Pass an array to use different credentials for different origins. The first entry that matches the request origin is used, and entries with no origin match any request.
- `IgnoreHTTPSErrors` [bool]? *(optional)*<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>

Whether to ignore HTTPS errors when sending network requests. Defaults to `false`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -562,6 +562,9 @@ await ApiRequestContext.StorageStateAsync(options);
- `IndexedDB` [bool]? *(optional)* <font size="2">Added in: v1.51</font><a aria-hidden="true" tabIndex="-1" class="list-anchor-link" id="api-request-context-storage-state-option-indexed-db"/><a href="#api-request-context-storage-state-option-indexed-db" class="list-anchor">#</a>

Set to `true` to include IndexedDB in the storage state snapshot.
- `Opfs` [bool]? *(optional)* <font size="2">Added in: v1.63</font><a aria-hidden="true" tabIndex="-1" class="list-anchor-link" id="api-request-context-storage-state-option-opfs"/><a href="#api-request-context-storage-state-option-opfs" class="list-anchor">#</a>

Set to `true` to include the origin private file system in the storage state snapshot.
- `Path` [string]? *(optional)*<a aria-hidden="true" tabIndex="-1" class="list-anchor-link" id="api-request-context-storage-state-option-path"/><a href="#api-request-context-storage-state-option-path" class="list-anchor">#</a>

The file path to save the storage state to. If [Path](/api/class-apirequestcontext.mdx#api-request-context-storage-state-option-path) is a relative path, then it is resolved relative to current working directory. If no path is provided, storage state is still returned, but won't be saved to the disk.
Expand All @@ -577,6 +580,8 @@ await ApiRequestContext.StorageStateAsync(options);

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

Tracing recorder for requests made through this API request context.

**Usage**

```csharp
Expand Down
8 changes: 6 additions & 2 deletions dotnet/versioned_docs/version-stable/api/class-browser.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ await browser.CloseAsync();
- `HasTouch` [bool]? *(optional)*<a aria-hidden="true" tabIndex="-1" class="list-anchor-link" id="browser-new-context-option-has-touch"/><a href="#browser-new-context-option-has-touch" class="list-anchor">#</a>

Specifies if viewport supports touch events. Defaults to false. Learn more about [mobile emulation](../emulation.mdx#devices).
- `HttpCredentials` HttpCredentials? *(optional)*<a aria-hidden="true" tabIndex="-1" class="list-anchor-link" id="browser-new-context-option-http-credentials"/><a href="#browser-new-context-option-http-credentials" class="list-anchor">#</a>
- `HttpCredentials|HttpCredentialsList` HttpCredentials|HttpCredentialsList? | [IEnumerable]?&lt;HttpCredentials|HttpCredentialsList&gt; *(optional)*<a aria-hidden="true" tabIndex="-1" class="list-anchor-link" id="browser-new-context-option-http-credentials"/><a href="#browser-new-context-option-http-credentials" class="list-anchor">#</a>
- `Username` [string]


Expand All @@ -291,6 +291,8 @@ await browser.CloseAsync();
This option only applies to the requests sent from corresponding [APIRequestContext] and does not affect requests sent from the browser. `'always'` - `Authorization` header with basic authentication credentials will be sent with the each API request. `'unauthorized` - the credentials are only sent when 401 (Unauthorized) response with `WWW-Authenticate` header is received. Defaults to `'unauthorized'`.

Credentials for [HTTP authentication](https://developer.mozilla.org/en-US/docs/Web/HTTP/Authentication). If no origin is specified, the username and password are sent to any servers upon unauthorized responses.

Pass an array to use different credentials for different origins. The first entry that matches the request origin is used, and entries with no origin match any request.
- `IgnoreHTTPSErrors` [bool]? *(optional)*<a aria-hidden="true" tabIndex="-1" class="list-anchor-link" id="browser-new-context-option-ignore-https-errors"/><a href="#browser-new-context-option-ignore-https-errors" class="list-anchor">#</a>

Whether to ignore HTTPS errors when sending network requests. Defaults to `false`.
Expand Down Expand Up @@ -496,7 +498,7 @@ await Browser.NewPageAsync(options);
- `HasTouch` [bool]? *(optional)*<a aria-hidden="true" tabIndex="-1" class="list-anchor-link" id="browser-new-page-option-has-touch"/><a href="#browser-new-page-option-has-touch" class="list-anchor">#</a>

Specifies if viewport supports touch events. Defaults to false. Learn more about [mobile emulation](../emulation.mdx#devices).
- `HttpCredentials` HttpCredentials? *(optional)*<a aria-hidden="true" tabIndex="-1" class="list-anchor-link" id="browser-new-page-option-http-credentials"/><a href="#browser-new-page-option-http-credentials" class="list-anchor">#</a>
- `HttpCredentials|HttpCredentialsList` HttpCredentials|HttpCredentialsList? | [IEnumerable]?&lt;HttpCredentials|HttpCredentialsList&gt; *(optional)*<a aria-hidden="true" tabIndex="-1" class="list-anchor-link" id="browser-new-page-option-http-credentials"/><a href="#browser-new-page-option-http-credentials" class="list-anchor">#</a>
- `Username` [string]


Expand All @@ -511,6 +513,8 @@ await Browser.NewPageAsync(options);
This option only applies to the requests sent from corresponding [APIRequestContext] and does not affect requests sent from the browser. `'always'` - `Authorization` header with basic authentication credentials will be sent with the each API request. `'unauthorized` - the credentials are only sent when 401 (Unauthorized) response with `WWW-Authenticate` header is received. Defaults to `'unauthorized'`.

Credentials for [HTTP authentication](https://developer.mozilla.org/en-US/docs/Web/HTTP/Authentication). If no origin is specified, the username and password are sent to any servers upon unauthorized responses.

Pass an array to use different credentials for different origins. The first entry that matches the request origin is used, and entries with no origin match any request.
- `IgnoreHTTPSErrors` [bool]? *(optional)*<a aria-hidden="true" tabIndex="-1" class="list-anchor-link" id="browser-new-page-option-ignore-https-errors"/><a href="#browser-new-page-option-ignore-https-errors" class="list-anchor">#</a>

Whether to ignore HTTPS errors when sending network requests. Defaults to `false`.
Expand Down
30 changes: 28 additions & 2 deletions dotnet/versioned_docs/version-stable/api/class-browsercontext.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -903,7 +903,7 @@ await BrowserContext.SetOfflineAsync(offline);

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

Clears the existing cookies, local storage, IndexedDB entries and virtual WebAuthn credentials, and sets the new storage state. When the storage state contains credentials, the virtual WebAuthn authenticator is installed (equivalent to [Credentials.InstallAsync()](/api/class-credentials.mdx#credentials-install)), preventing all real authenticators from working in this context.
Clears the existing cookies, local storage, IndexedDB entries, origin private file system entries and virtual WebAuthn credentials, and sets the new storage state. When the storage state contains credentials, the virtual WebAuthn authenticator is installed (equivalent to [Credentials.InstallAsync()](/api/class-credentials.mdx#credentials-install)), preventing all real authenticators from working in this context.

**Usage**

Expand All @@ -926,7 +926,7 @@ await context.SetStorageStateAsync("state.json");

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

Returns storage state for this browser context, contains current cookies, local storage snapshot, IndexedDB snapshot and virtual WebAuthn credentials.
Returns storage state for this browser context, contains current cookies, local storage snapshot, IndexedDB snapshot, origin private file system snapshot and virtual WebAuthn credentials.

**Usage**

Expand All @@ -942,6 +942,15 @@ await BrowserContext.StorageStateAsync(options);
- `IndexedDB` [bool]? *(optional)* <font size="2">Added in: v1.51</font><a aria-hidden="true" tabIndex="-1" class="list-anchor-link" id="browser-context-storage-state-option-indexed-db"/><a href="#browser-context-storage-state-option-indexed-db" class="list-anchor">#</a>

Set to `true` to include [IndexedDB](https://developer.mozilla.org/en-US/docs/Web/API/IndexedDB_API) in the storage state snapshot. If your application uses IndexedDB to store authentication tokens, like Firebase Authentication, enable this.
- `Opfs` [bool]? *(optional)* <font size="2">Added in: v1.63</font><a aria-hidden="true" tabIndex="-1" class="list-anchor-link" id="browser-context-storage-state-option-opfs"/><a href="#browser-context-storage-state-option-opfs" class="list-anchor">#</a>

Set to `true` to include the [origin private file system](https://developer.mozilla.org/en-US/docs/Web/API/File_System_API/Origin_private_file_system) in the storage state snapshot.

:::note

OPFS is currently not supported in ephemeral WebKit contexts.
:::

- `Path` [string]? *(optional)*<a aria-hidden="true" tabIndex="-1" class="list-anchor-link" id="browser-context-storage-state-option-path"/><a href="#browser-context-storage-state-option-path" class="list-anchor">#</a>

The file path to save the storage state to. If [Path](/api/class-browsercontext.mdx#browser-context-storage-state-option-path) is a relative path, then it is resolved relative to current working directory. If no path is provided, storage state is still returned, but won't be saved to the disk.
Expand Down Expand Up @@ -1158,6 +1167,23 @@ When no [Page.Dialog](/api/class-page.mdx#page-event-dialog) or [BrowserContext.

---

### event DialogClosed {/* #browser-context-event-dialog-closed */}

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

Emitted when a JavaScript dialog in any page belonging to this context has been closed, either by [Dialog.AcceptAsync()](/api/class-dialog.mdx#dialog-accept), by [Dialog.DismissAsync()](/api/class-dialog.mdx#dialog-dismiss), or manually by the user in the headed browser.

**Usage**

```csharp
BrowserContext.DialogClosed += async (_, dialog) => {};
```

**Event data**
- [Dialog]

---

### event Download {/* #browser-context-event-download */}

<font size="2" style={{position: "relative", top: "-20px"}}>Added in: v1.60</font><x-search>browserContext.event Download</x-search>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ await BrowserType.LaunchPersistentContextAsync(userDataDir, options);
- `Headless` [bool]? *(optional)*<a aria-hidden="true" tabIndex="-1" class="list-anchor-link" id="browser-type-launch-persistent-context-option-headless"/><a href="#browser-type-launch-persistent-context-option-headless" class="list-anchor">#</a>

Whether to run browser in headless mode. More details for [Chromium](https://developers.google.com/web/updates/2017/04/headless-chrome) and [Firefox](https://hacks.mozilla.org/2017/12/using-headless-mode-in-firefox/). Defaults to `true`.
- `HttpCredentials` HttpCredentials? *(optional)*<a aria-hidden="true" tabIndex="-1" class="list-anchor-link" id="browser-type-launch-persistent-context-option-http-credentials"/><a href="#browser-type-launch-persistent-context-option-http-credentials" class="list-anchor">#</a>
- `HttpCredentials|HttpCredentialsList` HttpCredentials|HttpCredentialsList? | [IEnumerable]?&lt;HttpCredentials|HttpCredentialsList&gt; *(optional)*<a aria-hidden="true" tabIndex="-1" class="list-anchor-link" id="browser-type-launch-persistent-context-option-http-credentials"/><a href="#browser-type-launch-persistent-context-option-http-credentials" class="list-anchor">#</a>
- `Username` [string]


Expand All @@ -435,6 +435,8 @@ await BrowserType.LaunchPersistentContextAsync(userDataDir, options);
This option only applies to the requests sent from corresponding [APIRequestContext] and does not affect requests sent from the browser. `'always'` - `Authorization` header with basic authentication credentials will be sent with the each API request. `'unauthorized` - the credentials are only sent when 401 (Unauthorized) response with `WWW-Authenticate` header is received. Defaults to `'unauthorized'`.

Credentials for [HTTP authentication](https://developer.mozilla.org/en-US/docs/Web/HTTP/Authentication). If no origin is specified, the username and password are sent to any servers upon unauthorized responses.

Pass an array to use different credentials for different origins. The first entry that matches the request origin is used, and entries with no origin match any request.
- `IgnoreAllDefaultArgs` [bool]? *(optional)* <font size="2">Added in: v1.9</font><a aria-hidden="true" tabIndex="-1" class="list-anchor-link" id="browser-type-launch-persistent-context-option-ignore-all-default-args"/><a href="#browser-type-launch-persistent-context-option-ignore-all-default-args" class="list-anchor">#</a>

If `true`, Playwright does not pass its own configurations args and only uses the ones from [Args](/api/class-browsertype.mdx#browser-type-launch-persistent-context-option-args). Dangerous option; use with care. Defaults to `false`.
Expand Down
13 changes: 11 additions & 2 deletions dotnet/versioned_docs/version-stable/api/class-frame.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,8 @@ Console.WriteLine(frame == contentFrame); // -> True

When working with iframes, you can create a frame locator that will enter the iframe and allow selecting elements in that iframe.

When called without [selector](/api/class-frame.mdx#frame-frame-locator-option-selector), the search starts in this frame or in any of the iframes inside it, so that you don't need to locate each iframe first. Note that the rest of the locator is resolved inside a single frame, just like any other locator. If it matches elements inside multiple frames, an error is thrown.

**Usage**

Following snippet locates element with text "Submit" in the iframe with id `my-frame`, like `<iframe id="my-frame">`:
Expand All @@ -337,10 +339,17 @@ var locator = frame.FrameLocator("#my-iframe").GetByText("Submit");
await locator.ClickAsync();
```

Following snippet locates a button, either in the frame or in one of the iframes inside it:

```csharp
var locator = frame.FrameLocator().GetByRole(AriaRole.Button);
await locator.ClickAsync();
```

**Arguments**
- `selector` [string]<a aria-hidden="true" tabIndex="-1" class="list-anchor-link" id="frame-frame-locator-option-selector"/><a href="#frame-frame-locator-option-selector" class="list-anchor">#</a>
- `selector` [string]? *(optional)*<a aria-hidden="true" tabIndex="-1" class="list-anchor-link" id="frame-frame-locator-option-selector"/><a href="#frame-frame-locator-option-selector" class="list-anchor">#</a>

A selector to use when resolving DOM element.
A selector that matches the frame element. When not specified, locator is matched in this frame or in any of the iframes inside it.

**Returns**
- [FrameLocator]<a aria-hidden="true" tabIndex="-1" class="list-anchor-link" id="frame-frame-locator-return"/><a href="#frame-frame-locator-return" class="list-anchor">#</a>
Expand Down
16 changes: 16 additions & 0 deletions dotnet/versioned_docs/version-stable/api/class-framelocator.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,22 @@ await page.Locator(".result-frame").ContentFrame.GetByRole(AriaRole.Button).Clic
await page.Locator(".result-frame").First.ContentFrame.getByRole(AriaRole.Button).ClickAsync();
```

**Any frame**

Calling [Page.FrameLocator()](/api/class-page.mdx#page-frame-locator) or [Frame.FrameLocator()](/api/class-frame.mdx#frame-frame-locator) without a selector creates a frame locator that starts the search in any frame of the subtree - so that you don't need to locate the iframe first.

```csharp
// Finds the button in any frame on the page:
await page.FrameLocator().GetByRole(AriaRole.Button).ClickAsync();

// Finds the iframe with id "my-frame" anywhere on the page, and clicks the button inside it:
await page.FrameLocator().Locator("#my-frame").ContentFrame.GetByRole(AriaRole.Button).ClickAsync();
```

Only the start of the search is affected - the rest of the locator is resolved inside a single frame, just like any other locator. Following the strictness rules above, an error is thrown when elements are matched in multiple frames.

Such a frame locator does not point to a particular `iframe`, so [FrameLocator.Owner](/api/class-framelocator.mdx#frame-locator-owner), [FrameLocator.First](/api/class-framelocator.mdx#frame-locator-first), [FrameLocator.Last](/api/class-framelocator.mdx#frame-locator-last) and [FrameLocator.Nth()](/api/class-framelocator.mdx#frame-locator-nth) are not supported on it.

**Converting Locator to FrameLocator**

If you have a [Locator] object pointing to an `iframe` it can be converted to [FrameLocator] using [Locator.ContentFrame](/api/class-locator.mdx#locator-content-frame).
Expand Down
Loading