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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions dotnet/versioned_docs/version-stable/actionability.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ For example, consider a scenario where Playwright will click `Sign Up` button re
[CDPSessionEvent]: /api/class-cdpsessionevent.mdx "CDPSessionEvent"
[Clock]: /api/class-clock.mdx "Clock"
[ConsoleMessage]: /api/class-consolemessage.mdx "ConsoleMessage"
[Debugger]: /api/class-debugger.mdx "Debugger"
[Dialog]: /api/class-dialog.mdx "Dialog"
[Download]: /api/class-download.mdx "Download"
[ElementHandle]: /api/class-elementhandle.mdx "ElementHandle"
Expand All @@ -153,6 +154,7 @@ For example, consider a scenario where Playwright will click `Sign Up` button re
[Request]: /api/class-request.mdx "Request"
[Response]: /api/class-response.mdx "Response"
[Route]: /api/class-route.mdx "Route"
[Screencast]: /api/class-screencast.mdx "Screencast"
[Selectors]: /api/class-selectors.mdx "Selectors"
[TimeoutError]: /api/class-timeouterror.mdx "TimeoutError"
[Touchscreen]: /api/class-touchscreen.mdx "Touchscreen"
Expand Down
2 changes: 2 additions & 0 deletions dotnet/versioned_docs/version-stable/api-testing.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,7 @@ var context = await Browser.NewContextAsync(new() { StorageState = state });
[CDPSessionEvent]: /api/class-cdpsessionevent.mdx "CDPSessionEvent"
[Clock]: /api/class-clock.mdx "Clock"
[ConsoleMessage]: /api/class-consolemessage.mdx "ConsoleMessage"
[Debugger]: /api/class-debugger.mdx "Debugger"
[Dialog]: /api/class-dialog.mdx "Dialog"
[Download]: /api/class-download.mdx "Download"
[ElementHandle]: /api/class-elementhandle.mdx "ElementHandle"
Expand All @@ -445,6 +446,7 @@ var context = await Browser.NewContextAsync(new() { StorageState = state });
[Request]: /api/class-request.mdx "Request"
[Response]: /api/class-response.mdx "Response"
[Route]: /api/class-route.mdx "Route"
[Screencast]: /api/class-screencast.mdx "Screencast"
[Selectors]: /api/class-selectors.mdx "Selectors"
[TimeoutError]: /api/class-timeouterror.mdx "TimeoutError"
[Touchscreen]: /api/class-touchscreen.mdx "Touchscreen"
Expand Down
2 changes: 2 additions & 0 deletions dotnet/versioned_docs/version-stable/api/class-apirequest.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ await ApiRequest.NewContextAsync(options);
[CDPSessionEvent]: /api/class-cdpsessionevent.mdx "CDPSessionEvent"
[Clock]: /api/class-clock.mdx "Clock"
[ConsoleMessage]: /api/class-consolemessage.mdx "ConsoleMessage"
[Debugger]: /api/class-debugger.mdx "Debugger"
[Dialog]: /api/class-dialog.mdx "Dialog"
[Download]: /api/class-download.mdx "Download"
[ElementHandle]: /api/class-elementhandle.mdx "ElementHandle"
Expand All @@ -162,6 +163,7 @@ await ApiRequest.NewContextAsync(options);
[Request]: /api/class-request.mdx "Request"
[Response]: /api/class-response.mdx "Response"
[Route]: /api/class-route.mdx "Route"
[Screencast]: /api/class-screencast.mdx "Screencast"
[Selectors]: /api/class-selectors.mdx "Selectors"
[TimeoutError]: /api/class-timeouterror.mdx "TimeoutError"
[Touchscreen]: /api/class-touchscreen.mdx "Touchscreen"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -577,6 +577,7 @@ await ApiRequestContext.StorageStateAsync(options);
[CDPSessionEvent]: /api/class-cdpsessionevent.mdx "CDPSessionEvent"
[Clock]: /api/class-clock.mdx "Clock"
[ConsoleMessage]: /api/class-consolemessage.mdx "ConsoleMessage"
[Debugger]: /api/class-debugger.mdx "Debugger"
[Dialog]: /api/class-dialog.mdx "Dialog"
[Download]: /api/class-download.mdx "Download"
[ElementHandle]: /api/class-elementhandle.mdx "ElementHandle"
Expand All @@ -596,6 +597,7 @@ await ApiRequestContext.StorageStateAsync(options);
[Request]: /api/class-request.mdx "Request"
[Response]: /api/class-response.mdx "Response"
[Route]: /api/class-route.mdx "Route"
[Screencast]: /api/class-screencast.mdx "Screencast"
[Selectors]: /api/class-selectors.mdx "Selectors"
[TimeoutError]: /api/class-timeouterror.mdx "TimeoutError"
[Touchscreen]: /api/class-touchscreen.mdx "Touchscreen"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ ApiResponse.Url
[CDPSessionEvent]: /api/class-cdpsessionevent.mdx "CDPSessionEvent"
[Clock]: /api/class-clock.mdx "Clock"
[ConsoleMessage]: /api/class-consolemessage.mdx "ConsoleMessage"
[Debugger]: /api/class-debugger.mdx "Debugger"
[Dialog]: /api/class-dialog.mdx "Dialog"
[Download]: /api/class-download.mdx "Download"
[ElementHandle]: /api/class-elementhandle.mdx "ElementHandle"
Expand All @@ -221,6 +222,7 @@ ApiResponse.Url
[Request]: /api/class-request.mdx "Request"
[Response]: /api/class-response.mdx "Response"
[Route]: /api/class-route.mdx "Route"
[Screencast]: /api/class-screencast.mdx "Screencast"
[Selectors]: /api/class-selectors.mdx "Selectors"
[TimeoutError]: /api/class-timeouterror.mdx "TimeoutError"
[Touchscreen]: /api/class-touchscreen.mdx "Touchscreen"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,24 @@ import HTMLCard from '@site/src/components/HTMLCard';

