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: 5 additions & 5 deletions dotnet/docs/api/class-browsercontext.mdx
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
6 changes: 5 additions & 1 deletion dotnet/docs/api/class-cdpsession.mdx
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/docs/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
10 changes: 5 additions & 5 deletions dotnet/docs/ci.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ jobs:
name: 'Playwright Tests'
runs-on: ubuntu-latest
container:
image: mcr.microsoft.com/playwright/dotnet:v1.63.0-noble
image: mcr.microsoft.com/playwright/dotnet:v1.64.1-noble
options: --user 1001
steps:
- uses: actions/checkout@v6
Expand Down Expand Up @@ -157,7 +157,7 @@ trigger:

pool:
vmImage: ubuntu-latest
container: mcr.microsoft.com/playwright/dotnet:v1.63.0-noble
container: mcr.microsoft.com/playwright/dotnet:v1.64.1-noble

steps:
- task: UseDotNet@2
Expand All @@ -180,7 +180,7 @@ Running Playwright on CircleCI is very similar to running on GitHub Actions. In
executors:
pw-noble-development:
docker:
- image: mcr.microsoft.com/playwright/dotnet:v1.63.0-noble
- image: mcr.microsoft.com/playwright/dotnet:v1.64.1-noble
```

Note: When using the docker agent definition, you are specifying the resource class of where playwright runs to the 'medium' tier [here](https://circleci.com/docs/configuration-reference?#docker-execution-environment). The default behavior of Playwright is to set the number of workers to the detected core count (2 in the case of the medium tier). Overriding the number of workers to greater than this number will cause unnecessary timeouts and failures.
Expand All @@ -191,7 +191,7 @@ Jenkins supports Docker agents for pipelines. Use the [Playwright Docker image](

```groovy
pipeline {
agent { docker { image 'mcr.microsoft.com/playwright/dotnet:v1.63.0-noble' } }
agent { docker { image 'mcr.microsoft.com/playwright/dotnet:v1.64.1-noble' } }
stages {
stage('e2e-tests') {
steps {
Expand All @@ -208,7 +208,7 @@ pipeline {
Bitbucket Pipelines can use public [Docker images as build environments](https://confluence.atlassian.com/bitbucket/use-docker-images-as-build-environments-792298897.html). To run Playwright tests on Bitbucket, use our public Docker image ([see Dockerfile](./docker.mdx)).

```yml
image: mcr.microsoft.com/playwright/dotnet:v1.63.0-noble
image: mcr.microsoft.com/playwright/dotnet:v1.64.1-noble
```

### GitLab CI
Expand Down
20 changes: 10 additions & 10 deletions dotnet/docs/docker.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ This Docker image is intended to be used for testing and development purposes on
### Pull the image

```bash
docker pull mcr.microsoft.com/playwright/dotnet:v1.63.0-noble
docker pull mcr.microsoft.com/playwright/dotnet:v1.64.1-noble
```

### Run the image
Expand All @@ -34,15 +34,15 @@ By default, the Docker image will use the `root` user to run the browsers. This
On trusted websites, you can avoid creating a separate user and use root for it since you trust the code which will run on the browsers.

```bash
docker run -it --rm --ipc=host mcr.microsoft.com/playwright/dotnet:v1.63.0-noble /bin/bash
docker run -it --rm --ipc=host mcr.microsoft.com/playwright/dotnet:v1.64.1-noble /bin/bash
```

#### Crawling and scraping

On untrusted websites, it's recommended to use a separate user for launching the browsers in combination with the seccomp profile. Inside the container or if you are using the Docker image as a base image you have to use `adduser` for it.

```bash
docker run -it --rm --ipc=host --user pwuser --security-opt seccomp=seccomp_profile.json mcr.microsoft.com/playwright/dotnet:v1.63.0-noble /bin/bash
docker run -it --rm --ipc=host --user pwuser --security-opt seccomp=seccomp_profile.json mcr.microsoft.com/playwright/dotnet:v1.64.1-noble /bin/bash
```

[`seccomp_profile.json`](https://github.com/microsoft/playwright/blob/main/utils/docker/seccomp_profile.json) is needed to run Chromium with sandbox. This is a [default Docker seccomp profile](https://github.com/docker/engine/blob/d0d99b04cf6e00ed3fc27e81fc3d94e7eda70af3/profiles/seccomp/default.json) with extra user namespace cloning permissions:
Expand Down Expand Up @@ -82,7 +82,7 @@ You can run Playwright Server in Docker while keeping your tests running on the
Start the Playwright Server in Docker:

```bash
docker run -p 3000:3000 --rm --init -it --workdir /home/pwuser --user pwuser mcr.microsoft.com/playwright:v1.63.0-noble /bin/sh -c "npx -y playwright@1.63.0 run-server --port 3000 --host 0.0.0.0"
docker run -p 3000:3000 --rm --init -it --workdir /home/pwuser --user pwuser mcr.microsoft.com/playwright:v1.64.1-noble /bin/sh -c "npx -y playwright@1.64.1 run-server --port 3000 --host 0.0.0.0"
```

#### Connecting to the Server
Expand All @@ -99,7 +99,7 @@ await using var browser = await playwright.Chromium.ConnectAsync("ws://127.0.0.1
If you need to access local servers from within the Docker container:

```bash
docker run --add-host=hostmachine:host-gateway -p 3000:3000 --rm --init -it --workdir /home/pwuser --user pwuser mcr.microsoft.com/playwright:v1.63.0-noble /bin/sh -c "npx -y playwright@1.63.0 run-server --port 3000 --host 0.0.0.0"
docker run --add-host=hostmachine:host-gateway -p 3000:3000 --rm --init -it --workdir /home/pwuser --user pwuser mcr.microsoft.com/playwright:v1.64.1-noble /bin/sh -c "npx -y playwright@1.64.1 run-server --port 3000 --host 0.0.0.0"
```

This makes `hostmachine` point to the host's localhost. Your tests should use `hostmachine` instead of `localhost` when accessing local servers.
Expand All @@ -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 All @@ -132,10 +132,10 @@ Once this is enabled you can open the port specified in a new browser tab and yo
See [all available image tags].

We currently publish images with the following tags:
- `:v1.63.0` - Playwright v1.63.0 release docker image based on Ubuntu 24.04 LTS (Noble Numbat).
- `:v1.63.0-noble` - Playwright v1.63.0 release docker image based on Ubuntu 24.04 LTS (Noble Numbat).
- `:v1.63.0-jammy` - Playwright v1.63.0 release docker image based on Ubuntu 22.04 LTS (Jammy Jellyfish).
- `:v1.63.0-resolute` - Playwright v1.63.0 release docker image based on Ubuntu 26.04 LTS (Resolute Raccoon).
- `:v1.64.1` - Playwright v1.64.1 release docker image based on Ubuntu 24.04 LTS (Noble Numbat).
- `:v1.64.1-noble` - Playwright v1.64.1 release docker image based on Ubuntu 24.04 LTS (Noble Numbat).
- `:v1.64.1-jammy` - Playwright v1.64.1 release docker image based on Ubuntu 22.04 LTS (Jammy Jellyfish).
- `:v1.64.1-resolute` - Playwright v1.64.1 release docker image based on Ubuntu 26.04 LTS (Resolute Raccoon).

:::note

Expand Down
20 changes: 20 additions & 0 deletions dotnet/docs/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
2 changes: 1 addition & 1 deletion dotnet/docs/getting-started-mcp.mdx
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
4 changes: 4 additions & 0 deletions dotnet/docs/navigations.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ The code above loads the page and waits for the web page to fire the [load](http
If the page does a client-side redirect before `load`, [Page.GotoAsync()](/api/class-page.mdx#page-goto) will wait for the redirected page to fire the `load` event.
:::

:::note
In Firefox, a navigation triggered by the page can interrupt [Page.GotoAsync()](/api/class-page.mdx#page-goto) with an `NS_BINDING_ABORTED` error. This is a [known Firefox limitation](https://github.com/microsoft/playwright/issues/20749).
:::

## When is the page loaded?

Modern pages perform numerous activities after the `load` event was fired. They fetch data lazily, populate UI, load expensive resources, scripts and styles after the `load` event was fired. There is no way to tell that the page is `loaded`, it depends on the page, framework, etc. So when can you start interacting with it?
Expand Down
101 changes: 101 additions & 0 deletions dotnet/docs/release-notes.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,107 @@ import HTMLCard from '@site/src/components/HTMLCard';

import LiteYouTube from '@site/src/components/LiteYouTube';

## Version 1.64

### 🧰 WebMCP

New [Page.Webmcp](/api/class-page.mdx#page-webmcp) and [Frame.Webmcp](/api/class-frame.mdx#frame-webmcp) give access to the tools that a page registers through the experimental [WebMCP](https://webmachinelearning.github.io/webmcp/) browser API, so you can test them like any other part of your app:

```csharp
var browser = await playwright.Chromium.LaunchAsync(new() { Args = new[] { "--enable-features=WebMCP" } });
var page = await browser.NewPageAsync();
await page.GotoAsync("https://example.com");

foreach (var tool in await page.Webmcp.ToolsAsync())
Console.WriteLine($"{tool.Name}: {tool.Description}");

var result = await page.Webmcp.CallToolAsync("add", new { a = 2, b = 40 });
Console.WriteLine(result?.GetProperty("content")[0].GetProperty("text")); // "42"
```

[Playwright MCP](./getting-started-mcp.mdx) also supports WebMCP by default, with page-defined tools offered to the agent as `webmcp_<tool>`. Pass `--no-webmcp` to opt out.

[`playwright-cli`](./getting-started-cli.mdx) exposes them as well:

```bash
playwright-cli webmcp-list
playwright-cli webmcp-call search_catalog --params '{"query":"cats"}'
```

### 🎬 Better videos

Videos can now be recorded at a custom frame rate, and the decorations for actions are styled with plain CSS:

```csharp
await page.Screencast.StartAsync(new()
{
Path = "video.webm",
Size = new() { Width = 1920, Height = 1080 },
Fps = 60,
});
await page.Screencast.ShowActionsAsync(new()
{
Style = new()
{
Point = "width: 20px; height: 20px; border-radius: 50%; background: red",
Highlight = "outline: 2px solid #333; background: rgba(0, 128, 255, .15)",
Title = "font-size: 16px",
},
});
```

- New [RecordVideoFps](/api/class-browser.mdx#browser-new-context-option-record-video-fps) option and new [Fps](/api/class-screencast.mdx#screencast-start-option-fps) option in [Screencast.StartAsync()](/api/class-screencast.mdx#screencast-start). Firefox and WebKit currently capture up to 25 frames per second.
- New [Style](/api/class-screencast.mdx#screencast-show-actions-option-style) option takes CSS declarations for the `point` marker, the target `highlight` and the action `title`. It replaces the `FontSize` option, which is now deprecated.
- The cursor stays visible at the last action point, survives navigations and travels along a natural, eased path.
- Videos are encoded with VP9 instead of VP8, which takes less CPU and produces smaller files of the same or better quality.
- All video options are also available in [Playwright MCP](./getting-started-mcp.mdx) and [`playwright-cli`](./getting-started-cli.mdx).

### 🪆 Locator.within()

New [Locator.Within()](/api/class-locator.mdx#locator-within) combines two locators that you already have, reading in the natural order — "this button, within that dialog":

```csharp
var saveButton = page.GetByRole(AriaRole.Button, new() { Name = "Save" });
var dialog = page.GetByTestId("settings-dialog");

await saveButton.Within(dialog).ClickAsync();
```

Relative locators such as [Locator.Nth()](/api/class-locator.mdx#locator-nth) or [Locator.First](/api/class-locator.mdx#locator-first) are resolved inside each parent separately, which makes column-like queries straightforward:

```csharp
// The third cell of every row, not the third cell in the table.
var thirdColumn = page.GetByRole(AriaRole.Cell).Nth(2).Within(page.GetByRole(AriaRole.Row));
await Expect(thirdColumn).ToHaveTextAsync(new[] { "Apple", "Banana", "Cherry" });
```

### New APIs
- New [Page.GetByRef()](/api/class-page.mdx#page-get-by-ref) locates an element by its aria ref, such as `e2`, reported by [Page.AriaSnapshotAsync()](/api/class-page.mdx#page-aria-snapshot) in the `"ai"` mode.
- New option [IncludeShadow](/api/class-page.mdx#page-content-option-include-shadow) in [Page.ContentAsync()](/api/class-page.mdx#page-content) and [Frame.ContentAsync()](/api/class-frame.mdx#frame-content) serializes open shadow roots as [declarative shadow DOM](https://developer.mozilla.org/en-US/docs/Web/API/Web_components/Using_shadow_DOM#declaratively_with_html).
- New option [SignCount](/api/class-credentials.mdx#credentials-create-option-sign-count) sets the initial signature counter of a virtual credential. [Credentials.CreateAsync()](/api/class-credentials.mdx#credentials-create) and [Credentials.GetAsync()](/api/class-credentials.mdx#credentials-get) return the current `SignCount`, and it is saved and restored together with the credentials in the storage state.
- New [ApiRequestContext.AddCookiesAsync()](/api/class-apirequestcontext.mdx#api-request-context-add-cookies), [ApiRequestContext.CookiesAsync()](/api/class-apirequestcontext.mdx#api-request-context-cookies) and [ApiRequestContext.ClearCookiesAsync()](/api/class-apirequestcontext.mdx#api-request-context-clear-cookies) manage cookies of a request context, mirroring the [BrowserContext] methods:

```csharp
await request.AddCookiesAsync(new[]
{
new Cookie { Name = "session-id", Value = "42", Url = "https://example.com" },
});
Console.WriteLine(await request.CookiesAsync("https://example.com"));
await request.ClearCookiesAsync(new() { Name = "session-id" });
```

### Breaking Changes ⚠️
- Elements inside hidden iframes are considered hidden. Elements inside an iframe that is not visible, for example with `visibility: hidden`, are now considered hidden by actions, [Locator.IsVisibleAsync()](/api/class-locator.mdx#locator-is-visible) and [Expect(Locator).ToBeVisibleAsync()](/api/class-locatorassertions.mdx#locator-assertions-to-be-visible).

### Browser Versions
- Chromium 156.0.8078.4
- Mozilla Firefox 157.0
- WebKit 27.2

This version was also tested against the following stable channels:
- Google Chrome 155
- Microsoft Edge 155

## Version 1.63

### 🪟 Locate across frames
Expand Down
Loading
Loading