Skip to content
Merged
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
53 changes: 31 additions & 22 deletions dotnet/versioned_docs/version-stable/actionability.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -16,31 +16,32 @@ For example, for [Locator.ClickAsync()](/api/class-locator.mdx#locator-click), P
- element is [Stable], as in not animating or completed animation
- element [Receives Events], as in not obscured by other elements
- element is [Enabled]
- element is [Not Inert]

Here is the complete list of actionability checks performed for each action:

| Action | [Visible] | [Stable] | [Receives Events] | [Enabled] | [Editable] |
| :- | :-: | :-: | :-: | :-: | :-: |
| [Locator.CheckAsync()](/api/class-locator.mdx#locator-check) | Yes | Yes | Yes | Yes | - |
| [Locator.ClickAsync()](/api/class-locator.mdx#locator-click) | Yes | Yes | Yes | Yes | - |
| [Locator.DblClickAsync()](/api/class-locator.mdx#locator-dblclick) | Yes | Yes | Yes | Yes | - |
| [Locator.SetCheckedAsync()](/api/class-locator.mdx#locator-set-checked) | Yes | Yes | Yes | Yes | - |
| [Locator.TapAsync()](/api/class-locator.mdx#locator-tap) | Yes | Yes | Yes | Yes | - |
| [Locator.UncheckAsync()](/api/class-locator.mdx#locator-uncheck) | Yes | Yes | Yes | Yes | - |
| [Locator.HoverAsync()](/api/class-locator.mdx#locator-hover) | Yes | Yes | Yes | - | - |
| [Locator.DragToAsync()](/api/class-locator.mdx#locator-drag-to) | Yes | Yes | Yes | - | - |
| [Locator.ScreenshotAsync()](/api/class-locator.mdx#locator-screenshot) | Yes | Yes | - | - | - |
| [Locator.FillAsync()](/api/class-locator.mdx#locator-fill) | Yes | - | - | Yes | Yes |
| [Locator.ClearAsync()](/api/class-locator.mdx#locator-clear) | Yes | - | - | Yes | Yes |
| [Locator.SelectOptionAsync()](/api/class-locator.mdx#locator-select-option) | Yes | - | - | Yes | - |
| [Locator.SelectTextAsync()](/api/class-locator.mdx#locator-select-text) | Yes | - | - | - | - |
| [Locator.ScrollIntoViewIfNeededAsync()](/api/class-locator.mdx#locator-scroll-into-view-if-needed) | - | Yes | - | - | - |
| [Locator.BlurAsync()](/api/class-locator.mdx#locator-blur) | - | - | - | - | - |
| [Locator.DispatchEventAsync()](/api/class-locator.mdx#locator-dispatch-event) | - | - | - | - | - |
| [Locator.FocusAsync()](/api/class-locator.mdx#locator-focus) | - | - | - | - | - |
| [Locator.PressAsync()](/api/class-locator.mdx#locator-press) | - | - | - | - | - |
| [Locator.PressSequentiallyAsync()](/api/class-locator.mdx#locator-press-sequentially) | - | - | - | - | - |
| [Locator.SetInputFilesAsync()](/api/class-locator.mdx#locator-set-input-files) | - | - | - | - | - |
| Action | [Visible] | [Stable] | [Receives Events] | [Enabled] | [Editable] | [Not Inert] |
| :- | :-: | :-: | :-: | :-: | :-: | :-: |
| [Locator.CheckAsync()](/api/class-locator.mdx#locator-check) | Yes | Yes | Yes | Yes | - | Yes |
| [Locator.ClickAsync()](/api/class-locator.mdx#locator-click) | Yes | Yes | Yes | Yes | - | Yes |
| [Locator.DblClickAsync()](/api/class-locator.mdx#locator-dblclick) | Yes | Yes | Yes | Yes | - | Yes |
| [Locator.SetCheckedAsync()](/api/class-locator.mdx#locator-set-checked) | Yes | Yes | Yes | Yes | - | Yes |
| [Locator.TapAsync()](/api/class-locator.mdx#locator-tap) | Yes | Yes | Yes | Yes | - | Yes |
| [Locator.UncheckAsync()](/api/class-locator.mdx#locator-uncheck) | Yes | Yes | Yes | Yes | - | Yes |
| [Locator.HoverAsync()](/api/class-locator.mdx#locator-hover) | Yes | Yes | Yes | - | - | - |
| [Locator.DragToAsync()](/api/class-locator.mdx#locator-drag-to) | Yes | Yes | Yes | - | - | - |
| [Locator.ScreenshotAsync()](/api/class-locator.mdx#locator-screenshot) | Yes | Yes | - | - | - | - |
| [Locator.FillAsync()](/api/class-locator.mdx#locator-fill) | Yes | - | - | Yes | Yes | Yes |
| [Locator.ClearAsync()](/api/class-locator.mdx#locator-clear) | Yes | - | - | Yes | Yes | Yes |
| [Locator.SelectOptionAsync()](/api/class-locator.mdx#locator-select-option) | Yes | - | - | Yes | - | Yes |
| [Locator.SelectTextAsync()](/api/class-locator.mdx#locator-select-text) | Yes | - | - | - | - | - |
| [Locator.ScrollIntoViewIfNeededAsync()](/api/class-locator.mdx#locator-scroll-into-view-if-needed) | - | Yes | - | - | - | - |
| [Locator.BlurAsync()](/api/class-locator.mdx#locator-blur) | - | - | - | - | - | - |
| [Locator.DispatchEventAsync()](/api/class-locator.mdx#locator-dispatch-event) | - | - | - | - | - | - |
| [Locator.FocusAsync()](/api/class-locator.mdx#locator-focus) | - | - | - | - | - | - |
| [Locator.PressAsync()](/api/class-locator.mdx#locator-press) | - | - | - | - | - | - |
| [Locator.PressSequentiallyAsync()](/api/class-locator.mdx#locator-press-sequentially) | - | - | - | - | - | - |
| [Locator.SetInputFilesAsync()](/api/class-locator.mdx#locator-set-input-files) | - | - | - | - | - | - |

## Forcing actions

Expand Down Expand Up @@ -108,6 +109,13 @@ Element is **readonly** when:
- it is a `<select>`, `<input>` or `<textarea>` with a `[readonly]` attribute;
- it has an `[aria-readonly=true]` attribute and an aria role that [supports it](https://w3c.github.io/aria/#aria-readonly).

## Not Inert

Element is considered not inert when it is **not** a part of an inert subtree. Inert elements cannot be focused, clicked or otherwise interacted with.

Element is **inert** when:
- it is an element with the [`inert`](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Global_attributes/inert) attribute, or a descendant of such an element.

## Receives Events

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)`.
Expand All @@ -121,6 +129,7 @@ For example, consider a scenario where Playwright will click `Sign Up` button re
[Enabled]: #enabled "Enabled"
[Editable]: #editable "Editable"
[Receives Events]: #receives-events "Receives Events"
[Not Inert]: #not-inert "Not Inert"


[APIRequest]: /api/class-apirequest.mdx "APIRequest"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -628,13 +628,13 @@ Note that only `WebSocket`s created after this method was called will be routed.
Below is an example of a simple handler that blocks some websocket messages. See [WebSocketRoute] for more details and examples.

```csharp
await context.RouteWebSocketAsync("/ws", async ws => {
ws.RouteSend(message => {
if (message == "to-be-blocked")
await context.RouteWebSocketAsync("/ws", ws => {
var server = ws.ConnectToServer();
ws.OnMessage(frame => {
if (frame.Text == "to-be-blocked")
return;
ws.Send(message);
server.Send(frame.Text);
});
await ws.ConnectAsync();
});
```

Expand Down Expand Up @@ -941,7 +941,7 @@ await BrowserContext.StorageStateAsync(options);

**Arguments**
- `options` `BrowserContextStorageStateOptions?` *(optional)*
- `Credentials` [bool]? *(optional)* <font size="2">Added in: v1.61</font><a aria-hidden="true" tabIndex="-1" class="list-anchor-link" id="browser-context-storage-state-option-credentials"/><a href="#browser-context-storage-state-option-credentials" class="list-anchor">#</a>
- `Credentials` [bool]? *(optional)* <font size="2">Added in: v1.62</font><a aria-hidden="true" tabIndex="-1" class="list-anchor-link" id="browser-context-storage-state-option-credentials"/><a href="#browser-context-storage-state-option-credentials" class="list-anchor">#</a>

Set to `true` to include the context's virtual WebAuthn [BrowserContext.Credentials](/api/class-browsercontext.mdx#browser-context-credentials) (passkeys) in the storage state snapshot. The captured credentials carry their private keys and signature counters, so they can be re-seeded into a later context via the [StorageState](/api/class-browser.mdx#browser-new-context-option-storage-state) option or [BrowserContext.SetStorageStateAsync()](/api/class-browsercontext.mdx#browser-context-set-storage-state). Note that restoring the storage state that contains credentials will automatically install the virtual WebAuthn authenticator (see [Credentials.InstallAsync()](/api/class-credentials.mdx#credentials-install)), and prevent all real authenticators from working in this context.
- `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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,8 @@ var page = defaultContext.Pages[0];
- `endpointURL` [string] <font size="2">Added in: v1.11</font><a aria-hidden="true" tabIndex="-1" class="list-anchor-link" id="browser-type-connect-over-cdp-option-endpoint-url"/><a href="#browser-type-connect-over-cdp-option-endpoint-url" class="list-anchor">#</a>

A CDP websocket endpoint or http url to connect to. For example `http://localhost:9222/` or `ws://127.0.0.1:9222/devtools/browser/387adf4c-243f-4051-a181-46798f4a46f4`.

Alternatively, a browser channel name such as `chrome` or `msedge` to connect to a browser with remote debugging enabled in its default user data directory. On Linux, Playwright uses `CHROME_USER_DATA_DIR` when set. Otherwise, it uses `CHROME_CONFIG_HOME`, then `XDG_CONFIG_HOME`, then `~/.config` to locate that directory.
- `options` `BrowserTypeConnectOverCDPOptions?` *(optional)*
- `ArtifactsDir` [string]? *(optional)* <font size="2">Added in: v1.61</font><a aria-hidden="true" tabIndex="-1" class="list-anchor-link" id="browser-type-connect-over-cdp-option-artifacts-dir"/><a href="#browser-type-connect-over-cdp-option-artifacts-dir" class="list-anchor">#</a>

Expand All @@ -128,7 +130,7 @@ var page = defaultContext.Pages[0];
Tells Playwright that it runs on the same host as the CDP server. It will enable certain optimizations that rely upon the file system being the same between Playwright and the Browser.
- `NoDefaults` [bool]? *(optional)* <font size="2">Added in: v1.60</font><a aria-hidden="true" tabIndex="-1" class="list-anchor-link" id="browser-type-connect-over-cdp-option-no-defaults"/><a href="#browser-type-connect-over-cdp-option-no-defaults" class="list-anchor">#</a>

When true, Playwright will not apply its default overrides to the existing default browser context. Specifically, [AcceptDownloads](/api/class-browser.mdx#browser-new-context-option-accept-downloads) is left at the browser's setting, focus emulation is not enabled, and media emulation options (such as [ColorScheme](/api/class-browser.mdx#browser-new-context-option-color-scheme), [ReducedMotion](/api/class-browser.mdx#browser-new-context-option-reduced-motion), [ForcedColors](/api/class-browser.mdx#browser-new-context-option-forced-colors), and [Contrast](/api/class-browser.mdx#browser-new-context-option-contrast)) are not applied. Useful when attaching to a user's daily-driver browser where these overrides would interfere with existing browser state. New contexts created via [Browser.NewContextAsync()](/api/class-browser.mdx#browser-new-context) are not affected. Defaults to `false`.
When true, Playwright will not apply its default overrides to the existing default browser context. Specifically, [AcceptDownloads](/api/class-browser.mdx#browser-new-context-option-accept-downloads) and font families are left at the browser's settings, focus emulation is not enabled, and media emulation options (such as [ColorScheme](/api/class-browser.mdx#browser-new-context-option-color-scheme), [ReducedMotion](/api/class-browser.mdx#browser-new-context-option-reduced-motion), [ForcedColors](/api/class-browser.mdx#browser-new-context-option-forced-colors), and [Contrast](/api/class-browser.mdx#browser-new-context-option-contrast)) are not applied. Useful when attaching to a user's daily-driver browser where these overrides would interfere with existing browser state. New contexts created via [Browser.NewContextAsync()](/api/class-browser.mdx#browser-new-context) are not affected. Defaults to `false`.
- `SlowMo` [float]? *(optional)* <font size="2">Added in: v1.11</font><a aria-hidden="true" tabIndex="-1" class="list-anchor-link" id="browser-type-connect-over-cdp-option-slow-mo"/><a href="#browser-type-connect-over-cdp-option-slow-mo" class="list-anchor">#</a>

Slows down Playwright operations by the specified amount of milliseconds. Useful so that you can see what is going on. Defaults to 0.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ CdpSession.Event(eventName);
**Usage**

```csharp
await CdpSession.SendAsync(method, params);
await CdpSession.SendAsync(method, params, options);
```

**Arguments**
Expand All @@ -86,6 +86,10 @@ await CdpSession.SendAsync(method, params);
- `args` [Map]?&lt;[string], Args&gt; *(optional)* <font size="2">Added in: v1.30</font><a aria-hidden="true" tabIndex="-1" class="list-anchor-link" id="cdp-session-send-option-params"/><a href="#cdp-session-send-option-params" class="list-anchor">#</a>

Optional method parameters.
- `options` `CdpSessionSendOptions?` *(optional)*
- `Timeout` [float]? *(optional)* <font size="2">Added in: v1.65</font><a aria-hidden="true" tabIndex="-1" class="list-anchor-link" id="cdp-session-send-option-timeout"/><a href="#cdp-session-send-option-timeout" class="list-anchor">#</a>

Maximum time in milliseconds to wait for the response. Defaults to `0` - no timeout.

**Returns**
- [JsonElement?]<a aria-hidden="true" tabIndex="-1" class="list-anchor-link" id="cdp-session-send-return"/><a href="#cdp-session-send-return" class="list-anchor">#</a>
Expand Down
4 changes: 2 additions & 2 deletions dotnet/versioned_docs/version-stable/api/class-clock.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ await page.Clock.FastForwardAsync("30:00");
**Arguments**
- `ticks` [long] | [string]<a aria-hidden="true" tabIndex="-1" class="list-anchor-link" id="clock-fast-forward-option-ticks"/><a href="#clock-fast-forward-option-ticks" class="list-anchor">#</a>

Time may be the number of milliseconds to advance the clock by or a human-readable string. Valid string formats are "08" for eight seconds, "01:00" for one minute and "02:34:10" for two hours, 34 minutes and ten seconds.
Time may be a finite number of milliseconds to advance the clock by or a human-readable string. Valid string formats are "08" for eight seconds, "01:00" for one minute and "02:34:10" for two hours, 34 minutes and ten seconds.

**Returns**
- [void]<a aria-hidden="true" tabIndex="-1" class="list-anchor-link" id="clock-fast-forward-return"/><a href="#clock-fast-forward-return" class="list-anchor">#</a>
Expand Down Expand Up @@ -135,7 +135,7 @@ await page.Clock.RunForAsync("30:00");
**Arguments**
- `ticks` [long] | [string]<a aria-hidden="true" tabIndex="-1" class="list-anchor-link" id="clock-run-for-option-ticks"/><a href="#clock-run-for-option-ticks" class="list-anchor">#</a>

Time may be the number of milliseconds to advance the clock by or a human-readable string. Valid string formats are "08" for eight seconds, "01:00" for one minute and "02:34:10" for two hours, 34 minutes and ten seconds.
Time may be a finite number of milliseconds to advance the clock by or a human-readable string. Valid string formats are "08" for eight seconds, "01:00" for one minute and "02:34:10" for two hours, 34 minutes and ten seconds.

**Returns**
- [void]<a aria-hidden="true" tabIndex="-1" class="list-anchor-link" id="clock-run-for-return"/><a href="#clock-run-for-return" class="list-anchor">#</a>
Expand Down
2 changes: 1 addition & 1 deletion dotnet/versioned_docs/version-stable/api/class-locator.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ Below is the HTML markup and the respective ARIA snapshot:
```

An AI-optimized snapshot, controlled by [Mode](/api/class-locator.mdx#locator-aria-snapshot-option-mode), is different from a default snapshot:
1. Includes element references `[ref=e2]`. 2. Does not wait for an element matching the locator, and throws when no elements match. 3. Includes snapshots of `<iframe>`s inside the target.
1. Includes element references `[ref=e2]`. 2. Does not wait for an element matching the locator, and throws when no elements match. 3. Includes snapshots of `<iframe>`s inside the target. 4. Can omit names that repeat printed descendants, such as a heading containing a link. Names that identify dialogs, landmarks, groups, tables and table headers are retained.

---

Expand Down
2 changes: 1 addition & 1 deletion dotnet/versioned_docs/version-stable/auth.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ Web apps use cookie-based or token-based authentication, where authenticated sta

Cookies, local storage, IndexedDB and virtual WebAuthn credentials (passkeys) can be used across different browsers. They depend on your application's authentication model which may require some combination of cookies, local storage, IndexedDB or passkeys.

The following code snippet retrieves state from an authenticated context and creates a new context with that state.
The following code snippet retrieves state from an authenticated context and creates a new context with that state. If your application stores authentication tokens in IndexedDB, such as Firebase Authentication, enable [IndexedDB](/api/class-browsercontext.mdx#browser-context-storage-state-option-indexed-db) when saving the state. IndexedDB is not included in the snapshot by default.

```csharp
// Save storage state into the file.
Expand Down
2 changes: 1 addition & 1 deletion dotnet/versioned_docs/version-stable/docker.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ For Docker and GitHub Codespaces environments, you can view and generate tests u

```json
{
"image": "mcr.microsoft.com/playwright:v1.57.0",
"image": "mcr.microsoft.com/playwright:v1.64.1-noble",
"forwardPorts": [6080],
"features": {
"desktop-lite": {
Expand Down
20 changes: 20 additions & 0 deletions dotnet/versioned_docs/version-stable/emulation.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,26 @@ await page.EmulateMediaAsync(new()

<img height="1824" width="2788" alt="playwright web in dark mode" src="https://user-images.githubusercontent.com/13063165/220411638-55d2b051-4678-4da7-9f0b-ed22f5a3c47c.png" />

The `"reducedMotion"`, `"forcedColors"` and `"contrast"` options emulate the `prefers-reduced-motion`, `forced-colors` and `prefers-contrast` media features the same way. Supported values are `'reduce'` and `'no-preference'` for reduced motion, `'active'` and `'none'` for forced colors, and `'more'` and `'no-preference'` for contrast. [Page.EmulateMediaAsync()](/api/class-page.mdx#page-emulate-media) changes them for a single page.

```csharp
// Create context with reduced motion, forced colors and more contrast
await using var context = await browser.NewContextAsync(new()
{
ReducedMotion = ReducedMotion.Reduce, // or NoPreference
ForcedColors = ForcedColors.Active, // or None
Contrast = Contrast.More // or NoPreference
});

// Change the media features for the page
await page.EmulateMediaAsync(new()
{
ReducedMotion = ReducedMotion.Reduce,
ForcedColors = ForcedColors.Active,
Contrast = Contrast.More
});
```

## User Agent

The User Agent is included in the device and therefore you will rarely need to change it however if you do need to test a different user agent you can override it with the `userAgent` property.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ A page that keeps animating or rendering costs CPU for as long as the browser is
```

When no tool call has completed for that long, the browser is closed, headed or not, the same way as if you had closed it by hand. The next tool call launches a new browser, so the agent navigates again. The timer never fires while a tool call is running.
- With `--isolated`, cookies and storage kept in memory are lost on an idle close. Use the persistent profile or `--storage-state` to keep them.
- With `--isolated`, cookies and storage kept in memory are lost on an idle close. Use the persistent profile or `--storage-state` to keep them. Each client has its own timer: the context of an idle client is closed while other clients keep working, and the browser is closed once no client has a context.
- With `--cdp-endpoint` or `--extension`, the browser is not owned by the server, so there is no default timeout, and an explicit one only disconnects from it, leaving its pages open. With `--extension`, the next tool call goes through the connect flow again.
- With `--shared-browser-context`, the timer spans all clients: a client that is idle while others keep working keeps its tabs and state, and the shared browser is closed only once every client has been idle for the timeout.

Expand Down
Loading
Loading