The [APIResponseAssertions] class provides assertion methods that can be used to make assertions about the [APIResponse] in the tests.

```csharp
using Microsoft.Playwright;
using Microsoft.Playwright.MSTest;

namespace PlaywrightTests;

[TestClass]
public class ExampleTests : PageTest
{
[TestMethod]
public async Task NavigatesToLoginPage()
{
var response = await Page.APIRequest.GetAsync("https://playwright.dev");
await Expect(response).ToBeOKAsync();
}
}
```


---

Expand All @@ -22,6 +40,10 @@ Ensures the response status code is within `200..299` range.

**Usage**

```csharp
await Expect(response).ToBeOKAsync();
```

**Returns**
- [void]<a aria-hidden="true" tabIndex="-1" class="list-anchor-link" id="api-response-assertions-to-be-ok-return"/><a href="#api-response-assertions-to-be-ok-return" class="list-anchor">#</a>

Expand All @@ -33,12 +55,14 @@ Ensures the response status code is within `200..299` range.

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

Makes the assertion check for the opposite condition. For example, this code tests that the response status is not successful:
Makes the assertion check for the opposite condition.

**Usage**

For example, this code tests that the response status is not successful:

```csharp
Expect(Response).Not
await Expect(response).Not.ToBeOKAsync();
```

