diff --git a/dotnet/versioned_docs/version-stable/ci.mdx b/dotnet/versioned_docs/version-stable/ci.mdx index d0df1c2cc2..cf201dd8be 100644 --- a/dotnet/versioned_docs/version-stable/ci.mdx +++ b/dotnet/versioned_docs/version-stable/ci.mdx @@ -76,7 +76,7 @@ jobs: name: 'Playwright Tests' runs-on: ubuntu-latest container: - image: mcr.microsoft.com/playwright/dotnet:v1.56.0-noble + image: mcr.microsoft.com/playwright/dotnet:v1.57.0-noble options: --user 1001 steps: - uses: actions/checkout@v5 @@ -159,7 +159,7 @@ trigger: pool: vmImage: ubuntu-latest -container: mcr.microsoft.com/playwright/dotnet:v1.56.0-noble +container: mcr.microsoft.com/playwright/dotnet:v1.57.0-noble steps: - task: UseDotNet@2 @@ -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.56.0-noble + - image: mcr.microsoft.com/playwright/dotnet:v1.57.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. @@ -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.56.0-noble' } } + agent { docker { image 'mcr.microsoft.com/playwright/dotnet:v1.57.0-noble' } } stages { stage('e2e-tests') { steps { @@ -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.56.0-noble +image: mcr.microsoft.com/playwright/dotnet:v1.57.0-noble ``` ### GitLab CI diff --git a/dotnet/versioned_docs/version-stable/docker.mdx b/dotnet/versioned_docs/version-stable/docker.mdx index db075a24a3..90dd50511a 100644 --- a/dotnet/versioned_docs/version-stable/docker.mdx +++ b/dotnet/versioned_docs/version-stable/docker.mdx @@ -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.56.0-noble +docker pull mcr.microsoft.com/playwright/dotnet:v1.57.0-noble ``` ### Run the image @@ -34,7 +34,7 @@ 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.56.0-noble /bin/bash +docker run -it --rm --ipc=host mcr.microsoft.com/playwright/dotnet:v1.57.0-noble /bin/bash ``` #### Crawling and scraping @@ -42,7 +42,7 @@ docker run -it --rm --ipc=host mcr.microsoft.com/playwright/dotnet:v1.56.0-noble 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.56.0-noble /bin/bash +docker run -it --rm --ipc=host --user pwuser --security-opt seccomp=seccomp_profile.json mcr.microsoft.com/playwright/dotnet:v1.57.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: @@ -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.56.0-noble /bin/sh -c "npx -y playwright@1.56.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.57.0-noble /bin/sh -c "npx -y playwright@1.57.0 run-server --port 3000 --host 0.0.0.0" ``` #### Connecting to the Server @@ -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.56.0-noble /bin/sh -c "npx -y playwright@1.56.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.57.0-noble /bin/sh -c "npx -y playwright@1.57.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. @@ -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.56.0` - Playwright v1.56.0 release docker image based on Ubuntu 24.04 LTS (Noble Numbat). -- `:v1.56.0-noble` - Playwright v1.56.0 release docker image based on Ubuntu 24.04 LTS (Noble Numbat). -- `:v1.56.0-jammy` - Playwright v1.56.0 release docker image based on Ubuntu 22.04 LTS (Jammy Jellyfish). +- `:v1.57.0` - Playwright v1.57.0 release docker image based on Ubuntu 24.04 LTS (Noble Numbat). +- `:v1.57.0-noble` - Playwright v1.57.0 release docker image based on Ubuntu 24.04 LTS (Noble Numbat). +- `:v1.57.0-jammy` - Playwright v1.57.0 release docker image based on Ubuntu 22.04 LTS (Jammy Jellyfish). :::note diff --git a/dotnet/versioned_docs/version-stable/release-notes.mdx b/dotnet/versioned_docs/version-stable/release-notes.mdx index bc1d3749aa..6c4a6eed8d 100644 --- a/dotnet/versioned_docs/version-stable/release-notes.mdx +++ b/dotnet/versioned_docs/version-stable/release-notes.mdx @@ -7,6 +7,34 @@ import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem'; import HTMLCard from '@site/src/components/HTMLCard'; +## Version 1.57 + +### Chrome for Testing + +Starting with this release, Playwright switches from Chromium, to using [Chrome for Testing](https://developer.chrome.com/blog/chrome-for-testing/) builds. Both headed and headless browsers are subject to this. Your tests should still be passing after upgrading to Playwright 1.57. + +We're expecting no functional changes to come from this switch. The biggest change is the new icon and title in your toolbar. + +![new and old logo](../images/cft-logo-change.png) + +If you still see an unexpected behaviour change, please [file an issue](https://github.com/microsoft/playwright/issues/new). + +On Arm64 Linux, Playwright continues to use Chromium. + +### Breaking Change + +After 3 years of being deprecated, we removed `Page.Accessibility` from our API. Please use other libraries such as [Axe](https://www.deque.com/axe/) if you need to test page accessibility. See our Node.js [guide](https://playwright.dev/docs/accessibility-testing) for integration with Axe. + +### New APIs +- [Worker.Console](/api/class-worker.mdx#worker-event-console) event is emitted when JavaScript within the worker calls one of console API methods, e.g. console.log or console.dir. +- [Locator.Description](/api/class-locator.mdx#locator-description) returns locator description previously set with [Locator.Describe()](/api/class-locator.mdx#locator-describe). +- New option [Steps](/api/class-locator.mdx#locator-click-option-steps) in [Locator.ClickAsync()](/api/class-locator.mdx#locator-click) and [Locator.DragToAsync()](/api/class-locator.mdx#locator-drag-to) that configures the number of `mousemove` events emitted while moving the mouse pointer to the target element. + +### Browser Versions +- Chromium 143.0.7499.4 +- Mozilla Firefox 144.0.2 +- WebKit 26.0 + ## Version 1.56 ### New APIs diff --git a/java/versioned_docs/version-stable/api/class-worker.mdx b/java/versioned_docs/version-stable/api/class-worker.mdx index db74ebe8fb..0b07a89e82 100644 --- a/java/versioned_docs/version-stable/api/class-worker.mdx +++ b/java/versioned_docs/version-stable/api/class-worker.mdx @@ -126,6 +126,36 @@ Worker.waitForClose(callback, options); --- +### waitForConsoleMessage {#worker-wait-for-console-message} + +Added in: v1.57worker.waitForConsoleMessage + +Performs action and waits for a console message. + +**Usage** + +```java +Worker.waitForConsoleMessage(callback); +Worker.waitForConsoleMessage(callback, options); +``` + +**Arguments** +- `options` `Worker.WaitForConsoleMessageOptions` *(optional)* + - `setPredicate` [Predicate]<[ConsoleMessage]> *(optional)*# + + Receives the [ConsoleMessage] object and resolves to true when the waiting should resolve. + - `setTimeout` [double] *(optional)*# + + Maximum time to wait for 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). +- `callback` [Runnable]# + + Callback that performs the action triggering the event. + +**Returns** +- [ConsoleMessage]# + +--- + ## Events ### onClose(handler) {#worker-event-close} diff --git a/java/versioned_docs/version-stable/ci.mdx b/java/versioned_docs/version-stable/ci.mdx index 4c29ffc3ff..1ea0950385 100644 --- a/java/versioned_docs/version-stable/ci.mdx +++ b/java/versioned_docs/version-stable/ci.mdx @@ -75,7 +75,7 @@ jobs: name: 'Playwright Tests' runs-on: ubuntu-latest container: - image: mcr.microsoft.com/playwright/java:v1.56.0-noble + image: mcr.microsoft.com/playwright/java:v1.57.0-noble options: --user 1001 steps: - uses: actions/checkout@v5 @@ -160,7 +160,7 @@ trigger: pool: vmImage: ubuntu-latest -container: mcr.microsoft.com/playwright/java:v1.56.0-noble +container: mcr.microsoft.com/playwright/java:v1.57.0-noble steps: - task: JavaToolInstaller@1 @@ -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.56.0-noble + - image: mcr.microsoft.com/playwright/java:v1.57.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. @@ -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.56.0-noble' } } + agent { docker { image 'mcr.microsoft.com/playwright/java:v1.57.0-noble' } } stages { stage('e2e-tests') { steps { @@ -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.56.0-noble +image: mcr.microsoft.com/playwright/java:v1.57.0-noble ``` ### GitLab CI @@ -224,7 +224,7 @@ stages: tests: stage: test - image: mcr.microsoft.com/playwright/java:v1.56.0-noble + image: mcr.microsoft.com/playwright/java:v1.57.0-noble script: ... ``` diff --git a/java/versioned_docs/version-stable/docker.mdx b/java/versioned_docs/version-stable/docker.mdx index 9b2b037da1..8319cb65c4 100644 --- a/java/versioned_docs/version-stable/docker.mdx +++ b/java/versioned_docs/version-stable/docker.mdx @@ -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/java:v1.56.0-noble +docker pull mcr.microsoft.com/playwright/java:v1.57.0-noble ``` ### Run the image @@ -34,7 +34,7 @@ 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/java:v1.56.0-noble /bin/bash +docker run -it --rm --ipc=host mcr.microsoft.com/playwright/java:v1.57.0-noble /bin/bash ``` #### Crawling and scraping @@ -42,7 +42,7 @@ docker run -it --rm --ipc=host mcr.microsoft.com/playwright/java:v1.56.0-noble / 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/java:v1.56.0-noble /bin/bash +docker run -it --rm --ipc=host --user pwuser --security-opt seccomp=seccomp_profile.json mcr.microsoft.com/playwright/java:v1.57.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: @@ -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.56.0-noble /bin/sh -c "npx -y playwright@1.56.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.57.0-noble /bin/sh -c "npx -y playwright@1.57.0 run-server --port 3000 --host 0.0.0.0" ``` #### Connecting to the Server @@ -107,7 +107,7 @@ public class App { 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.56.0-noble /bin/sh -c "npx -y playwright@1.56.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.57.0-noble /bin/sh -c "npx -y playwright@1.57.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. @@ -122,9 +122,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.56.0` - Playwright v1.56.0 release docker image based on Ubuntu 24.04 LTS (Noble Numbat). -- `:v1.56.0-noble` - Playwright v1.56.0 release docker image based on Ubuntu 24.04 LTS (Noble Numbat). -- `:v1.56.0-jammy` - Playwright v1.56.0 release docker image based on Ubuntu 22.04 LTS (Jammy Jellyfish). +- `:v1.57.0` - Playwright v1.57.0 release docker image based on Ubuntu 24.04 LTS (Noble Numbat). +- `:v1.57.0-noble` - Playwright v1.57.0 release docker image based on Ubuntu 24.04 LTS (Noble Numbat). +- `:v1.57.0-jammy` - Playwright v1.57.0 release docker image based on Ubuntu 22.04 LTS (Jammy Jellyfish). :::note diff --git a/java/versioned_docs/version-stable/intro.mdx b/java/versioned_docs/version-stable/intro.mdx index f2dfcae2e9..c987e6efcd 100644 --- a/java/versioned_docs/version-stable/intro.mdx +++ b/java/versioned_docs/version-stable/intro.mdx @@ -58,7 +58,7 @@ public class App { com.microsoft.playwright playwright - 1.56.0 + 1.57.0 diff --git a/java/versioned_docs/version-stable/release-notes.mdx b/java/versioned_docs/version-stable/release-notes.mdx index e0cb4b53dd..5b728b4c89 100644 --- a/java/versioned_docs/version-stable/release-notes.mdx +++ b/java/versioned_docs/version-stable/release-notes.mdx @@ -7,6 +7,34 @@ import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem'; import HTMLCard from '@site/src/components/HTMLCard'; +## Version 1.57 + +### Chrome for Testing + +Starting with this release, Playwright switches from Chromium, to using [Chrome for Testing](https://developer.chrome.com/blog/chrome-for-testing/) builds. Both headed and headless browsers are subject to this. Your tests should still be passing after upgrading to Playwright 1.57. + +We're expecting no functional changes to come from this switch. The biggest change is the new icon and title in your toolbar. + +![new and old logo](../images/cft-logo-change.png) + +If you still see an unexpected behaviour change, please [file an issue](https://github.com/microsoft/playwright/issues/new). + +On Arm64 Linux, Playwright continues to use Chromium. + +### Breaking Change + +After 3 years of being deprecated, we removed `page.accessibility()` from our API. Please use other libraries such as [Axe](https://www.deque.com/axe/) if you need to test page accessibility. See our Node.js [guide](https://playwright.dev/docs/accessibility-testing) for integration with Axe. + +### New APIs +- [Worker.onConsole(handler)](/api/class-worker.mdx#worker-event-console) event is emitted when JavaScript within the worker calls one of console API methods, e.g. console.log or console.dir. [Worker.waitForConsoleMessage()](/api/class-worker.mdx#worker-wait-for-console-message) can be used to wait for it. +- [Locator.description()](/api/class-locator.mdx#locator-description) returns locator description previously set with [Locator.describe()](/api/class-locator.mdx#locator-describe). +- New option [setSteps](/api/class-locator.mdx#locator-click-option-steps) in [Locator.click()](/api/class-locator.mdx#locator-click) and [Locator.dragTo()](/api/class-locator.mdx#locator-drag-to) that configures the number of `mousemove` events emitted while moving the mouse pointer to the target element. + +### Browser Versions +- Chromium 143.0.7499.4 +- Mozilla Firefox 144.0.2 +- WebKit 26.0 + ## Version 1.56 ### New APIs diff --git a/java/versioned_docs/version-stable/test-runners.mdx b/java/versioned_docs/version-stable/test-runners.mdx index b170f8debb..c139ed7df6 100644 --- a/java/versioned_docs/version-stable/test-runners.mdx +++ b/java/versioned_docs/version-stable/test-runners.mdx @@ -198,7 +198,7 @@ repositories { } dependencies { - implementation 'com.microsoft.playwright:playwright:1.56.0' + implementation 'com.microsoft.playwright:playwright:1.57.0' } application { @@ -231,7 +231,7 @@ repositories { } dependencies { - implementation("com.microsoft.playwright:playwright:1.56.0") + implementation("com.microsoft.playwright:playwright:1.57.0") } application { diff --git a/nodejs/versioned_docs/version-stable/release-notes.mdx b/nodejs/versioned_docs/version-stable/release-notes.mdx index 9d9fe7e7d3..f4bee905bf 100644 --- a/nodejs/versioned_docs/version-stable/release-notes.mdx +++ b/nodejs/versioned_docs/version-stable/release-notes.mdx @@ -64,7 +64,7 @@ This is not just useful for capturing varying ports of dev servers. You can also ### Breaking Change -After 3 years of being deprecated, we removed `Page#accessibility` from our API. Please use other libraries such as [Axe](https://www.deque.com/axe/) if you need to test page accessibility. See our Node.js [guide](https://playwright.dev/docs/accessibility-testing) for integration with Axe. +After 3 years of being deprecated, we removed `page.accessibility` from our API. Please use other libraries such as [Axe](https://www.deque.com/axe/) if you need to test page accessibility. See our Node.js [guide](https://playwright.dev/docs/accessibility-testing) for integration with Axe. ### New APIs - New property [testConfig.tag](/api/class-testconfig.mdx#test-config-tag) adds a tag to all tests in this run. This is useful when using [merge-reports](./test-sharding.mdx#merging-reports-from-multiple-shards). @@ -76,7 +76,7 @@ After 3 years of being deprecated, we removed `Page#accessibility` from our API. ### Browser Versions - Chromium 143.0.7499.4 -- Mozilla Firefox 142.0.1 +- Mozilla Firefox 144.0.2 - WebKit 26.0 ## Version 1.56 diff --git a/python/versioned_docs/version-stable/api/class-request.mdx b/python/versioned_docs/version-stable/api/class-request.mdx index 6f047b19a3..5dcc69043a 100644 --- a/python/versioned_docs/version-stable/api/class-request.mdx +++ b/python/versioned_docs/version-stable/api/class-request.mdx @@ -393,6 +393,29 @@ request.resource_type --- +### service_worker {#request-service-worker} + +Added in: v1.24request.service_worker + +The Service [Worker] that is performing the request. + +**Usage** + +```python +request.service_worker +``` + +**Returns** +- [NoneType] | [Worker]# + +**Details** + +This method is Chromium only. It's safe to call when using other browsers, but it will always be `null`. + +Requests originated in a Service Worker do not have a [request.frame](/api/class-request.mdx#request-frame) available. + +--- + ### timing {#request-timing} Added before v1.9request.timing diff --git a/python/versioned_docs/version-stable/ci.mdx b/python/versioned_docs/version-stable/ci.mdx index 398dcc9b3a..ef8ac08626 100644 --- a/python/versioned_docs/version-stable/ci.mdx +++ b/python/versioned_docs/version-stable/ci.mdx @@ -83,7 +83,7 @@ jobs: name: 'Playwright Tests' runs-on: ubuntu-latest container: - image: mcr.microsoft.com/playwright/python:v1.56.0-noble + image: mcr.microsoft.com/playwright/python:v1.57.0-noble options: --user 1001 steps: - uses: actions/checkout@v5 @@ -173,7 +173,7 @@ trigger: pool: vmImage: ubuntu-latest -container: mcr.microsoft.com/playwright/python:v1.56.0-noble +container: mcr.microsoft.com/playwright/python:v1.57.0-noble steps: - task: UsePythonVersion@0 @@ -197,7 +197,7 @@ Running Playwright on CircleCI is very similar to running on GitHub Actions. In executors: pw-noble-development: docker: - - image: mcr.microsoft.com/playwright/python:v1.56.0-noble + - image: mcr.microsoft.com/playwright/python:v1.57.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. @@ -208,7 +208,7 @@ Jenkins supports Docker agents for pipelines. Use the [Playwright Docker image]( ```groovy pipeline { - agent { docker { image 'mcr.microsoft.com/playwright/python:v1.56.0-noble' } } + agent { docker { image 'mcr.microsoft.com/playwright/python:v1.57.0-noble' } } stages { stage('e2e-tests') { steps { @@ -225,7 +225,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/python:v1.56.0-noble +image: mcr.microsoft.com/playwright/python:v1.57.0-noble ``` ### GitLab CI @@ -238,7 +238,7 @@ stages: tests: stage: test - image: mcr.microsoft.com/playwright/python:v1.56.0-noble + image: mcr.microsoft.com/playwright/python:v1.57.0-noble script: ... ``` diff --git a/python/versioned_docs/version-stable/docker.mdx b/python/versioned_docs/version-stable/docker.mdx index afb776042f..94e8d9f152 100644 --- a/python/versioned_docs/version-stable/docker.mdx +++ b/python/versioned_docs/version-stable/docker.mdx @@ -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/python:v1.56.0-noble +docker pull mcr.microsoft.com/playwright/python:v1.57.0-noble ``` ### Run the image @@ -34,7 +34,7 @@ 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/python:v1.56.0-noble /bin/bash +docker run -it --rm --ipc=host mcr.microsoft.com/playwright/python:v1.57.0-noble /bin/bash ``` #### Crawling and scraping @@ -42,7 +42,7 @@ docker run -it --rm --ipc=host mcr.microsoft.com/playwright/python:v1.56.0-noble 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/python:v1.56.0-noble /bin/bash +docker run -it --rm --ipc=host --user pwuser --security-opt seccomp=seccomp_profile.json mcr.microsoft.com/playwright/python:v1.57.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: @@ -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.56.0-noble /bin/sh -c "npx -y playwright@1.56.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.57.0-noble /bin/sh -c "npx -y playwright@1.57.0 run-server --port 3000 --host 0.0.0.0" ``` #### Connecting to the Server @@ -122,7 +122,7 @@ async with async_playwright() as p: 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.56.0-noble /bin/sh -c "npx -y playwright@1.56.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.57.0-noble /bin/sh -c "npx -y playwright@1.57.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. @@ -137,9 +137,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.56.0` - Playwright v1.56.0 release docker image based on Ubuntu 24.04 LTS (Noble Numbat). -- `:v1.56.0-noble` - Playwright v1.56.0 release docker image based on Ubuntu 24.04 LTS (Noble Numbat). -- `:v1.56.0-jammy` - Playwright v1.56.0 release docker image based on Ubuntu 22.04 LTS (Jammy Jellyfish). +- `:v1.57.0` - Playwright v1.57.0 release docker image based on Ubuntu 24.04 LTS (Noble Numbat). +- `:v1.57.0-noble` - Playwright v1.57.0 release docker image based on Ubuntu 24.04 LTS (Noble Numbat). +- `:v1.57.0-jammy` - Playwright v1.57.0 release docker image based on Ubuntu 22.04 LTS (Jammy Jellyfish). :::note @@ -163,7 +163,7 @@ To run Playwright inside Docker, you need to have Python, [Playwright browsers]( ```Dockerfile FROM python:3.12-bookworm -RUN pip install playwright==@1.56.0 && \ +RUN pip install playwright==@1.57.0 && \ playwright install --with-deps ``` diff --git a/python/versioned_docs/version-stable/release-notes.mdx b/python/versioned_docs/version-stable/release-notes.mdx index d58382dadc..4e812e15f8 100644 --- a/python/versioned_docs/version-stable/release-notes.mdx +++ b/python/versioned_docs/version-stable/release-notes.mdx @@ -7,6 +7,36 @@ import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem'; import HTMLCard from '@site/src/components/HTMLCard'; +## Version 1.57 + +### Chrome for Testing + +Starting with this release, Playwright switches from Chromium, to using [Chrome for Testing](https://developer.chrome.com/blog/chrome-for-testing/) builds. Both headed and headless browsers are subject to this. Your tests should still be passing after upgrading to Playwright 1.57. + +We're expecting no functional changes to come from this switch. The biggest change is the new icon and title in your toolbar. + +![new and old logo](../images/cft-logo-change.png) + +If you still see an unexpected behaviour change, please [file an issue](https://github.com/microsoft/playwright/issues/new). + +On Arm64 Linux, Playwright continues to use Chromium. + +### Breaking Change + +After 3 years of being deprecated, we removed `page.accessibility` from our API. Please use other libraries such as [Axe](https://www.deque.com/axe/) if you need to test page accessibility. See our Node.js [guide](https://playwright.dev/docs/accessibility-testing) for integration with Axe. + +### New APIs +- [worker.on("console")](/api/class-worker.mdx#worker-event-console) event is emitted when JavaScript within the worker calls one of console API methods, e.g. console.log or console.dir. [worker.expect_event()](/api/class-worker.mdx#worker-wait-for-event) can be used to wait for it. +- [locator.description](/api/class-locator.mdx#locator-description) returns locator description previously set with [locator.describe()](/api/class-locator.mdx#locator-describe). +- New option [steps](/api/class-locator.mdx#locator-click-option-steps) in [locator.click()](/api/class-locator.mdx#locator-click) and [locator.drag_to()](/api/class-locator.mdx#locator-drag-to) that configures the number of `mousemove` events emitted while moving the mouse pointer to the target element. +- Network requests issued by [Service Workers](./service-workers.mdx#network-events-and-routing) are now reported and can be routed through the [BrowserContext](./api/class-browsercontext.mdx), only in Chromium. You can opt out using the `PLAYWRIGHT_DISABLE_SERVICE_WORKER_NETWORK` environment variable. +- Console messages from Service Workers are dispatched through [worker.on("console")](/api/class-worker.mdx#worker-event-console). You can opt out of this using the `PLAYWRIGHT_DISABLE_SERVICE_WORKER_CONSOLE` environment variable. + +### Browser Versions +- Chromium 143.0.7499.4 +- Mozilla Firefox 144.0.2 +- WebKit 26.0 + ## Version 1.56 ### New APIs diff --git a/python/versioned_docs/version-stable/service-workers.mdx b/python/versioned_docs/version-stable/service-workers.mdx new file mode 100644 index 0000000000..c3180e09b3 --- /dev/null +++ b/python/versioned_docs/version-stable/service-workers.mdx @@ -0,0 +1,262 @@ +--- +id: service-workers +title: "Service Workers" +--- +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import HTMLCard from '@site/src/components/HTMLCard'; + +## Introduction + +:::warning + +Service workers are only supported on Chromium-based browsers. +::: + +:::note +If you're looking to do general network mocking, routing, and interception, please see the [Network Guide](./network.mdx) first. Playwright provides built-in APIs for this use case that don't require the information below. However, if you're interested in requests made by Service Workers themselves, please read below. +::: + +[Service Workers](https://developer.mozilla.org/en-US/docs/Web/API/Service_Worker_API) provide a browser-native method of handling requests made by a page with the native [Fetch API (`fetch`)](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API) along with other network-requested assets (like scripts, css, and images). + +They can act as a **network proxy** between the page and the external network to perform caching logic or can provide users with an offline experience if the Service Worker adds a [FetchEvent](https://developer.mozilla.org/en-US/docs/Web/API/FetchEvent#examples) listener. + +Many sites that use Service Workers simply use them as a transparent optimization technique. While users might notice a faster experience, the app's implementation is unaware of their existence. Running the app with or without Service Workers enabled appears functionally equivalent. + +## How to Disable Service Workers + +Playwright allows to disable Service Workers during testing. This makes tests more predictable and performant. However, if your actual page uses a Service Worker, the behavior might be different. + +To disable service workers, set `service_workers` context option to `"block"`. + +```python title="conftest.py" +import pytest + +@pytest.fixture(scope="session") +def browser_context_args(browser_context_args): + return { + **browser_context_args, + "service_workers": "block" + } +``` + +## Accessing Service Workers and Waiting for Activation + +You can use [browser_context.service_workers](/api/class-browsercontext.mdx#browser-context-service-workers) to list the Service [Worker]s, or specifically watch for the Service [Worker] if you anticipate a page will trigger its [registration](https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerContainer/register): + + + + +```py +with context.expect_event("serviceworker") as worker_info: + page.goto("/example-with-a-service-worker.html") +service_worker = worker_info.value +``` + + + + +```py +async with context.expect_event("serviceworker") as worker_info: + await page.goto("/example-with-a-service-worker.html") +service_worker = await worker_info.value +``` + + + + +[browser_context.on("serviceworker")](/api/class-browsercontext.mdx#browser-context-event-service-worker) event is fired ***before*** the Service Worker has taken control over the page, so ***before*** evaluating in the worker with [worker.evaluate()](/api/class-worker.mdx#worker-evaluate) you should wait on its activation. + +There are more idiomatic methods of waiting for a Service Worker to be activated, but the following is an implementation agnostic method: + + + + +```py +page.evaluate("""async () => { + const registration = await window.navigator.serviceWorker.getRegistration(); + if (registration.active?.state === 'activated') + return; + await new Promise(resolve => { + window.navigator.serviceWorker.addEventListener('controllerchange', resolve); + }); +}""") +``` + + + + +```py +await page.evaluate("""async () => { + const registration = await window.navigator.serviceWorker.getRegistration(); + if (registration.active?.state === 'activated') + return; + await new Promise(resolve => { + window.navigator.serviceWorker.addEventListener('controllerchange', resolve); + }); +}""") +``` + + + + +## Network Events and Routing + +Any network request made by the **Service Worker** is reported through the [BrowserContext] object: +* [browser_context.on("request")](/api/class-browsercontext.mdx#browser-context-event-request), [browser_context.on("requestfinished")](/api/class-browsercontext.mdx#browser-context-event-request-finished), [browser_context.on("response")](/api/class-browsercontext.mdx#browser-context-event-response) and [browser_context.on("requestfailed")](/api/class-browsercontext.mdx#browser-context-event-request-failed) are fired +* [browser_context.route()](/api/class-browsercontext.mdx#browser-context-route) sees the request +* [request.service_worker](/api/class-request.mdx#request-service-worker) will be set to the Service [Worker] instance, and [request.frame](/api/class-request.mdx#request-frame) will **throw** + +Additionally, for any network request made by the **Page**, method [response.from_service_worker](/api/class-response.mdx#response-from-service-worker) return `true` when the request was handled a Service Worker's fetch handler. + +Consider a simple service worker that fetches every request made by the page: + +If `index.html` registers this service worker, and then fetches `data.json`, the following Request/Response events would be emitted (along with the corresponding network lifecycle events): + +| Event | Owner | URL | Routed | [response.from_service_worker](/api/class-response.mdx#response-from-service-worker) | +| - | - | - | - | - | +| [browser_context.on("request")](/api/class-browsercontext.mdx#browser-context-event-request) | [Frame] | index.html | Yes | | +| [page.on("request")](/api/class-page.mdx#page-event-request) | [Frame] | index.html | Yes | | +| [browser_context.on("request")](/api/class-browsercontext.mdx#browser-context-event-request) | Service [Worker] | transparent-service-worker.js | Yes | | +| [browser_context.on("request")](/api/class-browsercontext.mdx#browser-context-event-request) | Service [Worker] | data.json | Yes | | +| [browser_context.on("request")](/api/class-browsercontext.mdx#browser-context-event-request) | [Frame] | data.json | | Yes | +| [page.on("request")](/api/class-page.mdx#page-event-request) | [Frame] | data.json | | Yes | + +Since the example Service Worker just acts a basic transparent "proxy": +* There's 2 [browser_context.on("request")](/api/class-browsercontext.mdx#browser-context-event-request) events for `data.json`; one [Frame]-owned, the other Service [Worker]-owned. +* Only the Service [Worker]-owned request for the resource was routable via [browser_context.route()](/api/class-browsercontext.mdx#browser-context-route); the [Frame]-owned events for `data.json` are not routeable, as they would not have even had the possibility to hit the external network since the Service Worker has a fetch handler registered. + +:::caution + +It's important to note: calling [request.frame](/api/class-request.mdx#request-frame) or [response.frame](/api/class-response.mdx#response-frame) will **throw** an exception, if called on a [Request]/[Response] that has a non-null [request.service_worker](/api/class-request.mdx#request-service-worker). +::: + +## Routing Service Worker Requests Only + + + + +```py +def handle_route(route: Route): + if route.request.service_worker: + # NB: accessing route.request.frame here would THROW + route.fulfill(content_type="text/plain", status=200, body="from sw") + else: + route.continue_() + +context.route("**", handle_route) +``` + + + + +```py +async def handle_route(route: Route): + if route.request.service_worker: + # NB: accessing route.request.frame here would THROW + await route.fulfill(content_type="text/plain", status=200, body="from sw") + else: + await route.continue_() + +await context.route("**", handle_route) +``` + + + + +## Known Limitations + +Requests for updated Service Worker main script code currently cannot be routed (https://github.com/microsoft/playwright/issues/14711). + + +[APIRequest]: /api/class-apirequest.mdx "APIRequest" +[APIRequestContext]: /api/class-apirequestcontext.mdx "APIRequestContext" +[APIResponse]: /api/class-apiresponse.mdx "APIResponse" +[APIResponseAssertions]: /api/class-apiresponseassertions.mdx "APIResponseAssertions" +[Browser]: /api/class-browser.mdx "Browser" +[BrowserContext]: /api/class-browsercontext.mdx "BrowserContext" +[BrowserType]: /api/class-browsertype.mdx "BrowserType" +[CDPSession]: /api/class-cdpsession.mdx "CDPSession" +[Clock]: /api/class-clock.mdx "Clock" +[ConsoleMessage]: /api/class-consolemessage.mdx "ConsoleMessage" +[Dialog]: /api/class-dialog.mdx "Dialog" +[Download]: /api/class-download.mdx "Download" +[ElementHandle]: /api/class-elementhandle.mdx "ElementHandle" +[Error]: /api/class-error.mdx "Error" +[FileChooser]: /api/class-filechooser.mdx "FileChooser" +[Frame]: /api/class-frame.mdx "Frame" +[FrameLocator]: /api/class-framelocator.mdx "FrameLocator" +[JSHandle]: /api/class-jshandle.mdx "JSHandle" +[Keyboard]: /api/class-keyboard.mdx "Keyboard" +[Locator]: /api/class-locator.mdx "Locator" +[LocatorAssertions]: /api/class-locatorassertions.mdx "LocatorAssertions" +[Mouse]: /api/class-mouse.mdx "Mouse" +[Page]: /api/class-page.mdx "Page" +[PageAssertions]: /api/class-pageassertions.mdx "PageAssertions" +[Playwright]: /api/class-playwright.mdx "Playwright" +[Request]: /api/class-request.mdx "Request" +[Response]: /api/class-response.mdx "Response" +[Route]: /api/class-route.mdx "Route" +[Selectors]: /api/class-selectors.mdx "Selectors" +[TimeoutError]: /api/class-timeouterror.mdx "TimeoutError" +[Touchscreen]: /api/class-touchscreen.mdx "Touchscreen" +[Tracing]: /api/class-tracing.mdx "Tracing" +[Video]: /api/class-video.mdx "Video" +[WebError]: /api/class-weberror.mdx "WebError" +[WebSocket]: /api/class-websocket.mdx "WebSocket" +[WebSocketRoute]: /api/class-websocketroute.mdx "WebSocketRoute" +[Worker]: /api/class-worker.mdx "Worker" +[Element]: https://developer.mozilla.org/en-US/docs/Web/API/element "Element" +[EvaluationArgument]: /evaluating.mdx#evaluation-argument "EvaluationArgument" +[Promise]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise "Promise" +[iterator]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols "Iterator" +[origin]: https://developer.mozilla.org/en-US/docs/Glossary/Origin "Origin" +[selector]: https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Selectors "selector" +[Serializable]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify#Description "Serializable" +[UIEvent.detail]: https://developer.mozilla.org/en-US/docs/Web/API/UIEvent/detail "UIEvent.detail" +[UnixTime]: https://en.wikipedia.org/wiki/Unix_time "Unix Time" +[xpath]: https://developer.mozilla.org/en-US/docs/Web/XPath "xpath" + +[Any]: https://docs.python.org/3/library/typing.html#typing.Any "Any" +[bool]: https://docs.python.org/3/library/stdtypes.html "bool" +[bytes]: https://docs.python.org/3/library/stdtypes.html#bytes "bytes" +[Callable]: https://docs.python.org/3/library/typing.html#typing.Callable "Callable" +[EventContextManager]: https://docs.python.org/3/reference/datamodel.html#context-managers "Event context manager" +[EventEmitter]: https://pyee.readthedocs.io/en/latest/#pyee.BaseEventEmitter "EventEmitter" +[Exception]: https://docs.python.org/3/library/exceptions.html#Exception "Exception" +[Dict]: https://docs.python.org/3/library/typing.html#typing.Dict "Dict" +[float]: https://docs.python.org/3/library/stdtypes.html#numeric-types-int-float-complex "float" +[int]: https://docs.python.org/3/library/stdtypes.html#numeric-types-int-float-complex "int" +[List]: https://docs.python.org/3/library/typing.html#typing.List "List" +[NoneType]: https://docs.python.org/3/library/constants.html#None "None" +[Pattern]: https://docs.python.org/3/library/re.html "Pattern" +[URL]: https://en.wikipedia.org/wiki/URL "URL" +[pathlib.Path]: https://realpython.com/python-pathlib/ "pathlib.Path" +[str]: https://docs.python.org/3/library/stdtypes.html#text-sequence-type-str "str" +[Union]: https://docs.python.org/3/library/typing.html#typing.Union "Union" +[datetime]: https://docs.python.org/3/library/datetime.html#datetime.datetime "datetime" + +[all available image tags]: https://mcr.microsoft.com/en-us/product/playwright/python/about "all available image tags" +[Microsoft Artifact Registry]: https://mcr.microsoft.com/en-us/product/playwright/python/about "Microsoft Artifact Registry" +[Dockerfile.noble]: https://github.com/microsoft/playwright-python/blob/main/utils/docker/Dockerfile.noble "Dockerfile.noble"