diff --git a/dotnet/docs/mock.mdx b/dotnet/docs/mock.mdx index 9ffa153af2f..e5eda9b5e8d 100644 --- a/dotnet/docs/mock.mdx +++ b/dotnet/docs/mock.mdx @@ -82,6 +82,9 @@ To record a HAR file we use [Page.RouteFromHARAsync()](/api/class-page.mdx#page- Setting `update` option to true will create or update the HAR file with the actual network information instead of serving the requests from the HAR file. Use it when creating a test to populate the HAR with real data. +#### +Alternatively, you can also record HAR files by using the [RecordHarPath](/api/class-browser.mdx#browser-new-context-option-record-har-path) option in [Browser.NewContextAsync()](/api/class-browser.mdx#browser-new-context) when creating a browser context. This allows you to capture all network traffic for the entire context until the context is closed. + ```csharp // Get the response from the HAR file await page.RouteFromHARAsync("./hars/fruit.har", new () { diff --git a/java/docs/mock.mdx b/java/docs/mock.mdx index 3764e69431b..4e102340503 100644 --- a/java/docs/mock.mdx +++ b/java/docs/mock.mdx @@ -80,6 +80,9 @@ To record a HAR file we use [Page.routeFromHAR()](/api/class-page.mdx#page-route Setting `update` option to true will create or update the HAR file with the actual network information instead of serving the requests from the HAR file. Use it when creating a test to populate the HAR with real data. +#### +Alternatively, you can also record HAR files by using the [setRecordHarPath](/api/class-browser.mdx#browser-new-context-option-record-har-path) option in [Browser.newContext()](/api/class-browser.mdx#browser-new-context) when creating a browser context. This allows you to capture all network traffic for the entire context until the context is closed. + ```java // Get the response from the HAR file page.routeFromHAR(Path.of("./hars/fruit.har"), new RouteFromHAROptions() diff --git a/nodejs/docs/ci.mdx b/nodejs/docs/ci.mdx index d42de5d8db3..c0d6f8dbf2f 100644 --- a/nodejs/docs/ci.mdx +++ b/nodejs/docs/ci.mdx @@ -101,7 +101,7 @@ jobs: name: 'Playwright Tests' runs-on: ubuntu-latest container: - image: mcr.microsoft.com/playwright:v1.53.2-noble + image: mcr.microsoft.com/playwright:v1.54.0-noble options: --user 1001 steps: - uses: actions/checkout@v4 @@ -335,7 +335,7 @@ trigger: pool: vmImage: ubuntu-latest -container: mcr.microsoft.com/playwright:v1.53.2-noble +container: mcr.microsoft.com/playwright:v1.54.0-noble steps: - task: NodeTool@0 @@ -359,7 +359,7 @@ Running Playwright on CircleCI is very similar to running on GitHub Actions. In executors: pw-noble-development: docker: - - image: mcr.microsoft.com/playwright:v1.53.2-noble + - image: mcr.microsoft.com/playwright:v1.54.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. @@ -382,7 +382,7 @@ Jenkins supports Docker agents for pipelines. Use the [Playwright Docker image]( ```groovy pipeline { - agent { docker { image 'mcr.microsoft.com/playwright:v1.53.2-noble' } } + agent { docker { image 'mcr.microsoft.com/playwright:v1.54.0-noble' } } stages { stage('e2e-tests') { steps { @@ -399,7 +399,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:v1.53.2-noble +image: mcr.microsoft.com/playwright:v1.54.0-noble ``` ### GitLab CI @@ -412,7 +412,7 @@ stages: tests: stage: test - image: mcr.microsoft.com/playwright:v1.53.2-noble + image: mcr.microsoft.com/playwright:v1.54.0-noble script: ... ``` @@ -427,7 +427,7 @@ stages: tests: stage: test - image: mcr.microsoft.com/playwright:v1.53.2-noble + image: mcr.microsoft.com/playwright:v1.54.0-noble parallel: 7 script: - npm ci @@ -442,7 +442,7 @@ stages: tests: stage: test - image: mcr.microsoft.com/playwright:v1.53.2-noble + image: mcr.microsoft.com/playwright:v1.54.0-noble parallel: matrix: - PROJECT: ['chromium', 'webkit'] @@ -458,7 +458,7 @@ To run Playwright tests on Google Cloud Build, use our public Docker image ([see ```yml steps: -- name: mcr.microsoft.com/playwright:v1.53.2-noble +- name: mcr.microsoft.com/playwright:v1.54.0-noble script: ... env: @@ -476,7 +476,7 @@ type: docker steps: - name: test - image: mcr.microsoft.com/playwright:v1.53.2-noble + image: mcr.microsoft.com/playwright:v1.54.0-noble commands: - npx playwright test ``` diff --git a/nodejs/docs/docker.mdx b/nodejs/docs/docker.mdx index 64b78c0f0aa..fea16bea235 100644 --- a/nodejs/docs/docker.mdx +++ b/nodejs/docs/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:v1.53.2-noble +docker pull mcr.microsoft.com/playwright:v1.54.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:v1.53.2-noble /bin/bash +docker run -it --rm --ipc=host mcr.microsoft.com/playwright:v1.54.0-noble /bin/bash ``` #### Crawling and scraping @@ -42,7 +42,7 @@ docker run -it --rm --ipc=host mcr.microsoft.com/playwright:v1.53.2-noble /bin/b 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:v1.53.2-noble /bin/bash +docker run -it --rm --ipc=host --user pwuser --security-opt seccomp=seccomp_profile.json mcr.microsoft.com/playwright:v1.54.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.53.2-noble /bin/sh -c "npx -y playwright@1.53.2 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.54.0-noble /bin/sh -c "npx -y playwright@1.54.0 run-server --port 3000 --host 0.0.0.0" ``` #### Connecting to the Server @@ -105,7 +105,7 @@ const browser = await playwright['chromium'].connect('ws://127.0.0.1:3000/'); 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.53.2-noble /bin/sh -c "npx -y playwright@1.53.2 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.54.0-noble /bin/sh -c "npx -y playwright@1.54.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. @@ -120,9 +120,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.53.2` - Playwright v1.53.2 release docker image based on Ubuntu 24.04 LTS (Noble Numbat). -- `:v1.53.2-noble` - Playwright v1.53.2 release docker image based on Ubuntu 24.04 LTS (Noble Numbat). -- `:v1.53.2-jammy` - Playwright v1.53.2 release docker image based on Ubuntu 22.04 LTS (Jammy Jellyfish). +- `:v1.54.0` - Playwright v1.54.0 release docker image based on Ubuntu 24.04 LTS (Noble Numbat). +- `:v1.54.0-noble` - Playwright v1.54.0 release docker image based on Ubuntu 24.04 LTS (Noble Numbat). +- `:v1.54.0-jammy` - Playwright v1.54.0 release docker image based on Ubuntu 22.04 LTS (Jammy Jellyfish). :::note @@ -146,7 +146,7 @@ To run Playwright inside Docker, you need to have Node.js, [Playwright browsers] ```Dockerfile FROM node:20-bookworm -RUN npx -y playwright@1.53.2 install --with-deps +RUN npx -y playwright@1.54.0 install --with-deps ``` diff --git a/nodejs/docs/mock.mdx b/nodejs/docs/mock.mdx index 6f8dd069b49..13548590c02 100644 --- a/nodejs/docs/mock.mdx +++ b/nodejs/docs/mock.mdx @@ -78,21 +78,8 @@ To record a HAR file we use [page.routeFromHAR()](/api/class-page.mdx#page-route Setting `update` option to true will create or update the HAR file with the actual network information instead of serving the requests from the HAR file. Use it when creating a test to populate the HAR with real data. -```js -test('records or updates the HAR file', async ({ page }) => { - // Get the response from the HAR file - await page.routeFromHAR('./hars/fruit.har', { - url: '*/**/api/v1/fruits', - update: true, - }); - - // Go to the page - await page.goto('https://demo.playwright.dev/api-mocking'); - - // Assert that the fruit is visible - await expect(page.getByText('Strawberry')).toBeVisible(); -}); -``` +#### +Alternatively, you can also record HAR files by using the [recordHar](/api/class-browser.mdx#browser-new-context-option-record-har) option in [browser.newContext()](/api/class-browser.mdx#browser-new-context) when creating a browser context. This allows you to capture all network traffic for the entire context until the context is closed. ### Modifying a HAR file diff --git a/python/docs/mock.mdx b/python/docs/mock.mdx index 45abcc537a2..8b5dec87626 100644 --- a/python/docs/mock.mdx +++ b/python/docs/mock.mdx @@ -147,6 +147,9 @@ To record a HAR file we use [page.route_from_har()](/api/class-page.mdx#page-rou Setting `update` option to true will create or update the HAR file with the actual network information instead of serving the requests from the HAR file. Use it when creating a test to populate the HAR with real data. +#### +Alternatively, you can also record HAR files by using the [record_har_path](/api/class-browser.mdx#browser-new-context-option-record-har-path) option in [browser.new_context()](/api/class-browser.mdx#browser-new-context) when creating a browser context. This allows you to capture all network traffic for the entire context until the context is closed. +