**Type**
Expand All @@ -56,6 +80,7 @@ Expect(Response).Not
[CDPSessionEvent]: /api/class-cdpsessionevent.mdx "CDPSessionEvent"
[Clock]: /api/class-clock.mdx "Clock"
[ConsoleMessage]: /api/class-consolemessage.mdx "ConsoleMessage"
[Debugger]: /api/class-debugger.mdx "Debugger"
[Dialog]: /api/class-dialog.mdx "Dialog"
[Download]: /api/class-download.mdx "Download"
[ElementHandle]: /api/class-elementhandle.mdx "ElementHandle"
Expand All @@ -75,6 +100,7 @@ Expect(Response).Not
[Request]: /api/class-request.mdx "Request"
[Response]: /api/class-response.mdx "Response"
[Route]: /api/class-route.mdx "Route"
[Screencast]: /api/class-screencast.mdx "Screencast"
[Selectors]: /api/class-selectors.mdx "Selectors"
[TimeoutError]: /api/class-timeouterror.mdx "TimeoutError"
[Touchscreen]: /api/class-touchscreen.mdx "Touchscreen"
Expand Down
53 changes: 53 additions & 0 deletions dotnet/versioned_docs/version-stable/api/class-browser.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,40 @@ await browser.CloseAsync();

## Methods

### BindAsync {#browser-bind}

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

Binds the browser to a named pipe or web socket, making it available for other clients to connect to.

**Usage**

```csharp
await Browser.BindAsync(title, options);
```

**Arguments**
- `title` [string]<a aria-hidden="true" tabIndex="-1" class="list-anchor-link" id="browser-bind-option-title"/><a href="#browser-bind-option-title" class="list-anchor">#</a>

Title of the browser server, used for identification.
- `options` `BrowserBindOptions?` *(optional)*
- `Host` [string]? *(optional)*<a aria-hidden="true" tabIndex="-1" class="list-anchor-link" id="browser-bind-option-host"/><a href="#browser-bind-option-host" class="list-anchor">#</a>

Host to bind the web socket server to. When specified, a web socket server is created instead of a named pipe.
- `Port` [int]? *(optional)*<a aria-hidden="true" tabIndex="-1" class="list-anchor-link" id="browser-bind-option-port"/><a href="#browser-bind-option-port" class="list-anchor">#</a>

Port to bind the web socket server to. When specified, a web socket server is created instead of a named pipe. Use `0` to let the OS pick an available port.
- `WorkspaceDir` [string]? *(optional)*<a aria-hidden="true" tabIndex="-1" class="list-anchor-link" id="browser-bind-option-workspace-dir"/><a href="#browser-bind-option-workspace-dir" class="list-anchor">#</a>

Working directory associated with this browser server.

**Returns**
- Bind<a aria-hidden="true" tabIndex="-1" class="list-anchor-link" id="browser-bind-return"/><a href="#browser-bind-return" class="list-anchor">#</a>
- `endpoint` [string]


---

### BrowserType {#browser-browser-type}

<font size="2" style={{position: "relative", top: "-20px"}}>Added in: v1.23</font><x-search>browser.BrowserType</x-search>
Expand Down Expand Up @@ -587,6 +621,23 @@ await Browser.NewPageAsync(options);

---

### UnbindAsync {#browser-unbind}

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

