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
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ await context.AddCookiesAsync(new[] { cookie1, cookie2 });
- `SameSite` `enum SameSiteAttribute { Strict, Lax, None }?` *(optional)*

Optional.
- `PartitionKey` [string]? *(optional)*

For partitioned third-party cookies (aka [CHIPS](https://developer.mozilla.org/en-US/docs/Web/Privacy/Guides/Privacy_sandbox/Partitioned_cookies)), the partition key. Optional.

**Returns**
- [void]<a aria-hidden="true" tabIndex="-1" class="list-anchor-link" id="browser-context-add-cookies-return"/><a href="#browser-context-add-cookies-return" class="list-anchor">#</a>
Expand Down Expand Up @@ -140,7 +143,7 @@ BrowserContext.BackgroundPages

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

Returns the browser instance of the context. If it was launched as a persistent context null gets returned.
Gets the browser instance that owns the context. Returns `null` if the context is created outside of normal browser, e.g. Android or Electron.

**Usage**

Expand Down Expand Up @@ -279,6 +282,9 @@ await BrowserContext.CookiesAsync(urls);
- `sameSite` `enum SameSiteAttribute { Strict, Lax, None }`


- `partitionKey` [string]? *(optional)*


---

### ExposeBindingAsync {#browser-context-expose-binding}
Expand Down Expand Up @@ -436,6 +442,7 @@ await BrowserContext.GrantPermissionsAsync(permissions, options);
* `'notifications'`
* `'payment-handler'`
* `'storage-access'`
* `'local-fonts'`
- `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 Down
5 changes: 5 additions & 0 deletions dotnet/versioned_docs/version-stable/api/class-mouse.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ import HTMLCard from '@site/src/components/HTMLCard';

The Mouse class operates in main-frame CSS pixels relative to the top-left corner of the viewport.

:::tip

If you want to debug where the mouse moved, you can use the [Trace viewer](../trace-viewer-intro.mdx) or [Playwright Inspector](../running-tests.mdx). A red dot showing the location of the mouse will be shown for every mouse action.
:::

Every `page` object has its own Mouse, accessible with [Page.Mouse](/api/class-page.mdx#page-mouse).

```csharp
Expand Down
10 changes: 5 additions & 5 deletions dotnet/versioned_docs/version-stable/ci.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ jobs:
name: 'Playwright Tests'
runs-on: ubuntu-latest
container:
image: mcr.microsoft.com/playwright/dotnet:v1.52.0-noble
image: mcr.microsoft.com/playwright/dotnet:v1.53.0-noble
options: --user 1001
steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -159,7 +159,7 @@ trigger:

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

steps:
- task: UseDotNet@2
Expand All @@ -182,7 +182,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.52.0-noble
- image: mcr.microsoft.com/playwright/dotnet:v1.53.0-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 @@ -193,7 +193,7 @@ Jenkins supports Docker agents for pipelines. Use the [Playwright Docker image](

```groovy
pipeline {
agent { docker { image 'mcr.microsoft.com/playwright/dotnet:v1.52.0-noble' } }
agent { docker { image 'mcr.microsoft.com/playwright/dotnet:v1.53.0-noble' } }
stages {
stage('e2e-tests') {
steps {
Expand All @@ -210,7 +210,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.52.0-noble
image: mcr.microsoft.com/playwright/dotnet:v1.53.0-noble
```

### GitLab CI
Expand Down
11 changes: 11 additions & 0 deletions dotnet/versioned_docs/version-stable/clock.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,17 @@ Often you only need to fake `Date.now` while keeping the timers going. That way
</script>
```

```csharp
// Set the fixed time for the clock.
await Page.Clock.SetFixedTimeAsync(new DateTime(2024, 2, 2, 10, 0, 0));
await Page.GotoAsync("http://localhost:3333");
await Expect(Page.GetByTestId("current-time")).ToHaveTextAsync("2/2/2024, 10:00:00 AM");
// Set the fixed time for the clock.
await Page.Clock.SetFixedTimeAsync(new DateTime(2024, 2, 2, 10, 30, 0));
// We know that the page has a timer that updates the time every second.
await Expect(Page.GetByTestId("current-time")).ToHaveTextAsync("2/2/2024, 10:30:00 AM");
```

## Consistent time and timers

Sometimes your timers depend on `Date.now` and are confused when the `Date.now` value does not change over time. In this case, you can install the clock and fast forward to the time of interest when testing.
Expand Down
13 changes: 13 additions & 0 deletions dotnet/versioned_docs/version-stable/codegen.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,19 @@ pwsh bin/Debug/netX/playwright.ps1 codegen --load-storage=auth.json github.com/m
######
<img width="1394" alt="github signed in showing use of load storage scharp" src="https://user-images.githubusercontent.com/13063165/220928354-caa0e958-fe09-4125-9b54-67483064da51.png" />

#### Use existing userDataDir

Run `codegen` with `--user-data-dir` to set a fixed [user data directory](https://playwright.dev/docs/api/class-browsertype#browser-type-launch-persistent-context-option-user-data-dir) for the browser session. If you create a custom browser user data directory, codegen will use this existing browser profile and have access to any authentication state present in that profile.

:::warning

[As of Chrome 136, the default user data directory cannot be accessed via automated tooling](https://developer.chrome.com/blog/remote-debugging-port), such as Playwright. You must create a separate user data directory for use in testing.
:::

```bash
pwsh bin/Debug/netX/playwright.ps1 codegen --user-data-dir=/path/to/your/browser/data/ github.com/microsoft/playwright
```

## Record using custom setup

If you would like to use codegen in some non-standard setup (for example, use [BrowserContext.RouteAsync()](/api/class-browsercontext.mdx#browser-context-route)), it is possible to call [Page.PauseAsync()](/api/class-page.mdx#page-pause) that will open a separate window with codegen controls.
Expand Down
16 changes: 8 additions & 8 deletions dotnet/versioned_docs/version-stable/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.52.0-noble
docker pull mcr.microsoft.com/playwright/dotnet:v1.53.0-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.52.0-noble /bin/bash
docker run -it --rm --ipc=host mcr.microsoft.com/playwright/dotnet:v1.53.0-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.52.0-noble /bin/bash
docker run -it --rm --ipc=host --user pwuser --security-opt seccomp=seccomp_profile.json mcr.microsoft.com/playwright/dotnet:v1.53.0-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.52.0-noble /bin/sh -c "npx -y playwright@1.52.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.53.0-noble /bin/sh -c "npx -y playwright@1.53.0 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.52.0-noble /bin/sh -c "npx -y playwright@1.52.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.53.0-noble /bin/sh -c "npx -y playwright@1.53.0 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 @@ -114,9 +114,9 @@ When running tests remotely, ensure the Playwright version in your tests matches
See [all available image tags].

We currently publish images with the following tags:
- `:v1.52.0` - Playwright v1.52.0 release docker image based on Ubuntu 24.04 LTS (Noble Numbat).
- `:v1.52.0-noble` - Playwright v1.52.0 release docker image based on Ubuntu 24.04 LTS (Noble Numbat).
- `:v1.52.0-jammy` - Playwright v1.52.0 release docker image based on Ubuntu 22.04 LTS (Jammy Jellyfish).
- `:v1.53.0` - Playwright v1.53.0 release docker image based on Ubuntu 24.04 LTS (Noble Numbat).
- `:v1.53.0-noble` - Playwright v1.53.0 release docker image based on Ubuntu 24.04 LTS (Noble Numbat).
- `:v1.53.0-jammy` - Playwright v1.53.0 release docker image based on Ubuntu 22.04 LTS (Jammy Jellyfish).

:::note

Expand Down
21 changes: 20 additions & 1 deletion dotnet/versioned_docs/version-stable/release-notes.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,29 @@ import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';
import HTMLCard from '@site/src/components/HTMLCard';

## Version 1.54
- New cookie property `PartitionKey` in [BrowserContext.CookiesAsync()](/api/class-browsercontext.mdx#browser-context-cookies) and [BrowserContext.AddCookiesAsync()](/api/class-browsercontext.mdx#browser-context-add-cookies). This property allows to save and restore partitioned cookies. See [CHIPS MDN article](https://developer.mozilla.org/en-US/docs/Web/Privacy/Guides/Privacy_sandbox/Partitioned_cookies) for more information. Note that browsers have different support and defaults for cookie partitioning.
- New option `--user-data-dir` in multiple commands. You can specify the same user data dir to reuse browsing state, like authentication, between sessions.

```bash
pwsh bin/Debug/netX/playwright.ps1 codegen --user-data-dir=./user-data
```

- `pwsh bin/Debug/netX/playwright.ps1 open` does not open the test recorder anymore. Use `pwsh bin/Debug/netX/playwright.ps1 codegen` instead.

### Browser Versions
- Chromium 139.0.7258.5
- Mozilla Firefox 140.0.2
- WebKit 26.0

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

## Version 1.53

### Miscellaneous
- New Steps in Trace Viewer: ![New Trace Viewer Steps](https://github.com/user-attachments/assets/1963ff7d-4070-41be-a79b-4333176921a2)
- New Steps in Trace Viewer: ![New Trace Viewer Steps](https://github.com/user-attachments/assets/1963ff7d-4070-41be-a79b-4333176921a2)
- New method [Locator.Describe()](/api/class-locator.mdx#locator-describe) to describe a locator. Used for trace viewer.

```csharp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ browserContext.addCookies(Arrays.asList(cookieObject1, cookieObject2));
- `setSameSite` `enum SameSiteAttribute { STRICT, LAX, NONE }` *(optional)*

Optional.
- `setPartitionKey` [String] *(optional)*

For partitioned third-party cookies (aka [CHIPS](https://developer.mozilla.org/en-US/docs/Web/Privacy/Guides/Privacy_sandbox/Partitioned_cookies)), the partition key. Optional.

**Returns**
- [void]<a aria-hidden="true" tabIndex="-1" class="list-anchor-link" id="browser-context-add-cookies-return"/><a href="#browser-context-add-cookies-return" class="list-anchor">#</a>
Expand Down Expand Up @@ -139,7 +142,7 @@ BrowserContext.backgroundPages();

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

Returns the browser instance of the context. If it was launched as a persistent context null gets returned.
Gets the browser instance that owns the context. Returns `null` if the context is created outside of normal browser, e.g. Android or Electron.

**Usage**

Expand Down Expand Up @@ -280,6 +283,9 @@ BrowserContext.cookies(urls);
- `sameSite` `enum SameSiteAttribute { STRICT, LAX, NONE }`


- `partitionKey` [String] *(optional)*


---

### exposeBinding {#browser-context-expose-binding}
Expand Down Expand Up @@ -447,6 +453,7 @@ BrowserContext.grantPermissions(permissions, options);
* `'notifications'`
* `'payment-handler'`
* `'storage-access'`
* `'local-fonts'`
- `options` `BrowserContext.GrantPermissionsOptions` *(optional)*
- `setOrigin` [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 Down
5 changes: 5 additions & 0 deletions java/versioned_docs/version-stable/api/class-mouse.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ import HTMLCard from '@site/src/components/HTMLCard';

The Mouse class operates in main-frame CSS pixels relative to the top-left corner of the viewport.

:::tip

If you want to debug where the mouse moved, you can use the [Trace viewer](../trace-viewer-intro.mdx) or [Playwright Inspector](../running-tests.mdx). A red dot showing the location of the mouse will be shown for every mouse action.
:::

Every `page` object has its own Mouse, accessible with [Page.mouse()](/api/class-page.mdx#page-mouse).

```java
Expand Down
12 changes: 6 additions & 6 deletions java/versioned_docs/version-stable/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/java:v1.52.0-noble
image: mcr.microsoft.com/playwright/java:v1.53.0-noble
options: --user 1001
steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -160,7 +160,7 @@ trigger:

pool:
vmImage: ubuntu-latest
container: mcr.microsoft.com/playwright/java:v1.52.0-noble
container: mcr.microsoft.com/playwright/java:v1.53.0-noble

steps:
- task: JavaToolInstaller@0
Expand All @@ -183,7 +183,7 @@ Running Playwright on CircleCI is very similar to running on GitHub Actions. In
executors:
pw-noble-development:
docker:
- image: mcr.microsoft.com/playwright/java:v1.52.0-noble
- image: mcr.microsoft.com/playwright/java:v1.53.0-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 @@ -194,7 +194,7 @@ Jenkins supports Docker agents for pipelines. Use the [Playwright Docker image](

```groovy
pipeline {
agent { docker { image 'mcr.microsoft.com/playwright/java:v1.52.0-noble' } }
agent { docker { image 'mcr.microsoft.com/playwright/java:v1.53.0-noble' } }
stages {
stage('e2e-tests') {
steps {
Expand All @@ -211,7 +211,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/java:v1.52.0-noble
image: mcr.microsoft.com/playwright/java:v1.53.0-noble
```

### GitLab CI
Expand All @@ -224,7 +224,7 @@ stages:

tests:
stage: test
image: mcr.microsoft.com/playwright/java:v1.52.0-noble
image: mcr.microsoft.com/playwright/java:v1.53.0-noble
script:
...
```
Expand Down
11 changes: 11 additions & 0 deletions java/versioned_docs/version-stable/clock.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,17 @@ Often you only need to fake `Date.now` while keeping the timers going. That way
</script>
```

```java
SimpleDateFormat format = new SimpleDateFormat("yyy-MM-dd'T'HH:mm:ss");
page.clock().setFixedTime(format.parse("2024-02-02T10:00:00"));
page.navigate("http://localhost:3333");
Locator locator = page.getByTestId("current-time");
assertThat(locator).hasText("2/2/2024, 10:00:00 AM");
page.clock().setFixedTime(format.parse("2024-02-02T10:30:00"));
// We know that the page has a timer that updates the time every second.
assertThat(locator).hasText("2/2/2024, 10:30:00 AM");
```

## Consistent time and timers

Sometimes your timers depend on `Date.now` and are confused when the `Date.now` value does not change over time. In this case, you can install the clock and fast forward to the time of interest when testing.
Expand Down
13 changes: 13 additions & 0 deletions java/versioned_docs/version-stable/codegen.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,19 @@ mvn exec:java -e -D exec.mainClass=com.microsoft.playwright.CLI -D exec.args="co
######
<img width="1394" alt="github signed in showing use of load storage java" src="https://user-images.githubusercontent.com/13063165/220928075-1e38347b-9d0d-4d9e-9a67-506c717893df.png" />

#### Use existing userDataDir

Run `codegen` with `--user-data-dir` to set a fixed [user data directory](https://playwright.dev/docs/api/class-browsertype#browser-type-launch-persistent-context-option-user-data-dir) for the browser session. If you create a custom browser user data directory, codegen will use this existing browser profile and have access to any authentication state present in that profile.

:::warning

[As of Chrome 136, the default user data directory cannot be accessed via automated tooling](https://developer.chrome.com/blog/remote-debugging-port), such as Playwright. You must create a separate user data directory for use in testing.
:::

```bash
mvn exec:java -e -D exec.mainClass=com.microsoft.playwright.CLI -D exec.args="codegen --user-data-dir=/path/to/your/browser/data/ github.com/microsoft/playwright"
```

## Record using custom setup

If you would like to use codegen in some non-standard setup (for example, use [BrowserContext.route()](/api/class-browsercontext.mdx#browser-context-route)), it is possible to call [Page.pause()](/api/class-page.mdx#page-pause) that will open a separate window with codegen controls.
Expand Down
Loading
Loading