From 5d4834aa317fb7f3ecadbeff67fd3591081e7b24 Mon Sep 17 00:00:00 2001 From: "microsoft-playwright-automation[bot]" <203992400+microsoft-playwright-automation[bot]@users.noreply.github.com> Date: Wed, 13 May 2026 11:00:20 +0000 Subject: [PATCH] feat(roll): roll to ToT Playwright (13-05-26) --- dotnet/docs/release-notes.mdx | 71 ++++++ java/docs/release-notes.mdx | 64 ++++++ nodejs/docs/api/class-electron.mdx | 217 +++++++++--------- nodejs/docs/api/class-electronapplication.mdx | 9 +- nodejs/docs/api/class-testproject.mdx | 3 + nodejs/docs/ci.mdx | 20 +- nodejs/docs/docker.mdx | 18 +- python/docs/release-notes.mdx | 68 ++++++ 8 files changed, 334 insertions(+), 136 deletions(-) diff --git a/dotnet/docs/release-notes.mdx b/dotnet/docs/release-notes.mdx index a06395c519..b04da66bed 100644 --- a/dotnet/docs/release-notes.mdx +++ b/dotnet/docs/release-notes.mdx @@ -9,6 +9,77 @@ import HTMLCard from '@site/src/components/HTMLCard'; import LiteYouTube from '@site/src/components/LiteYouTube'; +## Version 1.60 + +### 🌐 HAR recording on Tracing + +[Tracing.StartHarAsync()](/api/class-tracing.mdx#tracing-start-har) / [Tracing.StopHarAsync()](/api/class-tracing.mdx#tracing-stop-har) expose HAR recording as a first-class tracing API, with the same `Content`, `Mode` and `UrlFilter` options as `RecordHar`: + +```csharp +await context.Tracing.StartHarAsync("trace.har"); +var page = await context.NewPageAsync(); +await page.GotoAsync("https://playwright.dev"); +await context.Tracing.StopHarAsync(); +``` + +### 🪝 Drop API + +New [Locator.DropAsync()](/api/class-locator.mdx#locator-drop) simulates an external drag-and-drop of files or clipboard-like data onto an element. Playwright dispatches `dragenter`, `dragover`, and `drop` with a synthetic [DataTransfer] in the page context — works cross-browser and is great for testing upload zones: + +```csharp +await page.Locator("#dropzone").DropAsync(new() { + Files = new FilePayload() { + Name = "note.txt", + MimeType = "text/plain", + Buffer = Encoding.UTF8.GetBytes("hello"), + }, +}); + +await page.Locator("#dropzone").DropAsync(new() { + Data = new Dictionary { + ["text/plain"] = "hello world", + ["text/uri-list"] = "https://example.com", + }, +}); +``` + +### 🎯 Aria snapshots +- [Expect(Page).ToMatchAriaSnapshotAsync()](/api/class-pageassertions.mdx#page-assertions-to-match-aria-snapshot) now works on a [Page], in addition to a [Locator] — equivalent to asserting against `Page.Locator("body")`. +- New `Boxes` option on [Locator.AriaSnapshotAsync()](/api/class-locator.mdx#locator-aria-snapshot) / [Page.AriaSnapshotAsync()](/api/class-page.mdx#page-aria-snapshot) appends each element's bounding box as `[box=x,y,width,height]`, useful for AI consumption. + +### New APIs + +#### Browser, Context and Page +- Event [Browser.Context](/api/class-browser.mdx#browser-event-context) — fired when a new context is created on the browser. +- [BrowserContext] now mirrors lifecycle events from its pages: [BrowserContext.Download](/api/class-browsercontext.mdx#browser-context-event-download), [BrowserContext.FrameAttached](/api/class-browsercontext.mdx#browser-context-event-frame-attached), [BrowserContext.FrameDetached](/api/class-browsercontext.mdx#browser-context-event-frame-detached), [BrowserContext.FrameNavigated](/api/class-browsercontext.mdx#browser-context-event-frame-navigated), [BrowserContext.PageClose](/api/class-browsercontext.mdx#browser-context-event-page-close), [BrowserContext.PageLoad](/api/class-browsercontext.mdx#browser-context-event-page-load). + +#### Locators and Assertions +- New option `Description` in [Page.GetByRole()](/api/class-page.mdx#page-get-by-role) / [Locator.GetByRole()](/api/class-locator.mdx#locator-get-by-role) / [Frame.GetByRole()](/api/class-frame.mdx#frame-get-by-role) / [FrameLocator.GetByRole()](/api/class-framelocator.mdx#frame-locator-get-by-role) for matching the [accessible description](https://www.w3.org/TR/wai-aria-1.2/#dfn-accessible-description). +- New option `Pseudo` in [Expect(Locator).ToHaveCSSAsync()](/api/class-locatorassertions.mdx#locator-assertions-to-have-css) reads computed styles from `::before` or `::after`. +- New option `Style` in [Locator.HighlightAsync()](/api/class-locator.mdx#locator-highlight) applies extra inline CSS to the highlight overlay, plus new [Page.HideHighlightAsync()](/api/class-page.mdx#page-hide-highlight) to clear all highlights. + +#### Network +- [WebSocketRoute.Protocols](/api/class-websocketroute.mdx#web-socket-route-protocols) returns the WebSocket subprotocols requested by the page. +- New option `NoDefaults` in [BrowserType.ConnectOverCDPAsync()](/api/class-browsertype.mdx#browser-type-connect-over-cdp) disables Playwright's default overrides on the default context (download behavior, focus emulation, media emulation), so attaching to a user's daily-driver browser doesn't disturb its state. + +#### Errors +- New [WebError.Location](/api/class-weberror.mdx#web-error-location) mirrors [ConsoleMessage.Location](/api/class-consolemessage.mdx#console-message-location). + +### 🛠️ Other improvements +- Trace Viewer adds a pretty-print toggle for JSON / form request and response bodies in the network details panel. + +### Breaking Changes ⚠️ +- Removed long-deprecated `Handle` option on `BrowserContext.ExposeBindingAsync` and `Page.ExposeBindingAsync`. + +### Browser Versions +- Chromium 148.0.7778.96 +- Mozilla Firefox 150.0.2 +- WebKit 26.4 + +This version was also tested against the following stable channels: +- Google Chrome 147 +- Microsoft Edge 147 + ## Version 1.59 ### 🎬 Screencast diff --git a/java/docs/release-notes.mdx b/java/docs/release-notes.mdx index 550e017cef..621ecd4c15 100644 --- a/java/docs/release-notes.mdx +++ b/java/docs/release-notes.mdx @@ -9,6 +9,70 @@ import HTMLCard from '@site/src/components/HTMLCard'; import LiteYouTube from '@site/src/components/LiteYouTube'; +## Version 1.60 + +### 🌐 HAR recording on Tracing + +[Tracing.startHar()](/api/class-tracing.mdx#tracing-start-har) / [Tracing.stopHar()](/api/class-tracing.mdx#tracing-stop-har) expose HAR recording as a first-class tracing API, with the same `content`, `mode` and `urlFilter` options as `recordHar`: + +```java +context.tracing().startHar(Paths.get("trace.har")); +Page page = context.newPage(); +page.navigate("https://playwright.dev"); +context.tracing().stopHar(); +``` + +### 🪝 Drop API + +New [Locator.drop()](/api/class-locator.mdx#locator-drop) simulates an external drag-and-drop of files or clipboard-like data onto an element. Playwright dispatches `dragenter`, `dragover`, and `drop` with a synthetic [DataTransfer] in the page context — works cross-browser and is great for testing upload zones: + +```java +page.locator("#dropzone").drop(new Locator.DropPayload() + .setFiles(new FilePayload("note.txt", "text/plain", "hello".getBytes(StandardCharsets.UTF_8)))); + +page.locator("#dropzone").drop(new Locator.DropPayload() + .setData(Map.of( + "text/plain", "hello world", + "text/uri-list", "https://example.com"))); +``` + +### 🎯 Aria snapshots +- [assertThat(page).matchesAriaSnapshot()](/api/class-pageassertions.mdx#page-assertions-to-match-aria-snapshot) now works on a [Page], in addition to a [Locator] — equivalent to asserting against `page.locator("body")`. +- New `boxes` option on [Locator.ariaSnapshot()](/api/class-locator.mdx#locator-aria-snapshot) / [Page.ariaSnapshot()](/api/class-page.mdx#page-aria-snapshot) appends each element's bounding box as `[box=x,y,width,height]`, useful for AI consumption. + +### New APIs + +#### Browser, Context and Page +- Event [Browser.onContext(handler)](/api/class-browser.mdx#browser-event-context) — fired when a new context is created on the browser. +- [BrowserContext] now mirrors lifecycle events from its pages: [BrowserContext.onDownload(handler)](/api/class-browsercontext.mdx#browser-context-event-download), [BrowserContext.onFrameAttached(handler)](/api/class-browsercontext.mdx#browser-context-event-frame-attached), [BrowserContext.onFrameDetached(handler)](/api/class-browsercontext.mdx#browser-context-event-frame-detached), [BrowserContext.onFrameNavigated(handler)](/api/class-browsercontext.mdx#browser-context-event-frame-navigated), [BrowserContext.onPageClose(handler)](/api/class-browsercontext.mdx#browser-context-event-page-close), [BrowserContext.onPageLoad(handler)](/api/class-browsercontext.mdx#browser-context-event-page-load). + +#### Locators and Assertions +- New option `description` in [Page.getByRole()](/api/class-page.mdx#page-get-by-role) / [Locator.getByRole()](/api/class-locator.mdx#locator-get-by-role) / [Frame.getByRole()](/api/class-frame.mdx#frame-get-by-role) / [FrameLocator.getByRole()](/api/class-framelocator.mdx#frame-locator-get-by-role) for matching the [accessible description](https://www.w3.org/TR/wai-aria-1.2/#dfn-accessible-description). +- New option `pseudo` in [assertThat(locator).hasCSS()](/api/class-locatorassertions.mdx#locator-assertions-to-have-css) reads computed styles from `::before` or `::after`. +- New option `style` in [Locator.highlight()](/api/class-locator.mdx#locator-highlight) applies extra inline CSS to the highlight overlay, plus new [Page.hideHighlight()](/api/class-page.mdx#page-hide-highlight) to clear all highlights. + +#### Network +- [WebSocketRoute.protocols()](/api/class-websocketroute.mdx#web-socket-route-protocols) returns the WebSocket subprotocols requested by the page. +- New option `noDefaults` in [BrowserType.connectOverCDP()](/api/class-browsertype.mdx#browser-type-connect-over-cdp) disables Playwright's default overrides on the default context (download behavior, focus emulation, media emulation), so attaching to a user's daily-driver browser doesn't disturb its state. + +#### Errors +- New [WebError.location()](/api/class-weberror.mdx#web-error-location) mirrors [ConsoleMessage.location()](/api/class-consolemessage.mdx#console-message-location). + +### 🛠️ Other improvements +- Trace Viewer adds a pretty-print toggle for JSON / form request and response bodies in the network details panel. + +### Breaking Changes ⚠️ +- Removed long-deprecated `handle` option on `BrowserContext.exposeBinding` and `Page.exposeBinding`. + +### Browser Versions +- Chromium 148.0.7778.96 +- Mozilla Firefox 150.0.2 +- WebKit 26.4 + +This version was also tested against the following stable channels: +- Google Chrome 147 +- Microsoft Edge 147 + ## Version 1.59 ### 🎬 Screencast diff --git a/nodejs/docs/api/class-electron.mdx b/nodejs/docs/api/class-electron.mdx index 0299fd5649..c3dc1f6524 100644 --- a/nodejs/docs/api/class-electron.mdx +++ b/nodejs/docs/api/class-electron.mdx @@ -7,10 +7,16 @@ import TabItem from '@theme/TabItem'; import HTMLCard from '@site/src/components/HTMLCard'; -Playwright has **experimental** support for Electron automation, exposed as `_electron`. An example of the Electron automation script would be: +Playwright has **experimental** support for Electron automation. You can access electron namespace via: ```js -import { _electron as electron } from 'playwright'; +const { _electron } = require('playwright'); +``` + +An example of the Electron automation script would be: + +```js +const { _electron: electron } = require('playwright'); (async () => { // Launch Electron app. @@ -49,113 +55,6 @@ import { _electron as electron } from 'playwright'; If you are not able to launch Electron and it will end up in timeouts during launch, try the following: * Ensure that `nodeCliInspect` ([FuseV1Options.EnableNodeCliInspectArguments](https://www.electronjs.org/docs/latest/tutorial/fuses#nodecliinspect)) fuse is **not** set to `false`. -**Migrating from v1.59** - -A number of launch options have been removed after v1.59. See below for alternatives. -* `recordHar` - use [tracing.startHar()](/api/class-tracing.mdx#tracing-start-har). - - ```js - const electronApp = await electron.launch({ args: ['main.js'] }); - await electronApp.context().tracing.startHar('network.har'); - // ... drive the app ... - await electronApp.context().tracing.stopHar(); - await electronApp.close(); - ``` - -* `recordVideo` - use [screencast.start()](/api/class-screencast.mdx#screencast-start) on each window. - - ```js - const electronApp = await electron.launch({ args: ['main.js'] }); - const window = await electronApp.firstWindow(); - await window.screencast.start({ path: 'video.webm' }); - // ... drive the window ... - await window.screencast.stop(); - await electronApp.close(); - ``` - -* `colorScheme` - use [page.emulateMedia()](/api/class-page.mdx#page-emulate-media) on each window. - - ```js - const window = await electronApp.firstWindow(); - await window.emulateMedia({ colorScheme: 'dark' }); - ``` - -* `extraHTTPHeaders` - use [browserContext.setExtraHTTPHeaders()](/api/class-browsercontext.mdx#browser-context-set-extra-http-headers). - - ```js - await electronApp.context().setExtraHTTPHeaders({ 'X-My-Header': 'value' }); - ``` - -* `geolocation` - use [browserContext.setGeolocation()](/api/class-browsercontext.mdx#browser-context-set-geolocation). - - ```js - await electronApp.context().setGeolocation({ latitude: 48.858455, longitude: 2.294474 }); - ``` - -* `httpCredentials` - use [browserContext.setHTTPCredentials()](/api/class-browsercontext.mdx#browser-context-set-http-credentials). - - ```js - await electronApp.context().setHTTPCredentials({ username: 'user', password: 'pass' }); - ``` - -* `offline` - use [browserContext.setOffline()](/api/class-browsercontext.mdx#browser-context-set-offline). - - ```js - await electronApp.context().setOffline(true); - ``` - -* `bypassCSP` - disable CSP at the `BrowserWindow` level via Electron's [web preferences](https://www.electronjs.org/docs/latest/api/structures/web-preferences). Note that `webSecurity: false` also disables CORS and the Same-Origin Policy. - - ```js - const win = new BrowserWindow({ - webPreferences: { - webSecurity: false, - }, - }); - ``` - -* `ignoreHTTPSErrors` - - There are several ways to relax HTTPS checks in Electron. Pick the one that matches the scope you need. - - Per-window, allow mixed content through [web preferences](https://www.electronjs.org/docs/latest/api/structures/web-preferences): - - ```js - const win = new BrowserWindow({ - webPreferences: { - allowRunningInsecureContent: true, - }, - }); - ``` - - Process-wide, ignore certificate errors via Chromium command-line switches (must run before the `ready` event): - - ```js - const { app } = require('electron'); - app.commandLine.appendSwitch('ignore-certificate-errors'); - // Optional: also ignore localhost certificate errors when testing on an IP. - app.commandLine.appendSwitch('allow-insecure-localhost', 'true'); - ``` - - Per-request, accept the certificate manually via the [`certificate-error`](https://www.electronjs.org/docs/latest/api/app#event-certificate-error) event: - - ```js - app.on('certificate-error', (event, webContents, url, error, certificate, callback) => { - event.preventDefault(); - callback(true); - }); - ``` - -* `timezoneId` - set an environment variable at the very top of the main file, before any other logic or Chromium windows are initialized. - - ```js - // main.js - process.env.TZ = 'Europe/London'; - - const { app } = require('electron'); - // ... rest of your app logic - ``` - --- @@ -176,12 +75,24 @@ await electron.launch(options); **Arguments** - `options` [Object] *(optional)* + - `acceptDownloads` [boolean] *(optional)* Added in: v1.12# + + Whether to automatically download all the attachments. Defaults to `true` where all the downloads are accepted. - `args` [Array]<[string]> *(optional)*# Additional arguments to pass to the application when launching. You typically pass the main script name here. + - `artifactsDir` [string] *(optional)* Added in: v1.59# + + If specified, artifacts (traces, videos, downloads, HAR files, etc.) are saved into this directory. The directory is not cleaned up when the browser closes. If not specified, a temporary directory is used and cleaned up when the browser closes. + - `bypassCSP` [boolean] *(optional)* Added in: v1.12# + + Toggles bypassing page's Content-Security-Policy. Defaults to `false`. - `chromiumSandbox` [boolean] *(optional)* Added in: v1.59# Enable Chromium sandboxing. Defaults to `false`. + - `colorScheme` [null] | "light" | "dark" | "no-preference" *(optional)* Added in: v1.12# + + Emulates [prefers-colors-scheme](https://developer.mozilla.org/en-US/docs/Web/CSS/@media/prefers-color-scheme) media feature, supported values are `'light'` and `'dark'`. See [page.emulateMedia()](/api/class-page.mdx#page-emulate-media) for more details. Passing `null` resets emulation to system defaults. Defaults to `'light'`. - `cwd` [string] *(optional)*# Current working directory to launch application from. @@ -191,9 +102,97 @@ await electron.launch(options); - `executablePath` [string] *(optional)*# Launches given Electron application. If not specified, launches the default Electron executable installed in this package, located at `node_modules/.bin/electron`. + - `extraHTTPHeaders` [Object]<[string], [string]> *(optional)* Added in: v1.12# + + An object containing additional HTTP headers to be sent with every request. Defaults to none. + - `geolocation` [Object] *(optional)* Added in: v1.12# + - `latitude` [number] + + Latitude between -90 and 90. + - `longitude` [number] + + Longitude between -180 and 180. + - `accuracy` [number] *(optional)* + + Non-negative accuracy value. Defaults to `0`. + - `httpCredentials` [Object] *(optional)* Added in: v1.12# + - `username` [string] + + + - `password` [string] + + + - `origin` [string] *(optional)* + + Restrain sending http credentials on specific origin (scheme://host:port). + - `send` "unauthorized" | "always" *(optional)* + + This option only applies to the requests sent from corresponding [APIRequestContext] and does not affect requests sent from the browser. `'always'` - `Authorization` header with basic authentication credentials will be sent with the each API request. `'unauthorized` - the credentials are only sent when 401 (Unauthorized) response with `WWW-Authenticate` header is received. Defaults to `'unauthorized'`. + + Credentials for [HTTP authentication](https://developer.mozilla.org/en-US/docs/Web/HTTP/Authentication). If no origin is specified, the username and password are sent to any servers upon unauthorized responses. + - `ignoreHTTPSErrors` [boolean] *(optional)* Added in: v1.12# + + Whether to ignore HTTPS errors when sending network requests. Defaults to `false`. + - `locale` [string] *(optional)* Added in: v1.12# + + Specify user locale, for example `en-GB`, `de-DE`, etc. Locale will affect `navigator.language` value, `Accept-Language` request header value as well as number and date formatting rules. Defaults to the system default locale. Learn more about emulation in our [emulation guide](../emulation.mdx#locale--timezone). + - `offline` [boolean] *(optional)* Added in: v1.12# + + Whether to emulate network being offline. Defaults to `false`. Learn more about [network emulation](../emulation.mdx#offline). + - `recordHar` [Object] *(optional)* Added in: v1.12# + - `omitContent` [boolean] *(optional)* + + Optional setting to control whether to omit request content from the HAR. Defaults to `false`. Deprecated, use `content` policy instead. + - `content` "omit" | "embed" | "attach" *(optional)* + + Optional setting to control resource content management. If `omit` is specified, content is not persisted. If `attach` is specified, resources are persisted as separate files or entries in the ZIP archive. If `embed` is specified, content is stored inline the HAR file as per HAR specification. Defaults to `attach` for `.zip` output files and to `embed` for all other file extensions. + - `path` [string] + + Path on the filesystem to write the HAR file to. If the file name ends with `.zip`, `content: 'attach'` is used by default. + - `mode` "full" | "minimal" *(optional)* + + When set to `minimal`, only record information necessary for routing from HAR. This omits sizes, timing, page, cookies, security and other types of HAR information that are not used when replaying from HAR. Defaults to `full`. + - `urlFilter` [string] | [RegExp] *(optional)* + + A glob or regex pattern to filter requests that are stored in the HAR. When a [baseURL](/api/class-browser.mdx#browser-new-context-option-base-url) via the context options was provided and the passed URL is a path, it gets merged via the [`new URL()`](https://developer.mozilla.org/en-US/docs/Web/API/URL/URL) constructor. Defaults to none. + + Enables [HAR](http://www.softwareishard.com/blog/har-12-spec) recording for all pages into `recordHar.path` file. If not specified, the HAR is not recorded. Make sure to await [browserContext.close()](/api/class-browsercontext.mdx#browser-context-close) for the HAR to be saved. + - `recordVideo` [Object] *(optional)* Added in: v1.12# + - `dir` [string] *(optional)* + + Path to the directory to put videos into. If not specified, the videos will be stored in `artifactsDir` (see [browserType.launch()](/api/class-browsertype.mdx#browser-type-launch) options). + - `size` [Object] *(optional)* + - `width` [number] + + Video frame width. + - `height` [number] + + Video frame height. + + Optional dimensions of the recorded videos. If not specified the size will be equal to `viewport` scaled down to fit into 800x800. If `viewport` is not configured explicitly the video size defaults to 800x450. Actual picture of each page will be scaled down if necessary to fit the specified size. + - `showActions` [Object] *(optional)* + - `duration` [number] *(optional)* + + How long each annotation is displayed in milliseconds. Defaults to `500`. + - `position` "top-left" | "top" | "top-right" | "bottom-left" | "bottom" | "bottom-right" *(optional)* + + Position of the action title overlay. Defaults to `"top-right"`. + - `fontSize` [number] *(optional)* + + Font size of the action title in pixels. Defaults to `24`. + + If specified, enables visual annotations on interacted elements during video recording. + + Enables video recording for all pages into `recordVideo.dir` directory. If not specified videos are not recorded. Make sure to await [browserContext.close()](/api/class-browsercontext.mdx#browser-context-close) for videos to be saved. - `timeout` [number] *(optional)* Added in: v1.15# Maximum time in milliseconds to wait for the application to start. Defaults to `30000` (30 seconds). Pass `0` to disable timeout. + - `timezoneId` [string] *(optional)* Added in: v1.12# + + Changes the timezone of the context. See [ICU's metaZones.txt](https://cs.chromium.org/chromium/src/third_party/icu/source/data/misc/metaZones.txt?rcl=faee8bc70570192d82d2978a71e2a615788597d1) for a list of supported timezone IDs. Defaults to the system timezone. + - `tracesDir` [string] *(optional)* Added in: v1.36# + + If specified, traces are saved into this directory. **Returns** - [Promise]<[ElectronApplication]># diff --git a/nodejs/docs/api/class-electronapplication.mdx b/nodejs/docs/api/class-electronapplication.mdx index c8857a5cc4..2bc03bc1d7 100644 --- a/nodejs/docs/api/class-electronapplication.mdx +++ b/nodejs/docs/api/class-electronapplication.mdx @@ -10,7 +10,7 @@ import HTMLCard from '@site/src/components/HTMLCard'; Electron application representation. You can use [electron.launch()](/api/class-electron.mdx#electron-launch) to obtain the application instance. This instance you can control main electron process as well as work with Electron windows: ```js -import { _electron as electron } from 'playwright'; +const { _electron: electron } = require('playwright'); (async () => { // Launch Electron app. @@ -76,15 +76,8 @@ Closes Electron application. ```js await electronApplication.close(); -await electronApplication.close(options); ``` -**Arguments** -- `options` [Object] *(optional)* - - `timeout` [number] *(optional)* Added in: v1.60# - - Maximum time in milliseconds to wait for the Electron application to gracefully close before forcefully terminating it. By default, [electronApplication.close()](/api/class-electronapplication.mdx#electron-application-close) waits indefinitely for the application to exit, which can hang if the app has `before-quit` handlers that prevent shutdown, leaky IPC handlers, or child processes that keep it alive. When specified, the underlying process is force-killed (SIGKILL on POSIX, `taskkill /T /F` on Windows) if it does not exit within the given timeout. - **Returns** - [Promise]<[void]># diff --git a/nodejs/docs/api/class-testproject.mdx b/nodejs/docs/api/class-testproject.mdx index 55ef2f6a38..669b3ea646 100644 --- a/nodejs/docs/api/class-testproject.mdx +++ b/nodejs/docs/api/class-testproject.mdx @@ -141,6 +141,9 @@ testProject.expect - `pathTemplate` [string] *(optional)* A template controlling location of the screenshots. See [testProject.snapshotPathTemplate](/api/class-testproject.mdx#test-project-snapshot-path-template) for details. + - `timeout` [number] *(optional)* + + Default timeout for [expect(page).toHaveScreenshot()](/api/class-pageassertions.mdx#page-assertions-to-have-screenshot-1) in milliseconds, defaults to the global expect timeout. Setting to `0` disables the timeout. Configuration for the [expect(page).toHaveScreenshot()](/api/class-pageassertions.mdx#page-assertions-to-have-screenshot-1) method. - `toMatchAriaSnapshot` [Object] *(optional)* diff --git a/nodejs/docs/ci.mdx b/nodejs/docs/ci.mdx index 22c62aef55..edd9da231c 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.59.1-noble + image: mcr.microsoft.com/playwright:v1.60.0-noble options: --user 1001 steps: - uses: actions/checkout@v5 @@ -335,7 +335,7 @@ trigger: pool: vmImage: ubuntu-latest -container: mcr.microsoft.com/playwright:v1.59.1-noble +container: mcr.microsoft.com/playwright:v1.60.0-noble steps: - task: UseNode@1 @@ -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.59.1-noble + - image: mcr.microsoft.com/playwright:v1.60.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.59.1-noble' } } + agent { docker { image 'mcr.microsoft.com/playwright:v1.60.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.59.1-noble +image: mcr.microsoft.com/playwright:v1.60.0-noble ``` ### GitLab CI @@ -412,7 +412,7 @@ stages: tests: stage: test - image: mcr.microsoft.com/playwright:v1.59.1-noble + image: mcr.microsoft.com/playwright:v1.60.0-noble script: ... ``` @@ -427,7 +427,7 @@ stages: tests: stage: test - image: mcr.microsoft.com/playwright:v1.59.1-noble + image: mcr.microsoft.com/playwright:v1.60.0-noble parallel: 7 script: - npm ci @@ -442,7 +442,7 @@ stages: tests: stage: test - image: mcr.microsoft.com/playwright:v1.59.1-noble + image: mcr.microsoft.com/playwright:v1.60.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.59.1-noble +- name: mcr.microsoft.com/playwright:v1.60.0-noble script: ... env: @@ -476,7 +476,7 @@ type: docker steps: - name: test - image: mcr.microsoft.com/playwright:v1.59.1-noble + image: mcr.microsoft.com/playwright:v1.60.0-noble commands: - npx playwright test ``` diff --git a/nodejs/docs/docker.mdx b/nodejs/docs/docker.mdx index 0cc4806c78..ea02d6e978 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.59.1-noble +docker pull mcr.microsoft.com/playwright:v1.60.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.59.1-noble /bin/bash +docker run -it --rm --ipc=host mcr.microsoft.com/playwright:v1.60.0-noble /bin/bash ``` #### Crawling and scraping @@ -42,7 +42,7 @@ docker run -it --rm --ipc=host mcr.microsoft.com/playwright:v1.59.1-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.59.1-noble /bin/bash +docker run -it --rm --ipc=host --user pwuser --security-opt seccomp=seccomp_profile.json mcr.microsoft.com/playwright:v1.60.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.59.1-noble /bin/sh -c "npx -y playwright@1.59.1 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.60.0-noble /bin/sh -c "npx -y playwright@1.60.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.59.1-noble /bin/sh -c "npx -y playwright@1.59.1 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.60.0-noble /bin/sh -c "npx -y playwright@1.60.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. @@ -138,9 +138,9 @@ 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.59.1` - Playwright v1.59.1 release docker image based on Ubuntu 24.04 LTS (Noble Numbat). -- `:v1.59.1-noble` - Playwright v1.59.1 release docker image based on Ubuntu 24.04 LTS (Noble Numbat). -- `:v1.59.1-jammy` - Playwright v1.59.1 release docker image based on Ubuntu 22.04 LTS (Jammy Jellyfish). +- `:v1.60.0` - Playwright v1.60.0 release docker image based on Ubuntu 24.04 LTS (Noble Numbat). +- `:v1.60.0-noble` - Playwright v1.60.0 release docker image based on Ubuntu 24.04 LTS (Noble Numbat). +- `:v1.60.0-jammy` - Playwright v1.60.0 release docker image based on Ubuntu 22.04 LTS (Jammy Jellyfish). :::note @@ -164,7 +164,7 @@ To run Playwright inside Docker, you need to have Node.js, [Playwright browsers] ```Dockerfile FROM node:20-bookworm -RUN npx -y playwright@1.59.1 install --with-deps +RUN npx -y playwright@1.60.0 install --with-deps ``` diff --git a/python/docs/release-notes.mdx b/python/docs/release-notes.mdx index 505a9fc696..653eb492b9 100644 --- a/python/docs/release-notes.mdx +++ b/python/docs/release-notes.mdx @@ -9,6 +9,74 @@ import HTMLCard from '@site/src/components/HTMLCard'; import LiteYouTube from '@site/src/components/LiteYouTube'; +## Version 1.60 + +### 🌐 HAR recording on Tracing + +[tracing.start_har()](/api/class-tracing.mdx#tracing-start-har) / [tracing.stop_har()](/api/class-tracing.mdx#tracing-stop-har) expose HAR recording as a first-class tracing API, with the same `content`, `mode` and `url_filter` options as `record_har`: + +```python +context.tracing.start_har("trace.har") +page = context.new_page() +page.goto("https://playwright.dev") +context.tracing.stop_har() +``` + +### 🪝 Drop API + +New [locator.drop()](/api/class-locator.mdx#locator-drop) simulates an external drag-and-drop of files or clipboard-like data onto an element. Playwright dispatches `dragenter`, `dragover`, and `drop` with a synthetic [DataTransfer] in the page context — works cross-browser and is great for testing upload zones: + +```python +page.locator("#dropzone").drop( + files={"name": "note.txt", "mime_type": "text/plain", "buffer": b"hello"}, +) + +page.locator("#dropzone").drop( + data={ + "text/plain": "hello world", + "text/uri-list": "https://example.com", + }, +) +``` + +### 🎯 Aria snapshots +- [expect(page).to_match_aria_snapshot()](/api/class-pageassertions.mdx#page-assertions-to-match-aria-snapshot) now works on a [Page], in addition to a [Locator] — equivalent to asserting against `page.locator("body")`. +- New `boxes` option on [locator.aria_snapshot()](/api/class-locator.mdx#locator-aria-snapshot) / [page.aria_snapshot()](/api/class-page.mdx#page-aria-snapshot) appends each element's bounding box as `[box=x,y,width,height]`, useful for AI consumption. + +### New APIs + +#### Browser, Context and Page +- Event [browser.on("context")](/api/class-browser.mdx#browser-event-context) — fired when a new context is created on the browser. +- [BrowserContext] now mirrors lifecycle events from its pages: [browser_context.on("download")](/api/class-browsercontext.mdx#browser-context-event-download), [browser_context.on("frameattached")](/api/class-browsercontext.mdx#browser-context-event-frame-attached), [browser_context.on("framedetached")](/api/class-browsercontext.mdx#browser-context-event-frame-detached), [browser_context.on("framenavigated")](/api/class-browsercontext.mdx#browser-context-event-frame-navigated), [browser_context.on("pageclose")](/api/class-browsercontext.mdx#browser-context-event-page-close), [browser_context.on("pageload")](/api/class-browsercontext.mdx#browser-context-event-page-load). + +#### Locators and Assertions +- New option `description` in [page.get_by_role()](/api/class-page.mdx#page-get-by-role) / [locator.get_by_role()](/api/class-locator.mdx#locator-get-by-role) / [frame.get_by_role()](/api/class-frame.mdx#frame-get-by-role) / [frame_locator.get_by_role()](/api/class-framelocator.mdx#frame-locator-get-by-role) for matching the [accessible description](https://www.w3.org/TR/wai-aria-1.2/#dfn-accessible-description). +- New option `pseudo` in [expect(locator).to_have_css()](/api/class-locatorassertions.mdx#locator-assertions-to-have-css) reads computed styles from `::before` or `::after`. +- New option `style` in [locator.highlight()](/api/class-locator.mdx#locator-highlight) applies extra inline CSS to the highlight overlay, plus new [page.hide_highlight()](/api/class-page.mdx#page-hide-highlight) to clear all highlights. + +#### Network +- [web_socket_route.protocols](/api/class-websocketroute.mdx#web-socket-route-protocols) returns the WebSocket subprotocols requested by the page. +- New option `no_defaults` in [browser_type.connect_over_cdp()](/api/class-browsertype.mdx#browser-type-connect-over-cdp) disables Playwright's default overrides on the default context (download behavior, focus emulation, media emulation), so attaching to a user's daily-driver browser doesn't disturb its state. + +#### Errors +- New [web_error.location](/api/class-weberror.mdx#web-error-location) mirrors [console_message.location](/api/class-consolemessage.mdx#console-message-location). +- [console_message.location](/api/class-consolemessage.mdx#console-message-location) now exposes `line` / `column` properties (`line_number` / `column_number` are deprecated). + +### 🛠️ Other improvements +- Trace Viewer adds a pretty-print toggle for JSON / form request and response bodies in the network details panel. + +### Breaking Changes ⚠️ +- Removed long-deprecated `handle` option on `BrowserContext.expose_binding` and `Page.expose_binding`. + +### Browser Versions +- Chromium 148.0.7778.96 +- Mozilla Firefox 150.0.2 +- WebKit 26.4 + +This version was also tested against the following stable channels: +- Google Chrome 147 +- Microsoft Edge 147 + ## Version 1.59 ### 🎬 Screencast