Unbinds the browser server previously bound with [Browser.BindAsync()](/api/class-browser.mdx#browser-bind).

**Usage**

```csharp
await Browser.UnbindAsync();
```

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

---

### Version {#browser-version}

<font size="2" style={{position: "relative", top: "-20px"}}>Added before v1.9</font><x-search>browser.Version</x-search>
Expand Down Expand Up @@ -635,6 +686,7 @@ Browser.Disconnected += async (_, browser) => {};
[CDPSessionEvent]: /api/class-cdpsessionevent.mdx "CDPSessionEvent"
[Clock]: /api/class-clock.mdx "Clock"
[ConsoleMessage]: /api/class-consolemessage.mdx "ConsoleMessage"
[Debugger]: /api/class-debugger.mdx "Debugger"
[Dialog]: /api/class-dialog.mdx "Dialog"
[Download]: /api/class-download.mdx "Download"
[ElementHandle]: /api/class-elementhandle.mdx "ElementHandle"
Expand All @@ -654,6 +706,7 @@ Browser.Disconnected += async (_, browser) => {};
[Request]: /api/class-request.mdx "Request"
[Response]: /api/class-response.mdx "Response"
[Route]: /api/class-route.mdx "Route"
[Screencast]: /api/class-screencast.mdx "Screencast"
[Selectors]: /api/class-selectors.mdx "Selectors"
[TimeoutError]: /api/class-timeouterror.mdx "TimeoutError"
[Touchscreen]: /api/class-touchscreen.mdx "Touchscreen"
Expand Down
70 changes: 65 additions & 5 deletions dotnet/versioned_docs/version-stable/api/class-browsercontext.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ The order of evaluation of multiple scripts installed via [BrowserContext.AddIni
Script to be evaluated in all pages in the browser context.

**Returns**
- [void]<a aria-hidden="true" tabIndex="-1" class="list-anchor-link" id="browser-context-add-init-script-return"/><a href="#browser-context-add-init-script-return" class="list-anchor">#</a>
- [Disposable]<a aria-hidden="true" tabIndex="-1" class="list-anchor-link" id="browser-context-add-init-script-return"/><a href="#browser-context-add-init-script-return" class="list-anchor">#</a>

---

Expand Down Expand Up @@ -316,7 +316,7 @@ await page.GetByRole(AriaRole.Button).ClickAsync();
Whether to pass the argument as a handle, instead of passing by value. When passing a handle, only one argument is supported. When passing by value, multiple arguments are supported.

**Returns**
- [void]<a aria-hidden="true" tabIndex="-1" class="list-anchor-link" id="browser-context-expose-binding-return"/><a href="#browser-context-expose-binding-return" class="list-anchor">#</a>
- [Disposable]<a aria-hidden="true" tabIndex="-1" class="list-anchor-link" id="browser-context-expose-binding-return"/><a href="#browser-context-expose-binding-return" class="list-anchor">#</a>

---

Expand Down Expand Up @@ -378,7 +378,7 @@ class BrowserContextExamples
Callback function that will be called in the Playwright's context.

**Returns**
- [void]<a aria-hidden="true" tabIndex="-1" class="list-anchor-link" id="browser-context-expose-function-return"/><a href="#browser-context-expose-function-return" class="list-anchor">#</a>
- [Disposable]<a aria-hidden="true" tabIndex="-1" class="list-anchor-link" id="browser-context-expose-function-return"/><a href="#browser-context-expose-function-return" class="list-anchor">#</a>

---

Expand Down Expand Up @@ -422,6 +422,7 @@ await BrowserContext.GrantPermissionsAsync(permissions, options);
* `'notifications'`
* `'payment-handler'`
* `'storage-access'`
* `'screen-wake-lock'`
- `options` `BrowserContextGrantPermissionsOptions?` *(optional)*
- `Origin` [string]? *(optional)*<a aria-hidden="true" tabIndex="-1" class="list-anchor-link" id="browser-context-grant-permissions-option-origin"/><a href="#browser-context-grant-permissions-option-origin" class="list-anchor">#</a>

Expand All @@ -432,6 +433,23 @@ await BrowserContext.GrantPermissionsAsync(permissions, options);

---

### IsClosed {#browser-context-is-closed}

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

Indicates that the browser context is in the process of closing or has already been closed.

**Usage**

```csharp
BrowserContext.IsClosed
```

**Returns**
- [bool]<a aria-hidden="true" tabIndex="-1" class="list-anchor-link" id="browser-context-is-closed-return"/><a href="#browser-context-is-closed-return" class="list-anchor">#</a>

---

### NewCDPSessionAsync {#browser-context-new-cdp-session}

<font size="2" style={{position: "relative", top: "-20px"}}>Added in: v1.11</font><x-search>browserContext.NewCDPSessionAsync</x-search>
Expand Down Expand Up @@ -560,7 +578,7 @@ Enabling routing disables http cache.
How often a route should be used. By default it will be used every time.

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

---

Expand Down Expand Up @@ -890,6 +908,29 @@ await BrowserContext.SetOfflineAsync(offline);

---

### SetStorageStateAsync {#browser-context-set-storage-state}

<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 and IndexedDB entries for all origins and sets the new storage state.

**Usage**

```csharp
// Load storage state from a file and apply it to the context.
await context.SetStorageStateAsync("state.json");
```

**Arguments**
- `storageStatePath` [string]<a aria-hidden="true" tabIndex="-1" class="list-anchor-link" id="browser-context-set-storage-state-option-storage-state"/><a href="#browser-context-set-storage-state-option-storage-state" class="list-anchor">#</a>

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.

**Returns**
- [void]<a aria-hidden="true" tabIndex="-1" class="list-anchor-link" id="browser-context-set-storage-state-return"/><a href="#browser-context-set-storage-state-return" class="list-anchor">#</a>

---

### StorageStateAsync {#browser-context-storage-state}

<font size="2" style={{position: "relative", top: "-20px"}}>Added before v1.9</font><x-search>browserContext.StorageStateAsync</x-search>
Expand Down Expand Up @@ -931,7 +972,7 @@ await BrowserContext.UnrouteAsync(url, handler);
**Arguments**
- `url` [string] | [Regex] | [Func]&lt;[string], bool&gt;<a aria-hidden="true" tabIndex="-1" class="list-anchor-link" id="browser-context-unroute-option-url"/><a href="#browser-context-unroute-option-url" class="list-anchor">#</a>

A glob pattern, regex pattern or predicate receiving [URL] used to register a routing with [BrowserContext.RouteAsync()](/api/class-browsercontext.mdx#browser-context-route).
A glob pattern, regex pattern, or predicate receiving [URL] used to register a routing with [BrowserContext.RouteAsync()](/api/class-browsercontext.mdx#browser-context-route).
- `handler` [Action]&lt;[Route]?&gt; *(optional)*<a aria-hidden="true" tabIndex="-1" class="list-anchor-link" id="browser-context-unroute-option-handler"/><a href="#browser-context-unroute-option-handler" class="list-anchor">#</a>

Optional handler function used to register a routing with [BrowserContext.RouteAsync()](/api/class-browsercontext.mdx#browser-context-route).
Expand Down Expand Up @@ -1003,6 +1044,23 @@ BrowserContext.Clock

---

### Debugger {#browser-context-debugger}

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

Debugger allows to pause and resume the execution.

**Usage**

```csharp
BrowserContext.Debugger
```

**Type**
- [Debugger]

---

### Tracing {#browser-context-tracing}

<font size="2" style={{position: "relative", top: "-20px"}}>Added in: v1.12</font><x-search>browserContext.Tracing</x-search>
Expand Down Expand Up @@ -1272,6 +1330,7 @@ BrowserContext.BackgroundPages
[CDPSessionEvent]: /api/class-cdpsessionevent.mdx "CDPSessionEvent"
[Clock]: /api/class-clock.mdx "Clock"
[ConsoleMessage]: /api/class-consolemessage.mdx "ConsoleMessage"
[Debugger]: /api/class-debugger.mdx "Debugger"
[Dialog]: /api/class-dialog.mdx "Dialog"
[Download]: /api/class-download.mdx "Download"
[ElementHandle]: /api/class-elementhandle.mdx "ElementHandle"
Expand All @@ -1291,6 +1350,7 @@ BrowserContext.BackgroundPages
[Request]: /api/class-request.mdx "Request"
[Response]: /api/class-response.mdx "Response"
[Route]: /api/class-route.mdx "Route"
[Screencast]: /api/class-screencast.mdx "Screencast"
[Selectors]: /api/class-selectors.mdx "Selectors"
[TimeoutError]: /api/class-timeouterror.mdx "TimeoutError"
[Touchscreen]: /api/class-touchscreen.mdx "Touchscreen"
Expand Down
Loading
Loading