diff --git a/dotnet/docs/api/class-apirequest.mdx b/dotnet/docs/api/class-apirequest.mdx index e5799f96a9..5aa94d0cfd 100644 --- a/dotnet/docs/api/class-apirequest.mdx +++ b/dotnet/docs/api/class-apirequest.mdx @@ -79,7 +79,7 @@ await ApiRequest.NewContextAsync(options); - `FailOnStatusCode` [bool]? *(optional)* Added in: v1.51# Whether to throw on response codes other than 2xx and 3xx. By default response object is returned for all status codes. - - `HttpCredentials` HttpCredentials? *(optional)*# + - `HttpCredentials|HttpCredentialsList` HttpCredentials|HttpCredentialsList? | [IEnumerable]?<HttpCredentials|HttpCredentialsList> *(optional)*# - `Username` [string] @@ -94,6 +94,8 @@ await ApiRequest.NewContextAsync(options); 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. + + Pass an array to use different credentials for different origins. The first entry that matches the request origin is used, and entries with no origin match any request. - `IgnoreHTTPSErrors` [bool]? *(optional)*# Whether to ignore HTTPS errors when sending network requests. Defaults to `false`. diff --git a/dotnet/docs/api/class-browser.mdx b/dotnet/docs/api/class-browser.mdx index 234cd9bd01..0ca1d4a6ff 100644 --- a/dotnet/docs/api/class-browser.mdx +++ b/dotnet/docs/api/class-browser.mdx @@ -276,7 +276,7 @@ await browser.CloseAsync(); - `HasTouch` [bool]? *(optional)*# Specifies if viewport supports touch events. Defaults to false. Learn more about [mobile emulation](../emulation.mdx#devices). - - `HttpCredentials` HttpCredentials? *(optional)*# + - `HttpCredentials|HttpCredentialsList` HttpCredentials|HttpCredentialsList? | [IEnumerable]?<HttpCredentials|HttpCredentialsList> *(optional)*# - `Username` [string] @@ -291,6 +291,8 @@ await browser.CloseAsync(); 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. + + Pass an array to use different credentials for different origins. The first entry that matches the request origin is used, and entries with no origin match any request. - `IgnoreHTTPSErrors` [bool]? *(optional)*# Whether to ignore HTTPS errors when sending network requests. Defaults to `false`. @@ -496,7 +498,7 @@ await Browser.NewPageAsync(options); - `HasTouch` [bool]? *(optional)*# Specifies if viewport supports touch events. Defaults to false. Learn more about [mobile emulation](../emulation.mdx#devices). - - `HttpCredentials` HttpCredentials? *(optional)*# + - `HttpCredentials|HttpCredentialsList` HttpCredentials|HttpCredentialsList? | [IEnumerable]?<HttpCredentials|HttpCredentialsList> *(optional)*# - `Username` [string] @@ -511,6 +513,8 @@ await Browser.NewPageAsync(options); 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. + + Pass an array to use different credentials for different origins. The first entry that matches the request origin is used, and entries with no origin match any request. - `IgnoreHTTPSErrors` [bool]? *(optional)*# Whether to ignore HTTPS errors when sending network requests. Defaults to `false`. diff --git a/dotnet/docs/api/class-browsercontext.mdx b/dotnet/docs/api/class-browsercontext.mdx index d345b026b5..418b52421c 100644 --- a/dotnet/docs/api/class-browsercontext.mdx +++ b/dotnet/docs/api/class-browsercontext.mdx @@ -592,9 +592,6 @@ await BrowserContext.RouteFromHARAsync(har, options); Path to a [HAR](http://www.softwareishard.com/blog/har-12-spec) file with prerecorded network data. If `path` is a relative path, then it is resolved relative to the current working directory. - `options` `BrowserContextRouteFromHAROptions?` *(optional)* - - `InterceptAPIRequests` [bool]? *(optional)* Added in: v1.62# - - If set to `true`, requests made via [APIRequestContext] (such as [BrowserContext.APIRequest](/api/class-browsercontext.mdx#browser-context-request) or [Page.APIRequest](/api/class-page.mdx#page-request)) are also served from the HAR file. By default these requests are sent to the network, matching the behavior prior to v1.62. Defaults to `false` for backward compatibility. - `NotFound` `enum HarNotFound { Abort, Fallback }?` *(optional)*# * If set to 'abort' any request not found in the HAR file will be aborted. * If set to 'fallback' falls through to the next route handler in the handler chain. @@ -1161,6 +1158,23 @@ When no [Page.Dialog](/api/class-page.mdx#page-event-dialog) or [BrowserContext. --- +### event DialogClosed {/* #browser-context-event-dialog-closed */} + +Added in: v1.63browserContext.event DialogClosed + +Emitted when a JavaScript dialog in any page belonging to this context has been closed, either by [Dialog.AcceptAsync()](/api/class-dialog.mdx#dialog-accept), by [Dialog.DismissAsync()](/api/class-dialog.mdx#dialog-dismiss), or manually by the user in the headed browser. + +**Usage** + +```csharp +BrowserContext.DialogClosed += async (_, dialog) => {}; +``` + +**Event data** +- [Dialog] + +--- + ### event Download {/* #browser-context-event-download */} Added in: v1.60browserContext.event Download diff --git a/dotnet/docs/api/class-browsertype.mdx b/dotnet/docs/api/class-browsertype.mdx index 1042c70f38..fd6bbb2de7 100644 --- a/dotnet/docs/api/class-browsertype.mdx +++ b/dotnet/docs/api/class-browsertype.mdx @@ -420,7 +420,7 @@ await BrowserType.LaunchPersistentContextAsync(userDataDir, options); - `Headless` [bool]? *(optional)*# Whether to run browser in headless mode. More details for [Chromium](https://developers.google.com/web/updates/2017/04/headless-chrome) and [Firefox](https://hacks.mozilla.org/2017/12/using-headless-mode-in-firefox/). Defaults to `true`. - - `HttpCredentials` HttpCredentials? *(optional)*# + - `HttpCredentials|HttpCredentialsList` HttpCredentials|HttpCredentialsList? | [IEnumerable]?<HttpCredentials|HttpCredentialsList> *(optional)*# - `Username` [string] @@ -435,6 +435,8 @@ await BrowserType.LaunchPersistentContextAsync(userDataDir, options); 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. + + Pass an array to use different credentials for different origins. The first entry that matches the request origin is used, and entries with no origin match any request. - `IgnoreAllDefaultArgs` [bool]? *(optional)* Added in: v1.9# If `true`, Playwright does not pass its own configurations args and only uses the ones from [Args](/api/class-browsertype.mdx#browser-type-launch-persistent-context-option-args). Dangerous option; use with care. Defaults to `false`. diff --git a/dotnet/docs/api/class-frame.mdx b/dotnet/docs/api/class-frame.mdx index 98d4983459..32c2b5dd2d 100644 --- a/dotnet/docs/api/class-frame.mdx +++ b/dotnet/docs/api/class-frame.mdx @@ -883,6 +883,28 @@ Frame.ParentFrame --- +### PierceFrames {/* #frame-pierce-frames */} + +Added in: v1.63frame.PierceFrames + +When working with iframes, you can create a frame locator that will search for elements in this frame and in all iframes inside it, so that you don't need to locate each iframe first. + +Note that all elements matching the locator must belong to a single frame. For example, if the frame contains two iframes, each with a `Submit` button, piercing frames and locating a button will throw an error because it matches elements from multiple frames. + +**Usage** + +Following snippet locates a button, either in the frame or in one of the iframes inside it: + +```csharp +var locator = frame.PierceFrames.GetByRole(AriaRole.Button); +await locator.ClickAsync(); +``` + +**Returns** +- [FrameLocator]# + +--- + ### SetContentAsync {/* #frame-set-content */} Added before v1.9frame.SetContentAsync diff --git a/dotnet/docs/api/class-page.mdx b/dotnet/docs/api/class-page.mdx index 08e3980e78..72421c21b4 100644 --- a/dotnet/docs/api/class-page.mdx +++ b/dotnet/docs/api/class-page.mdx @@ -1216,7 +1216,7 @@ Navigate to the previous page in history. :::warning -**Testing Back/Forward Cache (BFCache) is not supported.** By default, Playwright disables the Back/Forward Cache across all browsers. Even if explicitly enabled, Playwright's internal state relies on network-level navigation events. Because BFCache restores unfreeze the DOM without firing these events, using `page.goBack()` or `page.goForward()` to trigger a BFCache restore will result in timeouts and a desynchronized `Page` state. +**Testing Back/Forward Cache (BFCache) is not supported.** By default, Playwright disables the Back/Forward Cache across all browsers. Even if explicitly enabled, Playwright's internal state relies on network-level navigation events. Because BFCache restores unfreeze the DOM without firing these events, using `page.goBack()` or `page.goForward()` to trigger a BFCache restore will result in timeouts and a desynchronized `Page` state. ::: **Usage** @@ -1253,7 +1253,7 @@ Navigate to the next page in history. :::warning -**Testing Back/Forward Cache (BFCache) is not supported.** By default, Playwright disables the Back/Forward Cache across all browsers. Even if explicitly enabled, Playwright's internal state relies on network-level navigation events. Because BFCache restores unfreeze the DOM without firing these events, using `page.goBack()` or `page.goForward()` to trigger a BFCache restore will result in timeouts and a desynchronized `Page` state. +**Testing Back/Forward Cache (BFCache) is not supported.** By default, Playwright disables the Back/Forward Cache across all browsers. Even if explicitly enabled, Playwright's internal state relies on network-level navigation events. Because BFCache restores unfreeze the DOM without firing these events, using `page.goBack()` or `page.goForward()` to trigger a BFCache restore will result in timeouts and a desynchronized `Page` state. ::: **Usage** @@ -1626,6 +1626,28 @@ Console.WriteLine(locator); --- +### PierceFrames {/* #page-pierce-frames */} + +Added in: v1.63page.PierceFrames + +When working with iframes, you can create a frame locator that will search for elements in the main frame and in all iframes on the page, so that you don't need to locate each iframe first. + +Note that all elements matching the locator must belong to a single frame. For example, if the page contains two iframes, each with a `Submit` button, piercing frames and locating a button will throw an error because it matches elements from multiple frames. + +**Usage** + +Following snippet locates a button, either in the main frame or in one of the iframes: + +```csharp +var locator = page.PierceFrames.GetByRole(AriaRole.Button); +await locator.ClickAsync(); +``` + +**Returns** +- [FrameLocator]# + +--- + ### ReloadAsync {/* #page-reload */} Added before v1.9page.ReloadAsync @@ -3142,6 +3164,23 @@ When no [Page.Dialog](/api/class-page.mdx#page-event-dialog) or [BrowserContext. --- +### event DialogClosed {/* #page-event-dialog-closed */} + +Added in: v1.63page.event DialogClosed + +Emitted when a JavaScript dialog has been closed, either by [Dialog.AcceptAsync()](/api/class-dialog.mdx#dialog-accept), by [Dialog.DismissAsync()](/api/class-dialog.mdx#dialog-dismiss), or manually by the user in the headed browser. + +**Usage** + +```csharp +Page.DialogClosed += async (_, dialog) => {}; +``` + +**Event data** +- [Dialog] + +--- + ### event DOMContentLoaded {/* #page-event-dom-content-loaded */} Added in: v1.9page.event DOMContentLoaded diff --git a/java/docs/api/class-apirequest.mdx b/java/docs/api/class-apirequest.mdx index 8d77f6e95f..0adf284652 100644 --- a/java/docs/api/class-apirequest.mdx +++ b/java/docs/api/class-apirequest.mdx @@ -80,7 +80,7 @@ APIRequest.newContext(options); - `setFailOnStatusCode` [boolean] *(optional)* Added in: v1.51# Whether to throw on response codes other than 2xx and 3xx. By default response object is returned for all status codes. - - `setHttpCredentials` HttpCredentials *(optional)*# + - `setHttpCredentials` HttpCredentials | [List]<HttpCredentials> *(optional)*# - `setUsername` [String] @@ -95,6 +95,8 @@ APIRequest.newContext(options); 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. + + Pass an array to use different credentials for different origins. The first entry that matches the request origin is used, and entries with no origin match any request. - `setIgnoreHTTPSErrors` [boolean] *(optional)*# Whether to ignore HTTPS errors when sending network requests. Defaults to `false`. diff --git a/java/docs/api/class-browser.mdx b/java/docs/api/class-browser.mdx index 567de7bf20..416f0a4c84 100644 --- a/java/docs/api/class-browser.mdx +++ b/java/docs/api/class-browser.mdx @@ -281,7 +281,7 @@ browser.close(); - `setHasTouch` [boolean] *(optional)*# Specifies if viewport supports touch events. Defaults to false. Learn more about [mobile emulation](../emulation.mdx#devices). - - `setHttpCredentials` HttpCredentials *(optional)*# + - `setHttpCredentials` HttpCredentials | [List]<HttpCredentials> *(optional)*# - `setUsername` [String] @@ -296,6 +296,8 @@ browser.close(); 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. + + Pass an array to use different credentials for different origins. The first entry that matches the request origin is used, and entries with no origin match any request. - `setIgnoreHTTPSErrors` [boolean] *(optional)*# Whether to ignore HTTPS errors when sending network requests. Defaults to `false`. @@ -502,7 +504,7 @@ Browser.newPage(options); - `setHasTouch` [boolean] *(optional)*# Specifies if viewport supports touch events. Defaults to false. Learn more about [mobile emulation](../emulation.mdx#devices). - - `setHttpCredentials` HttpCredentials *(optional)*# + - `setHttpCredentials` HttpCredentials | [List]<HttpCredentials> *(optional)*# - `setUsername` [String] @@ -517,6 +519,8 @@ Browser.newPage(options); 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. + + Pass an array to use different credentials for different origins. The first entry that matches the request origin is used, and entries with no origin match any request. - `setIgnoreHTTPSErrors` [boolean] *(optional)*# Whether to ignore HTTPS errors when sending network requests. Defaults to `false`. diff --git a/java/docs/api/class-browsercontext.mdx b/java/docs/api/class-browsercontext.mdx index 434ffb0cdc..e5c8cffc5e 100644 --- a/java/docs/api/class-browsercontext.mdx +++ b/java/docs/api/class-browsercontext.mdx @@ -603,9 +603,6 @@ BrowserContext.routeFromHAR(har, options); Path to a [HAR](http://www.softwareishard.com/blog/har-12-spec) file with prerecorded network data. If `path` is a relative path, then it is resolved relative to the current working directory. - `options` `BrowserContext.RouteFromHAROptions` *(optional)* - - `setInterceptAPIRequests` [boolean] *(optional)* Added in: v1.62# - - If set to `true`, requests made via [APIRequestContext] (such as [BrowserContext.request()](/api/class-browsercontext.mdx#browser-context-request) or [Page.request()](/api/class-page.mdx#page-request)) are also served from the HAR file. By default these requests are sent to the network, matching the behavior prior to v1.62. Defaults to `false` for backward compatibility. - `setNotFound` `enum HarNotFound { ABORT, FALLBACK }` *(optional)*# * If set to 'abort' any request not found in the HAR file will be aborted. * If set to 'fallback' falls through to the next route handler in the handler chain. @@ -1144,6 +1141,23 @@ When no [Page.onDialog(handler)](/api/class-page.mdx#page-event-dialog) or [Brow --- +### onDialogClosed(handler) {/* #browser-context-event-dialog-closed */} + +Added in: v1.63browserContext.onDialogClosed(handler) + +Emitted when a JavaScript dialog in any page belonging to this context has been closed, either by [Dialog.accept()](/api/class-dialog.mdx#dialog-accept), by [Dialog.dismiss()](/api/class-dialog.mdx#dialog-dismiss), or manually by the user in the headed browser. + +**Usage** + +```java +BrowserContext.onDialogClosed(handler) +``` + +**Event data** +- [Dialog] + +--- + ### onDownload(handler) {/* #browser-context-event-download */} Added in: v1.60browserContext.onDownload(handler) diff --git a/java/docs/api/class-browsertype.mdx b/java/docs/api/class-browsertype.mdx index aa19f174d7..40ae0a2e0b 100644 --- a/java/docs/api/class-browsertype.mdx +++ b/java/docs/api/class-browsertype.mdx @@ -420,7 +420,7 @@ BrowserType.launchPersistentContext(userDataDir, options); - `setHeadless` [boolean] *(optional)*# Whether to run browser in headless mode. More details for [Chromium](https://developers.google.com/web/updates/2017/04/headless-chrome) and [Firefox](https://hacks.mozilla.org/2017/12/using-headless-mode-in-firefox/). Defaults to `true`. - - `setHttpCredentials` HttpCredentials *(optional)*# + - `setHttpCredentials` HttpCredentials | [List]<HttpCredentials> *(optional)*# - `setUsername` [String] @@ -435,6 +435,8 @@ BrowserType.launchPersistentContext(userDataDir, options); 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. + + Pass an array to use different credentials for different origins. The first entry that matches the request origin is used, and entries with no origin match any request. - `setIgnoreAllDefaultArgs` [boolean] *(optional)* Added in: v1.9# If `true`, Playwright does not pass its own configurations args and only uses the ones from [setArgs](/api/class-browsertype.mdx#browser-type-launch-persistent-context-option-args). Dangerous option; use with care. Defaults to `false`. diff --git a/java/docs/api/class-frame.mdx b/java/docs/api/class-frame.mdx index 0479468040..fb4d70d837 100644 --- a/java/docs/api/class-frame.mdx +++ b/java/docs/api/class-frame.mdx @@ -886,6 +886,28 @@ Frame.parentFrame(); --- +### pierceFrames {/* #frame-pierce-frames */} + +Added in: v1.63frame.pierceFrames + +When working with iframes, you can create a frame locator that will search for elements in this frame and in all iframes inside it, so that you don't need to locate each iframe first. + +Note that all elements matching the locator must belong to a single frame. For example, if the frame contains two iframes, each with a `Submit` button, piercing frames and locating a button will throw an error because it matches elements from multiple frames. + +**Usage** + +Following snippet locates a button, either in the frame or in one of the iframes inside it: + +```java +Locator locator = frame.pierceFrames().getByRole(AriaRole.BUTTON); +locator.click(); +``` + +**Returns** +- [FrameLocator]# + +--- + ### setContent {/* #frame-set-content */} Added before v1.9frame.setContent diff --git a/java/docs/api/class-page.mdx b/java/docs/api/class-page.mdx index d1ad77c016..74c15fa5ac 100644 --- a/java/docs/api/class-page.mdx +++ b/java/docs/api/class-page.mdx @@ -1220,7 +1220,7 @@ Navigate to the previous page in history. :::warning -**Testing Back/Forward Cache (BFCache) is not supported.** By default, Playwright disables the Back/Forward Cache across all browsers. Even if explicitly enabled, Playwright's internal state relies on network-level navigation events. Because BFCache restores unfreeze the DOM without firing these events, using `page.goBack()` or `page.goForward()` to trigger a BFCache restore will result in timeouts and a desynchronized `Page` state. +**Testing Back/Forward Cache (BFCache) is not supported.** By default, Playwright disables the Back/Forward Cache across all browsers. Even if explicitly enabled, Playwright's internal state relies on network-level navigation events. Because BFCache restores unfreeze the DOM without firing these events, using `page.goBack()` or `page.goForward()` to trigger a BFCache restore will result in timeouts and a desynchronized `Page` state. ::: **Usage** @@ -1258,7 +1258,7 @@ Navigate to the next page in history. :::warning -**Testing Back/Forward Cache (BFCache) is not supported.** By default, Playwright disables the Back/Forward Cache across all browsers. Even if explicitly enabled, Playwright's internal state relies on network-level navigation events. Because BFCache restores unfreeze the DOM without firing these events, using `page.goBack()` or `page.goForward()` to trigger a BFCache restore will result in timeouts and a desynchronized `Page` state. +**Testing Back/Forward Cache (BFCache) is not supported.** By default, Playwright disables the Back/Forward Cache across all browsers. Even if explicitly enabled, Playwright's internal state relies on network-level navigation events. Because BFCache restores unfreeze the DOM without firing these events, using `page.goBack()` or `page.goForward()` to trigger a BFCache restore will result in timeouts and a desynchronized `Page` state. ::: **Usage** @@ -1684,6 +1684,28 @@ System.out.println(locator); --- +### pierceFrames {/* #page-pierce-frames */} + +Added in: v1.63page.pierceFrames + +When working with iframes, you can create a frame locator that will search for elements in the main frame and in all iframes on the page, so that you don't need to locate each iframe first. + +Note that all elements matching the locator must belong to a single frame. For example, if the page contains two iframes, each with a `Submit` button, piercing frames and locating a button will throw an error because it matches elements from multiple frames. + +**Usage** + +Following snippet locates a button, either in the main frame or in one of the iframes: + +```java +Locator locator = page.pierceFrames().getByRole(AriaRole.BUTTON); +locator.click(); +``` + +**Returns** +- [FrameLocator]# + +--- + ### reload {/* #page-reload */} Added before v1.9page.reload @@ -3004,6 +3026,23 @@ When no [Page.onDialog(handler)](/api/class-page.mdx#page-event-dialog) or [Brow --- +### onDialogClosed(handler) {/* #page-event-dialog-closed */} + +Added in: v1.63page.onDialogClosed(handler) + +Emitted when a JavaScript dialog has been closed, either by [Dialog.accept()](/api/class-dialog.mdx#dialog-accept), by [Dialog.dismiss()](/api/class-dialog.mdx#dialog-dismiss), or manually by the user in the headed browser. + +**Usage** + +```java +Page.onDialogClosed(handler) +``` + +**Event data** +- [Dialog] + +--- + ### onDOMContentLoaded(handler) {/* #page-event-dom-content-loaded */} Added in: v1.9page.onDOMContentLoaded(handler) diff --git a/nodejs/docs/api/class-androiddevice.mdx b/nodejs/docs/api/class-androiddevice.mdx index 0a062e0be7..bb7f8adc5e 100644 --- a/nodejs/docs/api/class-androiddevice.mdx +++ b/nodejs/docs/api/class-androiddevice.mdx @@ -244,7 +244,7 @@ await androidDevice.launchBrowser(options); - `hasTouch` [boolean] *(optional)*# Specifies if viewport supports touch events. Defaults to false. Learn more about [mobile emulation](../emulation.mdx#devices). - - `httpCredentials` [Object] *(optional)*# + - `httpCredentials` [Object] | [Array]<[Object]> *(optional)*# - `username` [string] @@ -259,6 +259,8 @@ await androidDevice.launchBrowser(options); 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. + + Pass an array to use different credentials for different origins. The first entry that matches the request origin is used, and entries with no origin match any request. - `ignoreHTTPSErrors` [boolean] *(optional)*# Whether to ignore HTTPS errors when sending network requests. Defaults to `false`. diff --git a/nodejs/docs/api/class-apirequest.mdx b/nodejs/docs/api/class-apirequest.mdx index 79f824a0b8..c56362531a 100644 --- a/nodejs/docs/api/class-apirequest.mdx +++ b/nodejs/docs/api/class-apirequest.mdx @@ -80,7 +80,7 @@ await apiRequest.newContext(options); - `failOnStatusCode` [boolean] *(optional)* Added in: v1.51# Whether to throw on response codes other than 2xx and 3xx. By default response object is returned for all status codes. - - `httpCredentials` [Object] *(optional)*# + - `httpCredentials` [Object] | [Array]<[Object]> *(optional)*# - `username` [string] @@ -95,6 +95,8 @@ await apiRequest.newContext(options); 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. + + Pass an array to use different credentials for different origins. The first entry that matches the request origin is used, and entries with no origin match any request. - `ignoreHTTPSErrors` [boolean] *(optional)*# Whether to ignore HTTPS errors when sending network requests. Defaults to `false`. diff --git a/nodejs/docs/api/class-browser.mdx b/nodejs/docs/api/class-browser.mdx index fec045f621..686ff72371 100644 --- a/nodejs/docs/api/class-browser.mdx +++ b/nodejs/docs/api/class-browser.mdx @@ -282,7 +282,7 @@ If directly using this method to create [BrowserContext]s, it is best practice t - `hasTouch` [boolean] *(optional)*# Specifies if viewport supports touch events. Defaults to false. Learn more about [mobile emulation](../emulation.mdx#devices). - - `httpCredentials` [Object] *(optional)*# + - `httpCredentials` [Object] | [Array]<[Object]> *(optional)*# - `username` [string] @@ -297,6 +297,8 @@ If directly using this method to create [BrowserContext]s, it is best practice t 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. + + Pass an array to use different credentials for different origins. The first entry that matches the request origin is used, and entries with no origin match any request. - `ignoreHTTPSErrors` [boolean] *(optional)*# Whether to ignore HTTPS errors when sending network requests. Defaults to `false`. @@ -573,7 +575,7 @@ await browser.newPage(options); - `hasTouch` [boolean] *(optional)*# Specifies if viewport supports touch events. Defaults to false. Learn more about [mobile emulation](../emulation.mdx#devices). - - `httpCredentials` [Object] *(optional)*# + - `httpCredentials` [Object] | [Array]<[Object]> *(optional)*# - `username` [string] @@ -588,6 +590,8 @@ await browser.newPage(options); 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. + + Pass an array to use different credentials for different origins. The first entry that matches the request origin is used, and entries with no origin match any request. - `ignoreHTTPSErrors` [boolean] *(optional)*# Whether to ignore HTTPS errors when sending network requests. Defaults to `false`. diff --git a/nodejs/docs/api/class-browsercontext.mdx b/nodejs/docs/api/class-browsercontext.mdx index b3c6646892..ff18e106ff 100644 --- a/nodejs/docs/api/class-browsercontext.mdx +++ b/nodejs/docs/api/class-browsercontext.mdx @@ -627,9 +627,6 @@ await browserContext.routeFromHAR(har, options); Path to a [HAR](http://www.softwareishard.com/blog/har-12-spec) file with prerecorded network data. If `path` is a relative path, then it is resolved relative to the current working directory. - `options` [Object] *(optional)* - - `interceptAPIRequests` [boolean] *(optional)* Added in: v1.62# - - If set to `true`, requests made via [APIRequestContext] (such as [browserContext.request](/api/class-browsercontext.mdx#browser-context-request) or [page.request](/api/class-page.mdx#page-request)) are also served from the HAR file. By default these requests are sent to the network, matching the behavior prior to v1.62. Defaults to `false` for backward compatibility. - `notFound` "abort" | "fallback" *(optional)*# * If set to 'abort' any request not found in the HAR file will be aborted. * If set to 'fallback' falls through to the next route handler in the handler chain. @@ -1226,6 +1223,23 @@ When no [page.on('dialog')](/api/class-page.mdx#page-event-dialog) or [browserCo --- +### on('dialogclosed') {/* #browser-context-event-dialog-closed */} + +Added in: v1.63browserContext.on('dialogclosed') + +Emitted when a JavaScript dialog in any page belonging to this context has been closed, either by [dialog.accept()](/api/class-dialog.mdx#dialog-accept), by [dialog.dismiss()](/api/class-dialog.mdx#dialog-dismiss), or manually by the user in the headed browser. + +**Usage** + +```js +browserContext.on('dialogclosed', data => {}); +``` + +**Event data** +- [Dialog] + +--- + ### on('download') {/* #browser-context-event-download */} Added in: v1.60browserContext.on('download') @@ -1540,13 +1554,19 @@ await browserContext.setHTTPCredentials(httpCredentials); ``` **Arguments** -- `httpCredentials` [null] | [Object]# +- `httpCredentials` [null] | [Object] | [Array]<[Object]># - `username` [string] - `password` [string] + - `origin` [string] *(optional)* + + Restrain sending http credentials on specific origin (scheme://host:port). + + Pass an array to use different credentials for different origins. The first entry that matches the request origin is used, and entries with no origin match any request. + **Returns** - [Promise]<[void]># diff --git a/nodejs/docs/api/class-browsertype.mdx b/nodejs/docs/api/class-browsertype.mdx index ec53f95c99..5e0ff64663 100644 --- a/nodejs/docs/api/class-browsertype.mdx +++ b/nodejs/docs/api/class-browsertype.mdx @@ -422,7 +422,7 @@ await browserType.launchPersistentContext(userDataDir, options); - `headless` [boolean] *(optional)*# Whether to run browser in headless mode. More details for [Chromium](https://developers.google.com/web/updates/2017/04/headless-chrome) and [Firefox](https://hacks.mozilla.org/2017/12/using-headless-mode-in-firefox/). Defaults to `true`. - - `httpCredentials` [Object] *(optional)*# + - `httpCredentials` [Object] | [Array]<[Object]> *(optional)*# - `username` [string] @@ -437,6 +437,8 @@ await browserType.launchPersistentContext(userDataDir, options); 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. + + Pass an array to use different credentials for different origins. The first entry that matches the request origin is used, and entries with no origin match any request. - `ignoreDefaultArgs` [boolean] | [Array]<[string]> *(optional)*# If `true`, Playwright does not pass its own configurations args and only uses the ones from [args](/api/class-browsertype.mdx#browser-type-launch-persistent-context-option-args). If an array is given, then filters out the given default arguments. Dangerous option; use with care. Defaults to `false`. diff --git a/nodejs/docs/api/class-electron.mdx b/nodejs/docs/api/class-electron.mdx index 6dcb32e52b..1ef6fad819 100644 --- a/nodejs/docs/api/class-electron.mdx +++ b/nodejs/docs/api/class-electron.mdx @@ -138,7 +138,7 @@ await electron.launch(options); - `accuracy` [number] *(optional)* Non-negative accuracy value. Defaults to `0`. - - `httpCredentials` [Object] *(optional)* Added in: v1.12# + - `httpCredentials` [Object] | [Array]<[Object]> *(optional)* Added in: v1.12# - `username` [string] @@ -153,6 +153,8 @@ await electron.launch(options); 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. + + Pass an array to use different credentials for different origins. The first entry that matches the request origin is used, and entries with no origin match any request. - `ignoreHTTPSErrors` [boolean] *(optional)* Added in: v1.12# Whether to ignore HTTPS errors when sending network requests. Defaults to `false`. diff --git a/nodejs/docs/api/class-frame.mdx b/nodejs/docs/api/class-frame.mdx index 7484809317..e120a0ba6e 100644 --- a/nodejs/docs/api/class-frame.mdx +++ b/nodejs/docs/api/class-frame.mdx @@ -907,6 +907,28 @@ frame.parentFrame(); --- +### pierceFrames {/* #frame-pierce-frames */} + +Added in: v1.63frame.pierceFrames + +When working with iframes, you can create a frame locator that will search for elements in this frame and in all iframes inside it, so that you don't need to locate each iframe first. + +Note that all elements matching the locator must belong to a single frame. For example, if the frame contains two iframes, each with a `Submit` button, piercing frames and locating a button will throw an error because it matches elements from multiple frames. + +**Usage** + +Following snippet locates a button, either in the frame or in one of the iframes inside it: + +```js +const locator = frame.pierceFrames().getByRole('button'); +await locator.click(); +``` + +**Returns** +- [FrameLocator]# + +--- + ### setContent {/* #frame-set-content */} Added before v1.9frame.setContent diff --git a/nodejs/docs/api/class-page.mdx b/nodejs/docs/api/class-page.mdx index 9cff3523d8..113d8bcb1e 100644 --- a/nodejs/docs/api/class-page.mdx +++ b/nodejs/docs/api/class-page.mdx @@ -1224,7 +1224,7 @@ Navigate to the previous page in history. :::warning -**Testing Back/Forward Cache (BFCache) is not supported.** By default, Playwright disables the Back/Forward Cache across all browsers. Even if explicitly enabled, Playwright's internal state relies on network-level navigation events. Because BFCache restores unfreeze the DOM without firing these events, using `page.goBack()` or `page.goForward()` to trigger a BFCache restore will result in timeouts and a desynchronized `Page` state. +**Testing Back/Forward Cache (BFCache) is not supported.** By default, Playwright disables the Back/Forward Cache across all browsers. Even if explicitly enabled, Playwright's internal state relies on network-level navigation events. Because BFCache restores unfreeze the DOM without firing these events, using `page.goBack()` or `page.goForward()` to trigger a BFCache restore will result in timeouts and a desynchronized `Page` state. ::: **Usage** @@ -1265,7 +1265,7 @@ Navigate to the next page in history. :::warning -**Testing Back/Forward Cache (BFCache) is not supported.** By default, Playwright disables the Back/Forward Cache across all browsers. Even if explicitly enabled, Playwright's internal state relies on network-level navigation events. Because BFCache restores unfreeze the DOM without firing these events, using `page.goBack()` or `page.goForward()` to trigger a BFCache restore will result in timeouts and a desynchronized `Page` state. +**Testing Back/Forward Cache (BFCache) is not supported.** By default, Playwright disables the Back/Forward Cache across all browsers. Even if explicitly enabled, Playwright's internal state relies on network-level navigation events. Because BFCache restores unfreeze the DOM without firing these events, using `page.goBack()` or `page.goForward()` to trigger a BFCache restore will result in timeouts and a desynchronized `Page` state. ::: **Usage** @@ -1654,6 +1654,28 @@ console.log(locator); --- +### pierceFrames {/* #page-pierce-frames */} + +Added in: v1.63page.pierceFrames + +When working with iframes, you can create a frame locator that will search for elements in the main frame and in all iframes on the page, so that you don't need to locate each iframe first. + +Note that all elements matching the locator must belong to a single frame. For example, if the page contains two iframes, each with a `Submit` button, piercing frames and locating a button will throw an error because it matches elements from multiple frames. + +**Usage** + +Following snippet locates a button, either in the main frame or in one of the iframes: + +```js +const locator = page.pierceFrames().getByRole('button'); +await locator.click(); +``` + +**Returns** +- [FrameLocator]# + +--- + ### reload {/* #page-reload */} Added before v1.9page.reload @@ -2850,6 +2872,23 @@ When no [page.on('dialog')](/api/class-page.mdx#page-event-dialog) or [browserCo --- +### on('dialogclosed') {/* #page-event-dialog-closed */} + +Added in: v1.63page.on('dialogclosed') + +Emitted when a JavaScript dialog has been closed, either by [dialog.accept()](/api/class-dialog.mdx#dialog-accept), by [dialog.dismiss()](/api/class-dialog.mdx#dialog-dismiss), or manually by the user in the headed browser. + +**Usage** + +```js +page.on('dialogclosed', data => {}); +``` + +**Event data** +- [Dialog] + +--- + ### on('domcontentloaded') {/* #page-event-dom-content-loaded */} Added in: v1.9page.on('domcontentloaded') diff --git a/nodejs/docs/api/class-test.mdx b/nodejs/docs/api/class-test.mdx index da9ffa1bdd..2855b06f0b 100644 --- a/nodejs/docs/api/class-test.mdx +++ b/nodejs/docs/api/class-test.mdx @@ -95,6 +95,23 @@ You can also add annotations during runtime by manipulating [testInfo.annotation Learn more about [test annotations](../test-annotations.mdx). +**Locks** + +You can declare named locks to prevent specific tests from running at the same time, while all other tests continue to run in parallel. Tests that share a lock name never run concurrently, even when they are declared in different files or belong to different [projects](../test-projects.mdx). This is useful when a few tests access a shared resource that does not support concurrent access. + +```js +import { test, expect } from '@playwright/test'; + +test('update user settings', { + lock: 'user-settings', +}, async ({ page }) => { + // This test never runs concurrently with other tests + // that declare the 'user-settings' lock. +}); +``` + +Learn more about [test locks](../test-parallel.mdx#test-locks). + **Arguments** - `title` [string]# @@ -112,6 +129,9 @@ Learn more about [test annotations](../test-annotations.mdx). Optional annotation description, for example an issue url. + - `lock` [string] | [Array]<[string]> *(optional)* + + Additional test details. - `body` [function]\([Fixtures], [TestInfo]\)# @@ -446,6 +466,26 @@ test.describe('two annotated tests', { Learn more about [test annotations](../test-annotations.mdx). +**Locks** + +You can declare named locks for all tests in a group by providing additional details. Tests that share a lock name never run concurrently. Learn more about [test locks](../test-parallel.mdx#test-locks). + +```js +import { test, expect } from '@playwright/test'; + +test.describe('two tests with a lock', { + lock: 'user-settings', +}, () => { + test('one', async ({ page }) => { + // ... + }); + + test('two', async ({ page }) => { + // ... + }); +}); +``` + **Arguments** - `title` [string] *(optional)*# @@ -462,6 +502,9 @@ Learn more about [test annotations](../test-annotations.mdx). + - `lock` [string] | [Array]<[string]> *(optional)* + + Additional details for all tests in the group. - `callback` [function]# diff --git a/nodejs/docs/api/class-testoptions.mdx b/nodejs/docs/api/class-testoptions.mdx index 61917bfb7b..9089fd048f 100644 --- a/nodejs/docs/api/class-testoptions.mdx +++ b/nodejs/docs/api/class-testoptions.mdx @@ -479,6 +479,8 @@ export default defineConfig({ 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. +Pass an array to use different credentials for different origins. The first entry that matches the request origin is used, and entries with no origin match any request. + **Usage** ```js title="playwright.config.ts" @@ -495,7 +497,7 @@ export default defineConfig({ ``` **Type** -- [Object] +- [Object] | [Array]<[Object]> - `username` [string] diff --git a/nodejs/docs/ci.mdx b/nodejs/docs/ci.mdx index c817cd0f6a..573c54c37a 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.61.1-noble + image: mcr.microsoft.com/playwright:v1.62.0-noble options: --user 1001 steps: - uses: actions/checkout@v6 @@ -335,7 +335,7 @@ trigger: pool: vmImage: ubuntu-latest -container: mcr.microsoft.com/playwright:v1.61.1-noble +container: mcr.microsoft.com/playwright:v1.62.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.61.1-noble + - image: mcr.microsoft.com/playwright:v1.62.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.61.1-noble' } } + agent { docker { image 'mcr.microsoft.com/playwright:v1.62.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.61.1-noble +image: mcr.microsoft.com/playwright:v1.62.0-noble ``` ### GitLab CI @@ -412,7 +412,7 @@ stages: tests: stage: test - image: mcr.microsoft.com/playwright:v1.61.1-noble + image: mcr.microsoft.com/playwright:v1.62.0-noble script: ... ``` @@ -427,7 +427,7 @@ stages: tests: stage: test - image: mcr.microsoft.com/playwright:v1.61.1-noble + image: mcr.microsoft.com/playwright:v1.62.0-noble parallel: 7 script: - npm ci @@ -442,7 +442,7 @@ stages: tests: stage: test - image: mcr.microsoft.com/playwright:v1.61.1-noble + image: mcr.microsoft.com/playwright:v1.62.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.61.1-noble +- name: mcr.microsoft.com/playwright:v1.62.0-noble script: ... env: @@ -476,7 +476,7 @@ type: docker steps: - name: test - image: mcr.microsoft.com/playwright:v1.61.1-noble + image: mcr.microsoft.com/playwright:v1.62.0-noble commands: - npx playwright test ``` diff --git a/nodejs/docs/docker.mdx b/nodejs/docs/docker.mdx index fd94502a20..6cc87bb18b 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.61.1-noble +docker pull mcr.microsoft.com/playwright:v1.62.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.61.1-noble /bin/bash +docker run -it --rm --ipc=host mcr.microsoft.com/playwright:v1.62.0-noble /bin/bash ``` #### Crawling and scraping @@ -42,7 +42,7 @@ docker run -it --rm --ipc=host mcr.microsoft.com/playwright:v1.61.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.61.1-noble /bin/bash +docker run -it --rm --ipc=host --user pwuser --security-opt seccomp=seccomp_profile.json mcr.microsoft.com/playwright:v1.62.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.61.1-noble /bin/sh -c "npx -y playwright@1.61.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.62.0-noble /bin/sh -c "npx -y playwright@1.62.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.61.1-noble /bin/sh -c "npx -y playwright@1.61.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.62.0-noble /bin/sh -c "npx -y playwright@1.62.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,10 +138,10 @@ Once this is enabled you can open the port specified in a new browser tab and yo See [all available image tags]. We currently publish images with the following tags: -- `:v1.61.1` - Playwright v1.61.1 release docker image based on Ubuntu 24.04 LTS (Noble Numbat). -- `:v1.61.1-noble` - Playwright v1.61.1 release docker image based on Ubuntu 24.04 LTS (Noble Numbat). -- `:v1.61.1-jammy` - Playwright v1.61.1 release docker image based on Ubuntu 22.04 LTS (Jammy Jellyfish). -- `:v1.61.1-resolute` - Playwright v1.61.1 release docker image based on Ubuntu 26.04 LTS (Resolute Raccoon). +- `:v1.62.0` - Playwright v1.62.0 release docker image based on Ubuntu 24.04 LTS (Noble Numbat). +- `:v1.62.0-noble` - Playwright v1.62.0 release docker image based on Ubuntu 24.04 LTS (Noble Numbat). +- `:v1.62.0-jammy` - Playwright v1.62.0 release docker image based on Ubuntu 22.04 LTS (Jammy Jellyfish). +- `:v1.62.0-resolute` - Playwright v1.62.0 release docker image based on Ubuntu 26.04 LTS (Resolute Raccoon). :::note @@ -166,7 +166,7 @@ To run Playwright inside Docker, you need to have Node.js, [Playwright browsers] ```Dockerfile FROM node:20-bookworm -RUN npx -y playwright@1.61.1 install --with-deps +RUN npx -y playwright@1.62.0 install --with-deps ``` diff --git a/nodejs/docs/release-notes.mdx b/nodejs/docs/release-notes.mdx index 06949c5442..b4cd2473ed 100644 --- a/nodejs/docs/release-notes.mdx +++ b/nodejs/docs/release-notes.mdx @@ -9,6 +9,118 @@ import HTMLCard from '@site/src/components/HTMLCard'; import LiteYouTube from '@site/src/components/LiteYouTube'; +## Version 1.62 + +### 🧱 New component testing model + +[Component testing](./test-components.mdx) moves to a **stories and galleries** model. A **story** wraps your component in one specific scenario — hard-coded props, mock data, providers — and a + +**gallery** page that you serve renders stories on demand. The new [fixtures.mount()](/api/class-fixtures.mdx#fixtures-mount) fixture navigates to the gallery, mounts a story by id, and returns a [Locator] scoped to the story's root element: + +```js +test('click should expand', async ({ mount }) => { + const component = await mount('components/Expandable/Stateful'); + await component.getByRole('button').click(); + await expect(component.getByTestId('expanded')).toHaveValue('true'); +}); +``` + +Pass a story type as a template argument to type-check its props, and use `update(props)` / `unmount()` on the returned locator to re-render or tear down within a test. + +### 🛑 Cancel operations with AbortSignal + +Most operations and web-first assertions now accept a `signal` option that takes an [`AbortSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal), letting you cancel long-running actions, navigations, waits, and assertions: + +```js +const controller = new AbortController(); +setTimeout(() => controller.abort(), 1000); + +await page.getByRole('button', { name: 'Submit' }).click({ signal: controller.signal }); +await expect(page.getByText('Done')).toBeVisible({ signal: controller.signal }); +``` + +Providing a signal does not disable the default timeout; pass `timeout: 0` to disable it. + +### 🖼️ WebP screenshots + +[expect(page).toHaveScreenshot()](/api/class-pageassertions.mdx#page-assertions-to-have-screenshot-1) and [expect(locator).toHaveScreenshot()](/api/class-locatorassertions.mdx#locator-assertions-to-have-screenshot-1) can now store snapshots in the WebP format — just give the snapshot a `.webp` name: + +```js +// Visual comparisons store the golden snapshot as lossless WebP. +await expect(page).toHaveScreenshot('homepage.webp'); + +// Standalone screenshots can trade quality for size with lossy WebP. +await page.screenshot({ path: 'homepage.webp', quality: 50 }); +``` + +[page.screenshot()](/api/class-page.mdx#page-screenshot) and [locator.screenshot()](/api/class-locator.mdx#locator-screenshot) also accept `webp` as a `type`, where quality `100` (the default) is lossless and lower values use lossy compression. + +### 🧩 Custom test filtering with Reporter.preprocess() + +New [reporter.preprocess()](/api/class-reporter.mdx#reporter-preprocess) hook runs after the configuration is resolved and before [reporter.onBegin()](/api/class-reporter.mdx#reporter-on-begin), letting a reporter mark individual tests as skipped, excluded, fixed, or failing through a [TestRun] object: + +```js +class MyReporter { + async preprocess({ config, suite, testRun }) { + for (const test of suite.allTests()) { + if (shouldSkip(test)) + testRun.skip(test); + } + } +} +``` + +### 🔁 Isolated retries + +New [testConfig.retryStrategy](/api/class-testconfig.mdx#test-config-retry-strategy) controls when failed tests are retried. The default `'immediate'` retries as soon as a worker is free; `'isolated'` runs all retries at the end, one by one in a single worker, to minimize interference with the rest of the suite: + +```js title="playwright.config.ts" +export default defineConfig({ + retries: 2, + retryStrategy: 'isolated', +}); +``` + +### New APIs + +#### Browser and Context +- New option [credentials](/api/class-browsercontext.mdx#browser-context-storage-state-option-credentials) includes the context's virtual WebAuthn [Credentials] (passkeys) in the storage state, so they can be persisted and re-seeded into later contexts. + +#### Actions +- New `scroll` option (`"auto"` | `"none"`) on actions to opt out of Playwright's automatic scroll-into-view. + +#### Network +- New [apiResponse.timing()](/api/class-apiresponse.mdx#api-response-timing) returns resource timing information for an API response. + +#### Evaluation +- New [locator.waitForFunction()](/api/class-locator.mdx#locator-wait-for-function) waits until a function — called with the matching element — returns a truthy value. +- [page.evaluate()](/api/class-page.mdx#page-evaluate) and related methods now accept functions as evaluate arguments. +- [page.addInitScript()](/api/class-page.mdx#page-add-init-script) / [browserContext.addInitScript()](/api/class-browsercontext.mdx#browser-context-add-init-script) now accept functions as init-script arguments. + +#### Command line & MCP +- Playwright now bundles the [Playwright MCP](./getting-started-mcp.mdx) server and [`playwright-cli`](./getting-started-cli.mdx), runnable via `npx playwright mcp` and `npx playwright cli`. + +#### Reporters +- The HTML report's **Merge files** grouping — previously only a UI toggle — can now be enabled from the config with the new `mergeFiles` reporter option: + +```js title="playwright.config.ts" +export default defineConfig({ + reporter: [['html', { mergeFiles: true }]], +}); +``` + +### Announcements +* ⚠️ Debian 11 is not supported anymore. + +### Browser Versions +- Chromium 151.0.7922.34 +- Mozilla Firefox 153.0 +- WebKit 26.5 + +This version was also tested against the following stable channels: +- Google Chrome 151 +- Microsoft Edge 151 + ## Version 1.61 ### 🔑 WebAuthn passkeys diff --git a/nodejs/docs/test-cli.mdx b/nodejs/docs/test-cli.mdx index 6f946ce5fa..8d395ae8f0 100644 --- a/nodejs/docs/test-cli.mdx +++ b/nodejs/docs/test-cli.mdx @@ -82,6 +82,7 @@ npx playwright test --ui | Option | Description | | :--- | :--- | | Non-option arguments | Each argument is treated as a regular expression matched against the full test file path. Only tests from files matching the pattern will be executed. Special symbols like `$` or `*` should be escaped with `\`. In many shells/terminals you may need to quote the arguments. | +| `--add-reporter ` | Reporter to add on top of the reporters configured in the config file, comma-separated. Can be a built-in reporter name or a path to a custom reporter file. Unlike `--reporter`, this keeps the configured reporters instead of replacing them. | | `-c ` or `--config ` | Configuration file, or a test directory with optional "playwright.config.{m,c}?{js,ts}". Defaults to `playwright.config.ts` or `playwright.config.js` in the current directory. | | `--debug` | Run tests with Playwright Inspector. Shortcut for `PWDEBUG=1` environment variable and `--timeout=0 --max-failures=1 --headed --workers=1` options. | | `--fail-on-flaky-tests` | Fail if any test is flagged as flaky (default: false). | diff --git a/nodejs/docs/test-components.mdx b/nodejs/docs/test-components.mdx index 1f80d1a2c1..44dc112394 100644 --- a/nodejs/docs/test-components.mdx +++ b/nodejs/docs/test-components.mdx @@ -213,7 +213,7 @@ This pattern is the heart of the methodology: ### Per-test props -When a scenario is genuinely parametric — a boundary-value sweep, a text matrix — pass plain serializable props as the second argument to `mount`. The gallery hands them to the story as its props: +When a scenario benefits from parameterizing, pass plain serializable props as the second argument to `mount`. The gallery hands them to the story as its props: ```js title="src/components/Button.story.tsx" import { Button } from './Button'; @@ -250,7 +250,7 @@ await expect(await mount('Button/Primary')).toHaveScreenshot('primary.png'); await expect(await mount('Button/Disabled')).toHaveScreenshot('disabled.png'); ``` -Screenshot the returned root locator, not the page, to avoid asserting on browser chrome. +Screenshot the returned root locator, not the page, to avoid asserting on anything extra you might put in the gallery. ### Handling network requests diff --git a/nodejs/docs/test-parallel.mdx b/nodejs/docs/test-parallel.mdx index 7430783c3e..b426f49bc7 100644 --- a/nodejs/docs/test-parallel.mdx +++ b/nodejs/docs/test-parallel.mdx @@ -128,6 +128,43 @@ test('runs second', async () => { }); ``` +## Test locks + +A few tests in your suite may access a shared resource that does not support concurrent access, for example an external service or a global account setting. You can declare named locks on such tests, so that tests sharing a lock name never run at the same time, while all other tests continue to run in parallel. Locks work across files, worker processes and [projects](./test-projects.mdx). + +```js title="settings.spec.ts" +import { test, expect } from '@playwright/test'; + +test('update user settings', { lock: 'user-settings' }, async ({ page }) => { + // ... +}); +``` + +```js title="profile.spec.ts" +import { test, expect } from '@playwright/test'; + +// Never runs concurrently with 'update user settings' above, +// even in a different project. +test('rename user', { lock: 'user-settings' }, async ({ page }) => { + // ... +}); +``` + +A test can declare multiple locks and will only run when all of them are available. You can also declare locks on a group with [test.describe()](/api/class-test.mdx#test-describe), applying them to every test inside. + +```js +test('reset the database', { lock: ['database', 'external-api'] }, async () => { + // ... +}); +``` + +Playwright acquires all the locks of a test before the test starts and releases them when it finishes. + +:::note + +In the default and [serial](#serial-mode) modes, all tests in a file run together in order, so a lock declared on any test is held for the duration of the whole file. +::: + ## Opt out of fully parallel mode If your configuration applies parallel mode to all tests using [testConfig.fullyParallel](/api/class-testconfig.mdx#test-config-fully-parallel), you might still want to run some tests with default settings. You can override the mode per describe: diff --git a/nodejs/docs/test-reporters.mdx b/nodejs/docs/test-reporters.mdx index 75c3bdeadf..e893f7c21d 100644 --- a/nodejs/docs/test-reporters.mdx +++ b/nodejs/docs/test-reporters.mdx @@ -110,12 +110,23 @@ export default defineConfig({ }); ``` +You can omit test tags that are automatically appended to test titles: + +```js title="playwright.config.ts" +import { defineConfig } from '@playwright/test'; + +export default defineConfig({ + reporter: [['list', { omitTags: true }]], +}); +``` + List report supports the following configuration options and environment variables: | Environment Variable Name | Reporter Config Option| Description | Default |---|---|---|---| | `PLAYWRIGHT_LIST_PRINT_STEPS` | `printSteps` | Whether to print each step on its own line. | `false` | `PLAYWRIGHT_LIST_PRINT_FAILURES_INLINE` | `printFailuresInline` | Whether to print failure details immediately after a failed test instead of at the end. | `false` +| `PLAYWRIGHT_LIST_OMIT_TAGS` | `omitTags` | Whether to omit test tags that are automatically appended to test titles. | `false` | `PLAYWRIGHT_FORCE_TTY` | | Whether to produce output suitable for a live terminal. Supports `true`, `1`, `false`, `0`, `[WIDTH]`, and `[WIDTH]x[HEIGHT]`. `[WIDTH]` and `[WIDTH]x[HEIGHT]` specifies the TTY dimensions. | `true` when terminal is in TTY mode, `false` otherwise. | `FORCE_COLOR` | | Whether to produce colored output. | `true` when terminal is in TTY mode, `false` otherwise. | `NO_COLOR` | | Whether to disable colored output ([no-color.org](https://no-color.org/)). Any non-empty value disables colors. | unset @@ -155,6 +166,7 @@ Line report supports the following configuration options and environment variabl | Environment Variable Name | Reporter Config Option| Description | Default |---|---|---|---| +| `PLAYWRIGHT_LINE_OMIT_TAGS` | `omitTags` | Whether to omit test tags that are automatically appended to test titles. | `false` | `PLAYWRIGHT_FORCE_TTY` | | Whether to produce output suitable for a live terminal. Supports `true`, `1`, `false`, `0`, `[WIDTH]`, and `[WIDTH]x[HEIGHT]`. `[WIDTH]` and `[WIDTH]x[HEIGHT]` specifies the TTY dimensions. | `true` when terminal is in TTY mode, `false` otherwise. | `FORCE_COLOR` | | Whether to produce colored output. | `true` when terminal is in TTY mode, `false` otherwise. | `NO_COLOR` | | Whether to disable colored output ([no-color.org](https://no-color.org/)). Any non-empty value disables colors. | unset @@ -198,6 +210,7 @@ Dot report supports the following configuration options and environment variable | Environment Variable Name | Reporter Config Option| Description | Default |---|---|---|---| +| `PLAYWRIGHT_DOT_OMIT_TAGS` | `omitTags` | Whether to omit test tags that are automatically appended to test titles. | `false` | `PLAYWRIGHT_FORCE_TTY` | | Whether to produce output suitable for a live terminal. Supports `true`, `1`, `false`, `0`, `[WIDTH]`, and `[WIDTH]x[HEIGHT]`. `[WIDTH]` and `[WIDTH]x[HEIGHT]` specifies the TTY dimensions. | `true` when terminal is in TTY mode, `false` otherwise. | `FORCE_COLOR` | | Whether to produce colored output. | `true` when terminal is in TTY mode, `false` otherwise. | `NO_COLOR` | | Whether to disable colored output ([no-color.org](https://no-color.org/)). Any non-empty value disables colors. | unset @@ -447,6 +460,7 @@ JUnit report supports following configuration options and environment variables: | `PLAYWRIGHT_JUNIT_OUTPUT_FILE` | `outputFile` | Full path to the output file. If defined, `PLAYWRIGHT_JUNIT_OUTPUT_DIR` and `PLAYWRIGHT_JUNIT_OUTPUT_NAME` will be ignored. | JUnit report is printed to the stdout. | `PLAYWRIGHT_JUNIT_STRIP_ANSI` | `stripANSIControlSequences` | Whether to remove ANSI control sequences from the text before writing it in the report. | By default output text is added as is. | `PLAYWRIGHT_JUNIT_INCLUDE_PROJECT_IN_TEST_NAME` | `includeProjectInTestName` | Whether to include Playwright project name in every test case as a name prefix. | By default not included. +| `PLAYWRIGHT_JUNIT_OMIT_TAGS` | `omitTags` | Whether to omit test tags that are automatically appended to failure details. | `false` | `PLAYWRIGHT_JUNIT_SUITE_ID` | | Value of the `id` attribute on the root `` report entry. | Empty string. | `PLAYWRIGHT_JUNIT_SUITE_NAME` | | Value of the `name` attribute on the root `` report entry. | Empty string. @@ -466,6 +480,8 @@ export default defineConfig({ }); ``` +The `github` reporter accepts `omitTags` (or the `PLAYWRIGHT_GITHUB_OMIT_TAGS` environment variable) to suppress test tags in its annotations, for example `reporter: [['github', { omitTags: true }]]`. + ## Custom reporters You can create a custom reporter by implementing a class with some of the reporter methods. Learn more about the [Reporter] API. diff --git a/python/docs/api/class-apirequest.mdx b/python/docs/api/class-apirequest.mdx index f7b6a5bb46..dee9593527 100644 --- a/python/docs/api/class-apirequest.mdx +++ b/python/docs/api/class-apirequest.mdx @@ -79,7 +79,7 @@ api_request.new_context(**kwargs) - `fail_on_status_code` [bool] *(optional)* Added in: v1.51# Whether to throw on response codes other than 2xx and 3xx. By default response object is returned for all status codes. -- `http_credentials` [Dict] *(optional)*# +- `http_credentials` [Dict] | [List]\[[Dict]\] *(optional)*# - `username` [str] @@ -94,6 +94,8 @@ api_request.new_context(**kwargs) 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. + + Pass an array to use different credentials for different origins. The first entry that matches the request origin is used, and entries with no origin match any request. - `ignore_https_errors` [bool] *(optional)*# Whether to ignore HTTPS errors when sending network requests. Defaults to `false`. diff --git a/python/docs/api/class-browser.mdx b/python/docs/api/class-browser.mdx index 01fdec2950..c751a6698f 100644 --- a/python/docs/api/class-browser.mdx +++ b/python/docs/api/class-browser.mdx @@ -284,7 +284,7 @@ await browser.close() - `has_touch` [bool] *(optional)*# Specifies if viewport supports touch events. Defaults to false. Learn more about [mobile emulation](../emulation.mdx#devices). -- `http_credentials` [Dict] *(optional)*# +- `http_credentials` [Dict] | [List]\[[Dict]\] *(optional)*# - `username` [str] @@ -299,6 +299,8 @@ await browser.close() 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. + + Pass an array to use different credentials for different origins. The first entry that matches the request origin is used, and entries with no origin match any request. - `ignore_https_errors` [bool] *(optional)*# Whether to ignore HTTPS errors when sending network requests. Defaults to `false`. @@ -541,7 +543,7 @@ browser.new_page(**kwargs) - `has_touch` [bool] *(optional)*# Specifies if viewport supports touch events. Defaults to false. Learn more about [mobile emulation](../emulation.mdx#devices). -- `http_credentials` [Dict] *(optional)*# +- `http_credentials` [Dict] | [List]\[[Dict]\] *(optional)*# - `username` [str] @@ -556,6 +558,8 @@ browser.new_page(**kwargs) 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. + + Pass an array to use different credentials for different origins. The first entry that matches the request origin is used, and entries with no origin match any request. - `ignore_https_errors` [bool] *(optional)*# Whether to ignore HTTPS errors when sending network requests. Defaults to `false`. diff --git a/python/docs/api/class-browsercontext.mdx b/python/docs/api/class-browsercontext.mdx index 192ccdd2b6..a487e9128b 100644 --- a/python/docs/api/class-browsercontext.mdx +++ b/python/docs/api/class-browsercontext.mdx @@ -928,9 +928,6 @@ browser_context.route_from_har(har, **kwargs) - `har` [Union]\[[str], [pathlib.Path]\]# Path to a [HAR](http://www.softwareishard.com/blog/har-12-spec) file with prerecorded network data. If `path` is a relative path, then it is resolved relative to the current working directory. -- `intercept_api_requests` [bool] *(optional)* Added in: v1.62# - - If set to `true`, requests made via [APIRequestContext] (such as [browser_context.request](/api/class-browsercontext.mdx#browser-context-request) or [page.request](/api/class-page.mdx#page-request)) are also served from the HAR file. By default these requests are sent to the network, matching the behavior prior to v1.62. Defaults to `false` for backward compatibility. - `not_found` "abort" | "fallback" *(optional)*# * If set to 'abort' any request not found in the HAR file will be aborted. * If set to 'fallback' falls through to the next route handler in the handler chain. @@ -1667,6 +1664,23 @@ When no [page.on("dialog")](/api/class-page.mdx#page-event-dialog) or [browser_c --- +### on("dialogclosed") {/* #browser-context-event-dialog-closed */} + +Added in: v1.63browserContext.on("dialogclosed") + +Emitted when a JavaScript dialog in any page belonging to this context has been closed, either by [dialog.accept()](/api/class-dialog.mdx#dialog-accept), by [dialog.dismiss()](/api/class-dialog.mdx#dialog-dismiss), or manually by the user in the headed browser. + +**Usage** + +```python +browser_context.on("dialogclosed", handler) +``` + +**Event data** +- [Dialog] + +--- + ### on("download") {/* #browser-context-event-download */} Added in: v1.60browserContext.on("download") diff --git a/python/docs/api/class-browsertype.mdx b/python/docs/api/class-browsertype.mdx index 1c61a7f68e..5c38e4409d 100644 --- a/python/docs/api/class-browsertype.mdx +++ b/python/docs/api/class-browsertype.mdx @@ -472,7 +472,7 @@ browser_type.launch_persistent_context(user_data_dir, **kwargs) - `headless` [bool] *(optional)*# Whether to run browser in headless mode. More details for [Chromium](https://developers.google.com/web/updates/2017/04/headless-chrome) and [Firefox](https://hacks.mozilla.org/2017/12/using-headless-mode-in-firefox/). Defaults to `true`. -- `http_credentials` [Dict] *(optional)*# +- `http_credentials` [Dict] | [List]\[[Dict]\] *(optional)*# - `username` [str] @@ -487,6 +487,8 @@ browser_type.launch_persistent_context(user_data_dir, **kwargs) 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. + + Pass an array to use different credentials for different origins. The first entry that matches the request origin is used, and entries with no origin match any request. - `ignore_default_args` [bool] | [List]\[[str]\] *(optional)*# If `true`, Playwright does not pass its own configurations args and only uses the ones from [args](/api/class-browsertype.mdx#browser-type-launch-persistent-context-option-args). If an array is given, then filters out the given default arguments. Dangerous option; use with care. Defaults to `false`. diff --git a/python/docs/api/class-frame.mdx b/python/docs/api/class-frame.mdx index 5d5642e48d..e17d0f6817 100644 --- a/python/docs/api/class-frame.mdx +++ b/python/docs/api/class-frame.mdx @@ -1501,6 +1501,49 @@ frame.parent_frame --- +### pierce_frames {/* #frame-pierce-frames */} + +Added in: v1.63frame.pierce_frames + +When working with iframes, you can create a frame locator that will search for elements in this frame and in all iframes inside it, so that you don't need to locate each iframe first. + +Note that all elements matching the locator must belong to a single frame. For example, if the frame contains two iframes, each with a `Submit` button, piercing frames and locating a button will throw an error because it matches elements from multiple frames. + +**Usage** + +Following snippet locates a button, either in the frame or in one of the iframes inside it: + + + + +```py +locator = frame.pierce_frames.get_by_role("button") +locator.click() +``` + + + + +```py +locator = frame.pierce_frames.get_by_role("button") +await locator.click() +``` + + + + +**Returns** +- [FrameLocator]# + +--- + ### url {/* #frame-url */} Added before v1.9frame.url diff --git a/python/docs/api/class-page.mdx b/python/docs/api/class-page.mdx index f4078f95c3..a6dfaebad1 100644 --- a/python/docs/api/class-page.mdx +++ b/python/docs/api/class-page.mdx @@ -2138,7 +2138,7 @@ Navigate to the previous page in history. :::warning -**Testing Back/Forward Cache (BFCache) is not supported.** By default, Playwright disables the Back/Forward Cache across all browsers. Even if explicitly enabled, Playwright's internal state relies on network-level navigation events. Because BFCache restores unfreeze the DOM without firing these events, using `page.goBack()` or `page.goForward()` to trigger a BFCache restore will result in timeouts and a desynchronized `Page` state. +**Testing Back/Forward Cache (BFCache) is not supported.** By default, Playwright disables the Back/Forward Cache across all browsers. Even if explicitly enabled, Playwright's internal state relies on network-level navigation events. Because BFCache restores unfreeze the DOM without firing these events, using `page.goBack()` or `page.goForward()` to trigger a BFCache restore will result in timeouts and a desynchronized `Page` state. ::: **Usage** @@ -2175,7 +2175,7 @@ Navigate to the next page in history. :::warning -**Testing Back/Forward Cache (BFCache) is not supported.** By default, Playwright disables the Back/Forward Cache across all browsers. Even if explicitly enabled, Playwright's internal state relies on network-level navigation events. Because BFCache restores unfreeze the DOM without firing these events, using `page.goBack()` or `page.goForward()` to trigger a BFCache restore will result in timeouts and a desynchronized `Page` state. +**Testing Back/Forward Cache (BFCache) is not supported.** By default, Playwright disables the Back/Forward Cache across all browsers. Even if explicitly enabled, Playwright's internal state relies on network-level navigation events. Because BFCache restores unfreeze the DOM without firing these events, using `page.goBack()` or `page.goForward()` to trigger a BFCache restore will result in timeouts and a desynchronized `Page` state. ::: **Usage** @@ -3675,6 +3675,49 @@ page.mouse --- +### pierce_frames {/* #page-pierce-frames */} + +Added in: v1.63page.pierce_frames + +When working with iframes, you can create a frame locator that will search for elements in the main frame and in all iframes on the page, so that you don't need to locate each iframe first. + +Note that all elements matching the locator must belong to a single frame. For example, if the page contains two iframes, each with a `Submit` button, piercing frames and locating a button will throw an error because it matches elements from multiple frames. + +**Usage** + +Following snippet locates a button, either in the main frame or in one of the iframes: + + + + +```py +locator = page.pierce_frames.get_by_role("button") +locator.click() +``` + + + + +```py +locator = page.pierce_frames.get_by_role("button") +await locator.click() +``` + + + + +**Returns** +- [FrameLocator]# + +--- + ### request {/* #page-request */} Added in: v1.16page.request @@ -3960,6 +4003,23 @@ When no [page.on("dialog")](/api/class-page.mdx#page-event-dialog) or [browser_c --- +### on("dialogclosed") {/* #page-event-dialog-closed */} + +Added in: v1.63page.on("dialogclosed") + +Emitted when a JavaScript dialog has been closed, either by [dialog.accept()](/api/class-dialog.mdx#dialog-accept), by [dialog.dismiss()](/api/class-dialog.mdx#dialog-dismiss), or manually by the user in the headed browser. + +**Usage** + +```python +page.on("dialogclosed", handler) +``` + +**Event data** +- [Dialog] + +--- + ### on("domcontentloaded") {/* #page-event-dom-content-loaded */} Added in: v1.9page.on("domcontentloaded") diff --git a/python/docs/test-assertions.mdx b/python/docs/test-assertions.mdx index 3a1dff9f09..66d32cdf77 100644 --- a/python/docs/test-assertions.mdx +++ b/python/docs/test-assertions.mdx @@ -53,7 +53,7 @@ page.get_by_role("link", name="next page").click() expect.soft(page.get_by_role("heading", name="Make another order")).to_be_visible() ``` -Note that soft assertions only work with the [`pytest-playwright`](https://pypi.org/project/pytest-playwright/) (or [`pytest-playwright-asyncio`](https://pypi.org/project/pytest-playwright-asyncio/)) plugin, version `0.7.3` or newer. +Note that soft assertions only work with the [`pytest-playwright`](https://pypi.org/project/pytest-playwright/) (or [`pytest-playwright-asyncio`](https://pypi.org/project/pytest-playwright-asyncio/)) plugin, version `0.8.0` or newer. ## Custom Expect Message diff --git a/src/documentation.js b/src/documentation.js index bfbad6d241..23b1a48daf 100644 --- a/src/documentation.js +++ b/src/documentation.js @@ -892,6 +892,9 @@ function csharpOptionOverloadSuffix(option, type) { case 'int': return 'Int'; case 'long': return 'Int64'; case 'Date': return 'Date'; + // Object keeps the original option name, e.g. for `Object|Array` unions. + case 'Object': return ''; + case 'Array': return 'List'; } throw new Error(`CSharp option "${option}" has unsupported type overload "${type}"`); }