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
10 changes: 7 additions & 3 deletions dotnet/docs/api/class-apirequestcontext.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,17 @@ import HTMLCard from '@site/src/components/HTMLCard';

This API is used for the Web API testing. You can use it to trigger API endpoints, configure micro-services, prepare environment or the service to your e2e test.

Each Playwright browser context has associated with it [APIRequestContext] instance which shares cookie storage with the browser context and can be accessed via [BrowserContext.APIRequest](/api/class-browsercontext.mdx#browser-context-request) or [Page.APIRequest](/api/class-page.mdx#page-request). It is also possible to create a new APIRequestContext instance manually by calling [ApiRequest.NewContextAsync()](/api/class-apirequest.mdx#api-request-new-context).
Each Playwright browser context has an associated [APIRequestContext], accessible via [BrowserContext.APIRequest](/api/class-browsercontext.mdx#browser-context-request) or [Page.APIRequest](/api/class-page.mdx#page-request) (these return the

**same instance** — `page.request` is a shortcut for `page.context().request`). You can also create a standalone, isolated instance with [ApiRequest.NewContextAsync()](/api/class-apirequest.mdx#api-request-new-context).

**Cookie management**

[APIRequestContext] returned by [BrowserContext.APIRequest](/api/class-browsercontext.mdx#browser-context-request) and [Page.APIRequest](/api/class-page.mdx#page-request) shares cookie storage with the corresponding [BrowserContext]. Each API request will have `Cookie` header populated with the values from the browser context. If the API response contains `Set-Cookie` header it will automatically update [BrowserContext] cookies and requests made from the page will pick them up. This means that if you log in using this API, your e2e test will be logged in and vice versa.
The [APIRequestContext] returned by [BrowserContext.APIRequest](/api/class-browsercontext.mdx#browser-context-request) and

[Page.APIRequest](/api/class-page.mdx#page-request) uses the same cookie jar as its [BrowserContext]:

If you want API requests to not interfere with the browser cookies you should create a new [APIRequestContext] by calling [ApiRequest.NewContextAsync()](/api/class-apirequest.mdx#api-request-new-context). Such `APIRequestContext` object will have its own isolated cookie storage.
If you want API requests that do **not** share cookies with the browser, create an isolated context via [ApiRequest.NewContextAsync()](/api/class-apirequest.mdx#api-request-new-context). Such `APIRequestContext` object will have its own isolated cookie storage.


---
Expand Down
17 changes: 17 additions & 0 deletions dotnet/docs/api/class-browser.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -657,6 +657,23 @@ Browser.Version

## Events

### event Context {#browser-event-context}

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

Emitted when a new browser context is created.

**Usage**

```csharp
Browser.Context += async (_, browserContext) => {};
```

**Event data**
- [BrowserContext]

---

### event Disconnected {#browser-event-disconnected}

<font size="2" style={{position: "relative", top: "-20px"}}>Added before v1.9</font><x-search>browser.event Disconnected</x-search>
Expand Down
102 changes: 102 additions & 0 deletions dotnet/docs/api/class-browsercontext.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -1138,6 +1138,74 @@ When no [Page.Dialog](/api/class-page.mdx#page-event-dialog) or [BrowserContext.

---

### 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>

Emitted when attachment download started in any page belonging to this context. User can access basic file operations on downloaded content via the passed [Download] instance. See also [Page.Download](/api/class-page.mdx#page-event-download) to receive events about a specific page.

**Usage**

```csharp
BrowserContext.Download += async (_, download) => {};
```

**Event data**
- [Download]

---

### event FrameAttached {#browser-context-event-frame-attached}

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

Emitted when a frame is attached in any page belonging to this context. See also [Page.FrameAttached](/api/class-page.mdx#page-event-frame-attached) to receive events about a specific page.

**Usage**

```csharp
BrowserContext.FrameAttached += async (_, frame) => {};
```

**Event data**
- [Frame]

---

### event FrameDetached {#browser-context-event-frame-detached}

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

Emitted when a frame is detached in any page belonging to this context. See also [Page.FrameDetached](/api/class-page.mdx#page-event-frame-detached) to receive events about a specific page.

**Usage**

```csharp
BrowserContext.FrameDetached += async (_, frame) => {};
```

**Event data**
- [Frame]

---

### event FrameNavigated {#browser-context-event-frame-navigated}

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

Emitted when a frame is navigated to a new url in any page belonging to this context. See also [Page.FrameNavigated](/api/class-page.mdx#page-event-frame-navigated) to receive events about navigations in a specific page.

**Usage**

```csharp
BrowserContext.FrameNavigated += async (_, frame) => {};
```

**Event data**
- [Frame]

---

### event Page {#browser-context-event-page}

<font size="2" style={{position: "relative", top: "-20px"}}>Added before v1.9</font><x-search>browserContext.event Page</x-search>
Expand Down Expand Up @@ -1169,6 +1237,40 @@ BrowserContext.Page += async (_, page) => {};

---

### event PageClose {#browser-context-event-page-close}

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

Emitted when a page in this context is closed. See also [Page.Close](/api/class-page.mdx#page-event-close) to receive events about a specific page.

**Usage**

```csharp
BrowserContext.PageClose += async (_, page) => {};
```

**Event data**
- [Page]

---

### event PageLoad {#browser-context-event-page-load}

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

Emitted when the JavaScript [`load`](https://developer.mozilla.org/en-US/docs/Web/Events/load) event is dispatched in any page belonging to this context. See also [Page.Load](/api/class-page.mdx#page-event-load) to receive events about a specific page.

**Usage**

```csharp
BrowserContext.PageLoad += async (_, page) => {};
```

**Event data**
- [Page]

---

### event Request {#browser-context-event-request}

<font size="2" style={{position: "relative", top: "-20px"}}>Added in: v1.12</font><x-search>browserContext.event Request</x-search>
Expand Down
3 changes: 3 additions & 0 deletions dotnet/docs/api/class-browsertype.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,9 @@ var page = defaultContext.Pages[0];
- `IsLocal` [bool]? *(optional)* <font size="2">Added in: v1.58</font><a aria-hidden="true" tabIndex="-1" class="list-anchor-link" id="browser-type-connect-over-cdp-option-is-local"/><a href="#browser-type-connect-over-cdp-option-is-local" class="list-anchor">#</a>

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.53</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 send default overrides to the browser on the default context. This includes `Browser.setDownloadBehavior`, `Emulation.setFocusEmulationEnabled`, and `Emulation.setEmulatedMedia`. Useful when attaching to a user's daily-driver browser where these overrides would interfere with existing browser state. New contexts created via [browser.newContext([options])](https://playwright.dev/docs/api/class-browser#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
7 changes: 6 additions & 1 deletion dotnet/docs/api/class-frame.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,11 @@ await page
An attribute that is usually set by `aria-checked` or native `<input type=checkbox>` controls.

Learn more about [`aria-checked`](https://www.w3.org/TR/wai-aria-1.2/#aria-checked).
- `Description|DescriptionRegex` [string]? | [Regex]? *(optional)* <font size="2">Added in: v1.60</font><a aria-hidden="true" tabIndex="-1" class="list-anchor-link" id="frame-get-by-role-option-description"/><a href="#frame-get-by-role-option-description" class="list-anchor">#</a>

Option to match the [accessible description](https://w3c.github.io/accname/#dfn-accessible-description). By default, matching is case-insensitive and searches for a substring, use [Exact](/api/class-frame.mdx#frame-get-by-role-option-exact) to control this behavior.

Learn more about [accessible description](https://w3c.github.io/accname/#dfn-accessible-description).
- `Disabled` [bool]? *(optional)*<a aria-hidden="true" tabIndex="-1" class="list-anchor-link" id="frame-get-by-role-option-disabled"/><a href="#frame-get-by-role-option-disabled" class="list-anchor">#</a>

An attribute that is usually set by `aria-disabled` or `disabled`.
Expand All @@ -505,7 +510,7 @@ await page

- `Exact` [bool]? *(optional)* <font size="2">Added in: v1.28</font><a aria-hidden="true" tabIndex="-1" class="list-anchor-link" id="frame-get-by-role-option-exact"/><a href="#frame-get-by-role-option-exact" class="list-anchor">#</a>

Whether [Name|NameRegex](/api/class-frame.mdx#frame-get-by-role-option-name) is matched exactly: case-sensitive and whole-string. Defaults to false. Ignored when [Name|NameRegex](/api/class-frame.mdx#frame-get-by-role-option-name) is a regular expression. Note that exact match still trims whitespace.
Whether [Name|NameRegex](/api/class-frame.mdx#frame-get-by-role-option-name) and [Description|DescriptionRegex](/api/class-frame.mdx#frame-get-by-role-option-description) are matched exactly: case-sensitive and whole-string. Defaults to false. Ignored when the value is a regular expression. Note that exact match still trims whitespace.
- `Expanded` [bool]? *(optional)*<a aria-hidden="true" tabIndex="-1" class="list-anchor-link" id="frame-get-by-role-option-expanded"/><a href="#frame-get-by-role-option-expanded" class="list-anchor">#</a>

An attribute that is usually set by `aria-expanded`.
Expand Down
7 changes: 6 additions & 1 deletion dotnet/docs/api/class-framelocator.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,11 @@ await page
An attribute that is usually set by `aria-checked` or native `<input type=checkbox>` controls.

Learn more about [`aria-checked`](https://www.w3.org/TR/wai-aria-1.2/#aria-checked).
- `Description|DescriptionRegex` [string]? | [Regex]? *(optional)* <font size="2">Added in: v1.60</font><a aria-hidden="true" tabIndex="-1" class="list-anchor-link" id="frame-locator-get-by-role-option-description"/><a href="#frame-locator-get-by-role-option-description" class="list-anchor">#</a>

Option to match the [accessible description](https://w3c.github.io/accname/#dfn-accessible-description). By default, matching is case-insensitive and searches for a substring, use [Exact](/api/class-framelocator.mdx#frame-locator-get-by-role-option-exact) to control this behavior.

Learn more about [accessible description](https://w3c.github.io/accname/#dfn-accessible-description).
- `Disabled` [bool]? *(optional)*<a aria-hidden="true" tabIndex="-1" class="list-anchor-link" id="frame-locator-get-by-role-option-disabled"/><a href="#frame-locator-get-by-role-option-disabled" class="list-anchor">#</a>

An attribute that is usually set by `aria-disabled` or `disabled`.
Expand All @@ -222,7 +227,7 @@ await page

- `Exact` [bool]? *(optional)* <font size="2">Added in: v1.28</font><a aria-hidden="true" tabIndex="-1" class="list-anchor-link" id="frame-locator-get-by-role-option-exact"/><a href="#frame-locator-get-by-role-option-exact" class="list-anchor">#</a>

Whether [Name|NameRegex](/api/class-framelocator.mdx#frame-locator-get-by-role-option-name) is matched exactly: case-sensitive and whole-string. Defaults to false. Ignored when [Name|NameRegex](/api/class-framelocator.mdx#frame-locator-get-by-role-option-name) is a regular expression. Note that exact match still trims whitespace.
Whether [Name|NameRegex](/api/class-framelocator.mdx#frame-locator-get-by-role-option-name) and [Description|DescriptionRegex](/api/class-framelocator.mdx#frame-locator-get-by-role-option-description) are matched exactly: case-sensitive and whole-string. Defaults to false. Ignored when the value is a regular expression. Note that exact match still trims whitespace.
- `Expanded` [bool]? *(optional)*<a aria-hidden="true" tabIndex="-1" class="list-anchor-link" id="frame-locator-get-by-role-option-expanded"/><a href="#frame-locator-get-by-role-option-expanded" class="list-anchor">#</a>

An attribute that is usually set by `aria-expanded`.
Expand Down
64 changes: 63 additions & 1 deletion dotnet/docs/api/class-locator.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,9 @@ await page.GetByRole(AriaRole.Link).AriaSnapshotAsync();

**Arguments**
- `options` `LocatorAriaSnapshotOptions?` *(optional)*
- `Boxes` [bool]? *(optional)* <font size="2">Added in: v1.60</font><a aria-hidden="true" tabIndex="-1" class="list-anchor-link" id="locator-aria-snapshot-option-boxes"/><a href="#locator-aria-snapshot-option-boxes" class="list-anchor">#</a>

When `true`, appends each element's bounding box as `[box=x,y,width,height]` to the snapshot. Defaults to `false`.
- `Depth` [int]? *(optional)* <font size="2">Added in: v1.59</font><a aria-hidden="true" tabIndex="-1" class="list-anchor-link" id="locator-aria-snapshot-option-depth"/><a href="#locator-aria-snapshot-option-depth" class="list-anchor">#</a>

When specified, limits the depth of the snapshot.
Expand Down Expand Up @@ -710,6 +713,60 @@ This method drags the locator to another target locator or target position. It w

---

### DropAsync {#locator-drop}

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

Simulate an external drag-and-drop of files or clipboard-like data onto this locator.

**Usage**

Drop a file buffer onto an upload area:

Drop plain text and a URL together:

**Arguments**
- `payload` Payload<a aria-hidden="true" tabIndex="-1" class="list-anchor-link" id="locator-drop-option-payload"/><a href="#locator-drop-option-payload" class="list-anchor">#</a>
- `Files` [string]? | [IEnumerable]?&lt;[string]&gt; | Files? | [IEnumerable]?&lt;Files&gt; *(optional)*
- `Name` [string]

File name
- `MimeType` [string]

File type
- `Buffer` [byte]&#91;&#93;

File content


- `Data` [IDictionary]?&lt;[string], [string]&gt; *(optional)*


Data to drop onto the target. Provide `files` (file paths or in-memory buffers), `data` (a mime-type → string map for clipboard-like content such as `text/plain`, `text/html`, `text/uri-list`), or both.
- `options` `LocatorDropOptions?` *(optional)*
- `Position` Position? *(optional)*<a aria-hidden="true" tabIndex="-1" class="list-anchor-link" id="locator-drop-option-position"/><a href="#locator-drop-option-position" class="list-anchor">#</a>
- `X` [float]


- `Y` [float]


A point to use relative to the top-left corner of element padding box. If not specified, uses some visible point of the element.
- `Timeout` [float]? *(optional)*<a aria-hidden="true" tabIndex="-1" class="list-anchor-link" id="locator-drop-option-timeout"/><a href="#locator-drop-option-timeout" class="list-anchor">#</a>

Maximum time in milliseconds. Defaults to `30000` (30 seconds). Pass `0` to disable timeout. The default value can be changed by using the [BrowserContext.SetDefaultTimeout()](/api/class-browsercontext.mdx#browser-context-set-default-timeout) or [Page.SetDefaultTimeout()](/api/class-page.mdx#page-set-default-timeout) methods.

**Returns**
- [void]<a aria-hidden="true" tabIndex="-1" class="list-anchor-link" id="locator-drop-return"/><a href="#locator-drop-return" class="list-anchor">#</a>

**Details**

Dispatches the native `dragenter`, `dragover`, and `drop` events at the center of the target element with a synthetic [DataTransfer] carrying the provided files and/or data entries. Works cross-browser by constructing the [DataTransfer] in the page context.

If the target element's `dragover` listener does not call `preventDefault()`, the target is considered to have rejected the drop: Playwright dispatches `dragleave` and this method throws.

---

### EvaluateAsync {#locator-evaluate}

<font size="2" style={{position: "relative", top: "-20px"}}>Added in: v1.14</font><x-search>locator.EvaluateAsync</x-search>
Expand Down Expand Up @@ -1162,6 +1219,11 @@ await page
An attribute that is usually set by `aria-checked` or native `<input type=checkbox>` controls.

Learn more about [`aria-checked`](https://www.w3.org/TR/wai-aria-1.2/#aria-checked).
- `Description|DescriptionRegex` [string]? | [Regex]? *(optional)* <font size="2">Added in: v1.60</font><a aria-hidden="true" tabIndex="-1" class="list-anchor-link" id="locator-get-by-role-option-description"/><a href="#locator-get-by-role-option-description" class="list-anchor">#</a>

Option to match the [accessible description](https://w3c.github.io/accname/#dfn-accessible-description). By default, matching is case-insensitive and searches for a substring, use [Exact](/api/class-locator.mdx#locator-get-by-role-option-exact) to control this behavior.

Learn more about [accessible description](https://w3c.github.io/accname/#dfn-accessible-description).
- `Disabled` [bool]? *(optional)*<a aria-hidden="true" tabIndex="-1" class="list-anchor-link" id="locator-get-by-role-option-disabled"/><a href="#locator-get-by-role-option-disabled" class="list-anchor">#</a>

An attribute that is usually set by `aria-disabled` or `disabled`.
Expand All @@ -1173,7 +1235,7 @@ await page

- `Exact` [bool]? *(optional)* <font size="2">Added in: v1.28</font><a aria-hidden="true" tabIndex="-1" class="list-anchor-link" id="locator-get-by-role-option-exact"/><a href="#locator-get-by-role-option-exact" class="list-anchor">#</a>

Whether [Name|NameRegex](/api/class-locator.mdx#locator-get-by-role-option-name) is matched exactly: case-sensitive and whole-string. Defaults to false. Ignored when [Name|NameRegex](/api/class-locator.mdx#locator-get-by-role-option-name) is a regular expression. Note that exact match still trims whitespace.
Whether [Name|NameRegex](/api/class-locator.mdx#locator-get-by-role-option-name) and [Description|DescriptionRegex](/api/class-locator.mdx#locator-get-by-role-option-description) are matched exactly: case-sensitive and whole-string. Defaults to false. Ignored when the value is a regular expression. Note that exact match still trims whitespace.
- `Expanded` [bool]? *(optional)*<a aria-hidden="true" tabIndex="-1" class="list-anchor-link" id="locator-get-by-role-option-expanded"/><a href="#locator-get-by-role-option-expanded" class="list-anchor">#</a>

An attribute that is usually set by `aria-expanded`.
Expand Down
Loading
Loading