From 18de09c4a00a9d710bd2c5915b1ccfaebb9dcd14 Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 6 Mar 2025 10:11:34 +0000 Subject: [PATCH] feat(roll): roll to ToT Playwright (06-03-25) --- dotnet/docs/release-notes.mdx | 43 ++++++++++ java/docs/release-notes.mdx | 40 +++++++++ nodejs/docs/api/class-apirequest.mdx | 4 - nodejs/docs/api/class-apirequestcontext.mdx | 3 - nodejs/docs/api/class-browser.mdx | 6 -- nodejs/docs/api/class-browsercontext.mdx | 3 - nodejs/docs/api/class-testconfig.mdx | 20 ++++- nodejs/docs/api/class-testoptions.mdx | 3 - nodejs/docs/api/class-teststepinfo.mdx | 12 ++- nodejs/docs/release-notes.mdx | 91 ++++++++++++--------- python/docs/api/class-apirequest.mdx | 4 - python/docs/api/class-apirequestcontext.mdx | 3 - python/docs/api/class-browser.mdx | 6 -- python/docs/api/class-browsercontext.mdx | 3 - python/docs/release-notes.mdx | 36 ++++++++ 15 files changed, 191 insertions(+), 86 deletions(-) diff --git a/dotnet/docs/release-notes.mdx b/dotnet/docs/release-notes.mdx index 921e707a122..f85e244bbf6 100644 --- a/dotnet/docs/release-notes.mdx +++ b/dotnet/docs/release-notes.mdx @@ -7,6 +7,49 @@ import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem'; import HTMLCard from '@site/src/components/HTMLCard'; +## Version 1.51 + +### Highlights +* New option [IndexedDB](/api/class-browsercontext.mdx#browser-context-storage-state-option-indexed-db) for [BrowserContext.StorageStateAsync()](/api/class-browsercontext.mdx#browser-context-storage-state) allows to save and restore IndexedDB contents. Useful when your application uses [IndexedDB API](https://developer.mozilla.org/en-US/docs/Web/API/IndexedDB_API) to store authentication tokens, like Firebase Authentication. + + Here is an example following the [authentication guide](./auth.mdx#reusing-signed-in-state): + + ```csharp + // Save storage state into the file. Make sure to include IndexedDB. + await context.StorageStateAsync(new() + { + Path = "../../../playwright/.auth/state.json", + IndexedDB = true + }); + + // Create a new context with the saved storage state. + var context = await browser.NewContextAsync(new() + { + StorageStatePath = "../../../playwright/.auth/state.json" + }); + ``` + +* New option [Visible](/api/class-locator.mdx#locator-filter-option-visible) for [Locator.Filter()](/api/class-locator.mdx#locator-filter) allows matching only visible elements. + + ```csharp + // Ignore invisible todo items. + var todoItems = Page.GetByTestId("todo-item").Filter(new() { Visible = true }); + // Check there are exactly 3 visible ones. + await Expect(todoItems).ToHaveCountAsync(3); + ``` + +* New option `Contrast` for methods [Page.EmulateMediaAsync()](/api/class-page.mdx#page-emulate-media) and [Browser.NewContextAsync()](/api/class-browser.mdx#browser-new-context) allows to emulate the `prefers-contrast` media feature. +* New option [FailOnStatusCode](/api/class-apirequest.mdx#api-request-new-context-option-fail-on-status-code) makes all fetch requests made through the [APIRequestContext] throw on response codes other than 2xx and 3xx. + +### Browser Versions +* Chromium 134.0.6998.35 +* Mozilla Firefox 135.0 +* WebKit 18.4 + +This version was also tested against the following stable channels: +* Google Chrome 133 +* Microsoft Edge 133 + ## Version 1.50 ### Support for Xunit diff --git a/java/docs/release-notes.mdx b/java/docs/release-notes.mdx index 57326a83c71..513d53f1aca 100644 --- a/java/docs/release-notes.mdx +++ b/java/docs/release-notes.mdx @@ -7,6 +7,46 @@ import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem'; import HTMLCard from '@site/src/components/HTMLCard'; +## Version 1.51 + +### Highlights +* New option [setIndexedDB](/api/class-browsercontext.mdx#browser-context-storage-state-option-indexed-db) for [BrowserContext.storageState()](/api/class-browsercontext.mdx#browser-context-storage-state) allows to save and restore IndexedDB contents. Useful when your application uses [IndexedDB API](https://developer.mozilla.org/en-US/docs/Web/API/IndexedDB_API) to store authentication tokens, like Firebase Authentication. + + Here is an example following the [authentication guide](./auth.mdx#reusing-signed-in-state): + + ```java + // Save storage state into the file. Make sure to include IndexedDB. + context.storageState(new BrowserContext.StorageStateOptions() + .setPath(Paths.get("state.json")) + .setIndexedDB(true)); + + // Create a new context with the saved storage state. + BrowserContext context = browser.newContext(new Browser.NewContextOptions() + .setStorageStatePath(Paths.get("state.json"))); + ``` + +* New option [setVisible](/api/class-locator.mdx#locator-filter-option-visible) for [Locator.filter()](/api/class-locator.mdx#locator-filter) allows matching only visible elements. + + ```java + // Ignore invisible todo items. + Locator todoItems = page.getByTestId("todo-item") + .filter(new Locator.FilterOptions().setVisible(true)); + // Check there are exactly 3 visible ones. + assertThat(todoItems).hasCount(3); + ``` + +* New option `setContrast` for methods [Page.emulateMedia()](/api/class-page.mdx#page-emulate-media) and [Browser.newContext()](/api/class-browser.mdx#browser-new-context) allows to emulate the `prefers-contrast` media feature. +* New option [setFailOnStatusCode](/api/class-apirequest.mdx#api-request-new-context-option-fail-on-status-code) makes all fetch requests made through the [APIRequestContext] throw on response codes other than 2xx and 3xx. + +### Browser Versions +* Chromium 134.0.6998.35 +* Mozilla Firefox 135.0 +* WebKit 18.4 + +This version was also tested against the following stable channels: +* Google Chrome 133 +* Microsoft Edge 133 + ## Version 1.50 ### Miscellaneous diff --git a/nodejs/docs/api/class-apirequest.mdx b/nodejs/docs/api/class-apirequest.mdx index 5ffb36252d8..565a337effa 100644 --- a/nodejs/docs/api/class-apirequest.mdx +++ b/nodejs/docs/api/class-apirequest.mdx @@ -150,10 +150,6 @@ await apiRequest.newContext(options); - - `indexedDB` [Array]<[unknown]> *(optional)* - - indexedDB to set for context - Populates context with given storage state. This option can be used to initialize context with logged-in information obtained via [browserContext.storageState()](/api/class-browsercontext.mdx#browser-context-storage-state) or [apiRequestContext.storageState()](/api/class-apirequestcontext.mdx#api-request-context-storage-state). Either a path to the file with saved storage, or the value returned by one of [browserContext.storageState()](/api/class-browsercontext.mdx#browser-context-storage-state) or [apiRequestContext.storageState()](/api/class-apirequestcontext.mdx#api-request-context-storage-state) methods. - `timeout` [number] *(optional)*# diff --git a/nodejs/docs/api/class-apirequestcontext.mdx b/nodejs/docs/api/class-apirequestcontext.mdx index 40aac325a13..becb68c8048 100644 --- a/nodejs/docs/api/class-apirequestcontext.mdx +++ b/nodejs/docs/api/class-apirequestcontext.mdx @@ -622,9 +622,6 @@ await apiRequestContext.storageState(options); - - `indexedDB` [Array]<[unknown]> - - diff --git a/nodejs/docs/api/class-browser.mdx b/nodejs/docs/api/class-browser.mdx index 3caa4158ae1..80eb162fe7b 100644 --- a/nodejs/docs/api/class-browser.mdx +++ b/nodejs/docs/api/class-browser.mdx @@ -383,9 +383,6 @@ If directly using this method to create [BrowserContext]s, it is best practice t localStorage to set for context - - `indexedDB` [Array]<[unknown]> *(optional)* - - indexedDB to set for context Learn more about [storage state and auth](../auth.mdx). @@ -673,9 +670,6 @@ await browser.newPage(options); localStorage to set for context - - `indexedDB` [Array]<[unknown]> *(optional)* - - indexedDB to set for context Learn more about [storage state and auth](../auth.mdx). diff --git a/nodejs/docs/api/class-browsercontext.mdx b/nodejs/docs/api/class-browsercontext.mdx index 3bbeedf5475..636ad4a1ec5 100644 --- a/nodejs/docs/api/class-browsercontext.mdx +++ b/nodejs/docs/api/class-browsercontext.mdx @@ -911,9 +911,6 @@ await browserContext.storageState(options); - - `indexedDB` [Array]<[unknown]> - - --- diff --git a/nodejs/docs/api/class-testconfig.mdx b/nodejs/docs/api/class-testconfig.mdx index b2a900f02e7..a09d3d19890 100644 --- a/nodejs/docs/api/class-testconfig.mdx +++ b/nodejs/docs/api/class-testconfig.mdx @@ -56,9 +56,8 @@ export default defineConfig({ ### captureGitInfo {#test-config-capture-git-info} Added in: v1.51testConfig.captureGitInfo -* These settings control whether git information is captured and stored in the config [testConfig.metadata](/api/class-testconfig.mdx#test-config-metadata). -* The structure of the git commit metadata is subject to change. -* Default values for these settings depend on the environment. When tests run as a part of CI where it is safe to obtain git information, the default value is true, false otherwise. + +These settings control whether git information is captured and stored in the config [testConfig.metadata](/api/class-testconfig.mdx#test-config-metadata). **Usage** @@ -74,11 +73,24 @@ export default defineConfig({ - [Object] - `commit` [boolean] *(optional)* - Whether to capture commit information such as hash, author, timestamp. + Whether to capture commit and pull request information such as hash, author, timestamp. - `diff` [boolean] *(optional)* Whether to capture commit diff. +**Details** +* Capturing `commit` information is useful when you'd like to see it in your HTML (or a third party) report. +* Capturing `diff` information is useful to enrich the report with the actual source diff. This information can be used to provide intelligent advice on how to fix the test. + +:::note + +Default values for these settings depend on the environment. When tests run as a part of CI where it is safe to obtain git information, the default value is `true`, `false` otherwise. +::: + +:::note +The structure of the git commit metadata is subject to change. +::: + --- ### expect {#test-config-expect} diff --git a/nodejs/docs/api/class-testoptions.mdx b/nodejs/docs/api/class-testoptions.mdx index f198db684bd..346865064cd 100644 --- a/nodejs/docs/api/class-testoptions.mdx +++ b/nodejs/docs/api/class-testoptions.mdx @@ -872,9 +872,6 @@ export default defineConfig({ localStorage to set for context - - `indexedDB` [Array]<[unknown]> *(optional)* - - indexedDB to set for context **Details** diff --git a/nodejs/docs/api/class-teststepinfo.mdx b/nodejs/docs/api/class-teststepinfo.mdx index c0d2893e59e..6ead8014fa0 100644 --- a/nodejs/docs/api/class-teststepinfo.mdx +++ b/nodejs/docs/api/class-teststepinfo.mdx @@ -14,9 +14,8 @@ import { test, expect } from '@playwright/test'; test('basic test', async ({ page, browserName }) => { await test.step('check some behavior', async step => { - await step.skip(browserName === 'webkit', 'The feature is not available in WebKit'); + step.skip(browserName === 'webkit', 'The feature is not available in WebKit'); // ... rest of the step code - await page.check('input'); }); }); ``` @@ -103,8 +102,8 @@ Abort the currently running step and mark it as skipped. Useful for steps that a import { test, expect } from '@playwright/test'; test('my test', async ({ page }) => { - await test.step('check expectations', async () => { - test.skip(); + await test.step('check expectations', async step => { + step.skip(); // step body below will not run // ... }); @@ -125,9 +124,8 @@ Conditionally abort the currently running step and mark it as skipped with an op import { test, expect } from '@playwright/test'; test('my test', async ({ page, isMobile }) => { - await test.step('check desktop expectations', async () => { - test.skip(isMobile, 'not present in the mobile layout'); - + await test.step('check desktop expectations', async step => { + step.skip(isMobile, 'not present in the mobile layout'); // step body below will not run // ... }); diff --git a/nodejs/docs/release-notes.mdx b/nodejs/docs/release-notes.mdx index 76175a4f2aa..02180d201cc 100644 --- a/nodejs/docs/release-notes.mdx +++ b/nodejs/docs/release-notes.mdx @@ -11,7 +11,7 @@ import LiteYouTube from '@site/src/components/LiteYouTube'; ## Version 1.51 -### Highlights +### StorageState for indexedDB * New option [indexedDB](/api/class-browsercontext.mdx#browser-context-storage-state-option-indexed-db) for [browserContext.storageState()](/api/class-browsercontext.mdx#browser-context-storage-state) allows to save and restore IndexedDB contents. Useful when your application uses [IndexedDB API](https://developer.mozilla.org/en-US/docs/Web/API/IndexedDB_API) to store authentication tokens, like Firebase Authentication. Here is an example following the [authentication guide](./auth.mdx#basic-shared-account-in-all-tests): @@ -31,47 +31,58 @@ import LiteYouTube from '@site/src/components/LiteYouTube'; }); ``` -* New option [visible](/api/class-locator.mdx#locator-filter-option-visible) for [locator.filter()](/api/class-locator.mdx#locator-filter) allows matching only visible elements. - - ```js title="example.spec.ts" - test('some test', async ({ page }) => { - // Ignore invisible todo items. - const todoItems = page.getByTestId('todo-item').filter({ visible: true }); - // Check there are exactly 3 visible ones. - await expect(todoItems).toHaveCount(3); - }); - ``` - -* Set option [testConfig.captureGitInfo](/api/class-testconfig.mdx#test-config-capture-git-info) to capture git information into [testConfig.metadata](/api/class-testconfig.mdx#test-config-metadata). - - ```js title="playwright.config.ts" - import { defineConfig } from '@playwright/test'; - - export default defineConfig({ - captureGitInfo: { commit: true, diff: true } - }); - ``` - - HTML report will show this information when available: - - ![Git information in the report](https://github.com/user-attachments/assets/9ca4a05a-1485-4521-826b-50568babec3f) +### Copy as prompt -### Test runner -* A new [TestStepInfo] object is now available in test steps. You can add step attachments or skip the step under some conditions. - - ```js - test('some test', async ({ page, isMobile }) => { - // Note the new "step" argument: - await test.step('here is my step', async step => { - step.skip(isMobile, 'not relevant on mobile layouts'); - - // ... - await step.attach('my attachment', { body: 'some text' }); - // ... - }); +New "Copy prompt" button on errors in the HTML report, trace viewer and UI mode. Click to copy a pre-filled LLM prompt that contains the error message and useful context for fixing the error. + +![Copy prompt](https://github.com/user-attachments/assets/f3654407-dd6d-4240-9845-0d96df2bf30a) + +### Filter visible elements + +New option [visible](/api/class-locator.mdx#locator-filter-option-visible) for [locator.filter()](/api/class-locator.mdx#locator-filter) allows matching only visible elements. + +```js title="example.spec.ts" +test('some test', async ({ page }) => { + // Ignore invisible todo items. + const todoItems = page.getByTestId('todo-item').filter({ visible: true }); + // Check there are exactly 3 visible ones. + await expect(todoItems).toHaveCount(3); +}); +``` + +### Git information in HTML report + +Set option [testConfig.captureGitInfo](/api/class-testconfig.mdx#test-config-capture-git-info) to capture git information into [testConfig.metadata](/api/class-testconfig.mdx#test-config-metadata). + +```js title="playwright.config.ts" +import { defineConfig } from '@playwright/test'; + +export default defineConfig({ + captureGitInfo: { commit: true, diff: true } +}); +``` + +HTML report will show this information when available: + +![Git information in the report](https://github.com/user-attachments/assets/f5b3f6f4-aa08-4a24-816c-7edf33ef0c37) + +### Test Step improvements + +A new [TestStepInfo] object is now available in test steps. You can add step attachments or skip the step under some conditions. + +```js +test('some test', async ({ page, isMobile }) => { + // Note the new "step" argument: + await test.step('here is my step', async step => { + step.skip(isMobile, 'not relevant on mobile layouts'); + + // ... + await step.attach('my attachment', { body: 'some text' }); + // ... }); - ``` - +}); +``` + ### Miscellaneous * New option `contrast` for methods [page.emulateMedia()](/api/class-page.mdx#page-emulate-media) and [browser.newContext()](/api/class-browser.mdx#browser-new-context) allows to emulate the `prefers-contrast` media feature. * New option [failOnStatusCode](/api/class-apirequest.mdx#api-request-new-context-option-fail-on-status-code) makes all fetch requests made through the [APIRequestContext] throw on response codes other than 2xx and 3xx. diff --git a/python/docs/api/class-apirequest.mdx b/python/docs/api/class-apirequest.mdx index 1f295d3c8c5..510f1c176b9 100644 --- a/python/docs/api/class-apirequest.mdx +++ b/python/docs/api/class-apirequest.mdx @@ -149,10 +149,6 @@ api_request.new_context(**kwargs) - - `indexedDB` [List]\[[Any]\] *(optional)* - - indexedDB to set for context - Populates context with given storage state. This option can be used to initialize context with logged-in information obtained via [browser_context.storage_state()](/api/class-browsercontext.mdx#browser-context-storage-state) or [api_request_context.storage_state()](/api/class-apirequestcontext.mdx#api-request-context-storage-state). Either a path to the file with saved storage, or the value returned by one of [browser_context.storage_state()](/api/class-browsercontext.mdx#browser-context-storage-state) or [api_request_context.storage_state()](/api/class-apirequestcontext.mdx#api-request-context-storage-state) methods. - `timeout` [float] *(optional)*# diff --git a/python/docs/api/class-apirequestcontext.mdx b/python/docs/api/class-apirequestcontext.mdx index 533b0d2b110..ae545e9920b 100644 --- a/python/docs/api/class-apirequestcontext.mdx +++ b/python/docs/api/class-apirequestcontext.mdx @@ -712,9 +712,6 @@ api_request_context.storage_state(**kwargs) - - `indexedDB` [List]\[[Any]\] - - diff --git a/python/docs/api/class-browser.mdx b/python/docs/api/class-browser.mdx index 56612b253de..156b00c9de0 100644 --- a/python/docs/api/class-browser.mdx +++ b/python/docs/api/class-browser.mdx @@ -381,9 +381,6 @@ await browser.close() localStorage to set for context - - `indexedDB` [List]\[[Any]\] *(optional)* - - indexedDB to set for context Learn more about [storage state and auth](../auth.mdx). @@ -639,9 +636,6 @@ browser.new_page(**kwargs) localStorage to set for context - - `indexedDB` [List]\[[Any]\] *(optional)* - - indexedDB to set for context Learn more about [storage state and auth](../auth.mdx). diff --git a/python/docs/api/class-browsercontext.mdx b/python/docs/api/class-browsercontext.mdx index eb123934555..fca51f293ed 100644 --- a/python/docs/api/class-browsercontext.mdx +++ b/python/docs/api/class-browsercontext.mdx @@ -1239,9 +1239,6 @@ browser_context.storage_state(**kwargs) - - `indexedDB` [List]\[[Any]\] - - --- diff --git a/python/docs/release-notes.mdx b/python/docs/release-notes.mdx index c03b6202db1..80cb585a0dc 100644 --- a/python/docs/release-notes.mdx +++ b/python/docs/release-notes.mdx @@ -7,6 +7,42 @@ import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem'; import HTMLCard from '@site/src/components/HTMLCard'; +## Version 1.51 + +### Highlights +* New option [indexed_db](/api/class-browsercontext.mdx#browser-context-storage-state-option-indexed-db) for [browser_context.storage_state()](/api/class-browsercontext.mdx#browser-context-storage-state) allows to save and restore IndexedDB contents. Useful when your application uses [IndexedDB API](https://developer.mozilla.org/en-US/docs/Web/API/IndexedDB_API) to store authentication tokens, like Firebase Authentication. + + Here is an example following the [authentication guide](./auth.mdx#reusing-signed-in-state): + + ```python + # Save storage state into the file. Make sure to include IndexedDB. + storage = await context.storage_state(path="state.json", indexed_db=True) + + # Create a new context with the saved storage state. + context = await browser.new_context(storage_state="state.json") + ``` + +* New option [visible](/api/class-locator.mdx#locator-filter-option-visible) for [locator.filter()](/api/class-locator.mdx#locator-filter) allows matching only visible elements. + + ```python + # Ignore invisible todo items. + todo_items = page.get_by_test_id("todo-item").filter(visible=True) + # Check there are exactly 3 visible ones. + await expect(todo_items).to_have_count(3) + ``` + +* New option `contrast` for methods [page.emulate_media()](/api/class-page.mdx#page-emulate-media) and [browser.new_context()](/api/class-browser.mdx#browser-new-context) allows to emulate the `prefers-contrast` media feature. +* New option [fail_on_status_code](/api/class-apirequest.mdx#api-request-new-context-option-fail-on-status-code) makes all fetch requests made through the [APIRequestContext] throw on response codes other than 2xx and 3xx. + +### Browser Versions +* Chromium 134.0.6998.35 +* Mozilla Firefox 135.0 +* WebKit 18.4 + +This version was also tested against the following stable channels: +* Google Chrome 133 +* Microsoft Edge 133 + ## Version 1.50 ### Async Pytest Plugin