From 84825341a746061d67584c09b7c306aaee7618ac Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri, 31 Jan 2025 10:11:06 +0000 Subject: [PATCH] feat(roll): roll to ToT Playwright (31-01-25) --- dotnet/docs/api/class-browsertype.mdx | 41 ++++---------- dotnet/docs/api/class-locator.mdx | 2 +- dotnet/docs/api/class-locatorassertions.mdx | 8 +-- dotnet/docs/aria-snapshots.mdx | 42 ++++----------- dotnet/docs/release-notes.mdx | 2 +- java/docs/api/class-browsertype.mdx | 42 ++++----------- java/docs/api/class-locator.mdx | 2 +- java/docs/api/class-locatorassertions.mdx | 8 +-- java/docs/aria-snapshots.mdx | 42 ++++----------- java/docs/release-notes.mdx | 2 +- nodejs/docs/api/class-browsertype.mdx | 13 ++++- nodejs/docs/api/class-locator.mdx | 2 +- nodejs/docs/api/class-locatorassertions.mdx | 8 +-- nodejs/docs/aria-snapshots.mdx | 59 ++++++++++++++++----- nodejs/docs/release-notes.mdx | 2 +- nodejs/docs/test-cli.mdx | 2 +- python/docs/api/class-browsertype.mdx | 41 ++++---------- python/docs/api/class-locator.mdx | 2 +- python/docs/api/class-locatorassertions.mdx | 39 ++++++++++++-- python/docs/aria-snapshots.mdx | 42 ++++----------- python/docs/release-notes.mdx | 2 +- python/docs/test-runners.mdx | 2 +- 22 files changed, 178 insertions(+), 227 deletions(-) diff --git a/dotnet/docs/api/class-browsertype.mdx b/dotnet/docs/api/class-browsertype.mdx index 5f21adcf0c4..4fbc355e591 100644 --- a/dotnet/docs/api/class-browsertype.mdx +++ b/dotnet/docs/api/class-browsertype.mdx @@ -37,42 +37,19 @@ class BrowserTypeExamples Added before v1.9browserType.ConnectAsync -This method attaches Playwright to an existing browser instance. When connecting to another browser launched via `BrowserType.launchServer` in Node.js, the major and minor version needs to match the client version (1.2.3 → is compatible with 1.2.x). +This method attaches Playwright to an existing browser instance created via `BrowserType.launchServer` in Node.js. + +:::note + +The major and minor version of the Playwright instance that connects needs to match the version of Playwright that launches the browser (1.2.3 → is compatible with 1.2.x). +::: **Usage** ```csharp -await BrowserType.ConnectAsync(wsEndpoint, options); +await BrowserType.ConnectAsync(); ``` -**Arguments** -- `wsEndpoint` [string] Added in: v1.10# - - A browser websocket endpoint to connect to. -- `options` `BrowserTypeConnectOptions?` *(optional)* - - `ExposeNetwork` [string]? *(optional)* Added in: v1.37# - - This option exposes network available on the connecting client to the browser being connected to. Consists of a list of rules separated by comma. - - Available rules: - 1. Hostname pattern, for example: `example.com`, `*.org:99`, `x.*.y.com`, `*foo.org`. - 1. IP literal, for example: `127.0.0.1`, `0.0.0.0:99`, `[::1]`, `[0:0::1]:99`. - 1. `` that matches local loopback interfaces: `localhost`, `*.localhost`, `127.0.0.1`, `[::1]`. - - Some common examples: - 1. `"*"` to expose all network. - 1. `""` to expose localhost network. - 1. `"*.test.internal-domain,*.staging.internal-domain,"` to expose test/staging deployments and localhost. - - `Headers` [IDictionary]?<[string], [string]> *(optional)* Added in: v1.11# - - Additional HTTP headers to be sent with web socket connect request. Optional. - - `SlowMo` [float]? *(optional)* Added in: v1.10# - - Slows down Playwright operations by the specified amount of milliseconds. Useful so that you can see what is going on. Defaults to 0. - - `Timeout` [float]? *(optional)* Added in: v1.10# - - Maximum time in milliseconds to wait for the connection to be established. Defaults to `0` (no timeout). - **Returns** - [Browser]# @@ -91,6 +68,10 @@ The default browser context is accessible via [Browser.Contexts](/api/class-brow Connecting over the Chrome DevTools Protocol is only supported for Chromium-based browsers. ::: +:::note +This connection is significantly lower fidelity than the Playwright protocol connection via [BrowserType.ConnectAsync()](/api/class-browsertype.mdx#browser-type-connect). If you are experiencing issues or attempting to use advanced functionality, you probably want to use [BrowserType.ConnectAsync()](/api/class-browsertype.mdx#browser-type-connect). +::: + **Usage** ```csharp diff --git a/dotnet/docs/api/class-locator.mdx b/dotnet/docs/api/class-locator.mdx index 735e79cdf21..a9ebb96c889 100644 --- a/dotnet/docs/api/class-locator.mdx +++ b/dotnet/docs/api/class-locator.mdx @@ -115,7 +115,7 @@ var button = page.GetByRole(AriaRole.Button).And(page.GetByTitle("Subscribe")); Added in: v1.49locator.AriaSnapshotAsync -Captures the aria snapshot of the given element. Read more about [aria snapshots](../aria-snapshots.mdx) and [Expect(Locator).ToMatchAriaSnapshotAsync()](/api/class-locatorassertions.mdx#locator-assertions-to-match-aria-snapshot-1) for the corresponding assertion. +Captures the aria snapshot of the given element. Read more about [aria snapshots](../aria-snapshots.mdx) and [Expect(Locator).ToMatchAriaSnapshotAsync()](/api/class-locatorassertions.mdx#locator-assertions-to-match-aria-snapshot) for the corresponding assertion. **Usage** diff --git a/dotnet/docs/api/class-locatorassertions.mdx b/dotnet/docs/api/class-locatorassertions.mdx index b89e5005faf..10a839a7fcf 100644 --- a/dotnet/docs/api/class-locatorassertions.mdx +++ b/dotnet/docs/api/class-locatorassertions.mdx @@ -811,7 +811,7 @@ await Expect(locator).ToHaveValuesAsync(new Regex[] { new Regex("R"), new Regex( --- -### ToMatchAriaSnapshotAsync {#locator-assertions-to-match-aria-snapshot-1} +### ToMatchAriaSnapshotAsync {#locator-assertions-to-match-aria-snapshot} Added in: v1.49locatorAssertions.ToMatchAriaSnapshotAsync @@ -828,14 +828,14 @@ await Expect(page.Locator("body")).ToMatchAriaSnapshotAsync(@" ``` **Arguments** -- `expected` [string]# +- `expected` [string]# - `options` `LocatorAssertionsToMatchAriaSnapshotOptions?` *(optional)* - - `Timeout` [float]? *(optional)*# + - `Timeout` [float]? *(optional)*# Time to retry the assertion for in milliseconds. Defaults to `5000`. **Returns** -- [void]# +- [void]# --- diff --git a/dotnet/docs/aria-snapshots.mdx b/dotnet/docs/aria-snapshots.mdx index db218e18d9e..d4c5e75fd21 100644 --- a/dotnet/docs/aria-snapshots.mdx +++ b/dotnet/docs/aria-snapshots.mdx @@ -10,7 +10,7 @@ import LiteYouTube from '@site/src/components/LiteYouTube'; ## Overview -With the Playwright Snapshot testing you can assert the accessibility tree of a page against a predefined snapshot template. +With Playwright's Snapshot testing you can assert the accessibility tree of a page against a predefined snapshot template. ```csharp await page.GotoAsync("https://playwright.dev/"); @@ -31,11 +31,11 @@ Snapshot testing and assertion testing serve different purposes in test automati ### Assertion testing -Assertion testing is a targeted approach where you assert specific values or conditions about elements or components. For instance, with Playwright, [Expect(Locator).ToHaveTextAsync()](/api/class-locatorassertions.mdx#locator-assertions-to-have-text) verifies that an element contains the expected text, and [Expect(Locator).ToHaveValueAsync()](/api/class-locatorassertions.mdx#locator-assertions-to-have-value) confirms that an input field has the expected value. Assertion tests are specific and generally check the current state of an element or property against an expected, predefined state. They work well for predictable, single-value checks but are limited in scope when testing the broader structure or variations. +Assertion testing is a targeted approach where you assert specific values or conditions about elements or components. For instance, with Playwright, [Expect(Locator).ToHaveTextAsync()](/api/class-locatorassertions.mdx#locator-assertions-to-have-text) verifies that an element contains the expected text, and [Expect(Locator).ToHaveValueAsync()](/api/class-locatorassertions.mdx#locator-assertions-to-have-value) confirms that an input field has the expected value. Assertion tests are specific and generally check the current state of an element or property against an expected, predefined state. They work well for predictable, single-value checks but are limited in scope when testing the broader structure or variations. **Advantages** - **Clarity**: The intent of the test is explicit and easy to understand. -- **Specificity**: Tests focus on particular aspects of functionality, making them more robust against unrelated changes. +- **Specificity**: Tests focus on particular aspects of functionality, making them more robust against unrelated changes. - **Debugging**: Failures provide targeted feedback, pointing directly to the problematic aspect. **Disadvantages** @@ -88,7 +88,7 @@ These values are derived from ARIA attributes or calculated based on HTML semant ## Snapshot matching -The [Expect(Locator).ToMatchAriaSnapshotAsync()](/api/class-locatorassertions.mdx#locator-assertions-to-match-aria-snapshot-1) assertion method in Playwright compares the accessible structure of the locator scope with a predefined aria snapshot template, helping validate the page's state against testing requirements. +The [Expect(Locator).ToMatchAriaSnapshotAsync()](/api/class-locatorassertions.mdx#locator-assertions-to-match-aria-snapshot) assertion method in Playwright compares the accessible structure of the locator scope with a predefined aria snapshot template, helping validate the page's state against testing requirements. For the following DOM: @@ -123,7 +123,7 @@ You can perform partial matches on nodes by omitting attributes or accessible na - button ``` -In this example, the button role is matched, but the accessible name ("Submit") is not specified, allowing the test to pass regardless of the button’s label. +In this example, the button role is matched, but the accessible name ("Submit") is not specified, allowing the test to pass regardless of the button's label.
@@ -178,37 +178,17 @@ Regular expressions allow flexible matching for elements with dynamic or variabl ## Generating snapshots -Creating aria snapshots in Playwright helps ensure and maintain your application’s structure. You can generate snapshots in various ways depending on your testing setup and workflow. +Creating aria snapshots in Playwright helps ensure and maintain your application's structure. You can generate snapshots in various ways depending on your testing setup and workflow. -### 1. Generating snapshots with the Playwright code generator +### Generating snapshots with the Playwright code generator -If you’re using Playwright’s [Code Generator](./codegen.mdx), generating aria snapshots is streamlined with its interactive interface: +If you're using Playwright's [Code Generator](./codegen.mdx), generating aria snapshots is streamlined with its interactive interface: - **"Assert snapshot" Action**: In the code generator, you can use the "Assert snapshot" action to automatically create a snapshot assertion for the selected elements. This is a quick way to capture the aria snapshot as part of your recorded test flow. - **"Aria snapshot" Tab**: The "Aria snapshot" tab within the code generator interface visually represents the aria snapshot for a selected locator, letting you explore, inspect, and verify element roles, attributes, and accessible names to aid snapshot creation and review. -### 2. Updating snapshots with `@playwright/test` and the `--update-snapshots` flag +### Using the `Locator.ariaSnapshot` method -When using the Playwright test runner (`@playwright/test`), you can automatically update snapshots by running tests with the `--update-snapshots` flag: - -```bash -npx playwright test --update-snapshots -``` - -This command regenerates snapshots for assertions, including aria snapshots, replacing outdated ones. It’s useful when application structure changes require new snapshots as a baseline. Note that Playwright will wait for the maximum expect timeout specified in the test runner configuration to ensure the page is settled before taking the snapshot. It might be necessary to adjust the `--timeout` if the test hits the timeout while generating snapshots. - -#### Empty template for snapshot generation - -Passing an empty string as the template in an assertion generates a snapshot on-the-fly: - -Note that Playwright will wait for the maximum expect timeout specified in the test runner configuration to ensure the page is settled before taking the snapshot. It might be necessary to adjust the `--timeout` if the test hits the timeout while generating snapshots. - -#### Snapshot patch files - -When updating snapshots, Playwright creates patch files that capture differences. These patch files can be reviewed, applied, and committed to source control, allowing teams to track structural changes over time and ensure updates are consistent with application requirements. - -### 3. Using the `Locator.ariaSnapshot` method - -The [Locator.AriaSnapshotAsync()](/api/class-locator.mdx#locator-aria-snapshot) method allows you to programmatically create a YAML representation of accessible elements within a locator’s scope, especially helpful for generating snapshots dynamically during test execution. +The [Locator.AriaSnapshotAsync()](/api/class-locator.mdx#locator-aria-snapshot) method allows you to programmatically create a YAML representation of accessible elements within a locator's scope, especially helpful for generating snapshots dynamically during test execution. **Example**: @@ -217,7 +197,7 @@ var snapshot = await page.Locator("body").AriaSnapshotAsync(); Console.WriteLine(snapshot); ``` -This command outputs the aria snapshot within the specified locator’s scope in YAML format, which you can validate or store as needed. +This command outputs the aria snapshot within the specified locator's scope in YAML format, which you can validate or store as needed. ## Accessibility tree examples diff --git a/dotnet/docs/release-notes.mdx b/dotnet/docs/release-notes.mdx index 58459e24267..1391bc50ed0 100644 --- a/dotnet/docs/release-notes.mdx +++ b/dotnet/docs/release-notes.mdx @@ -11,7 +11,7 @@ import HTMLCard from '@site/src/components/HTMLCard'; ### Aria snapshots -New assertion [Expect(Locator).ToMatchAriaSnapshotAsync()](/api/class-locatorassertions.mdx#locator-assertions-to-match-aria-snapshot-1) verifies page structure by comparing to an expected accessibility tree, represented as YAML. +New assertion [Expect(Locator).ToMatchAriaSnapshotAsync()](/api/class-locatorassertions.mdx#locator-assertions-to-match-aria-snapshot) verifies page structure by comparing to an expected accessibility tree, represented as YAML. ```csharp await page.GotoAsync("https://playwright.dev"); diff --git a/java/docs/api/class-browsertype.mdx b/java/docs/api/class-browsertype.mdx index d3436c1fa53..04ef549a41d 100644 --- a/java/docs/api/class-browsertype.mdx +++ b/java/docs/api/class-browsertype.mdx @@ -35,43 +35,19 @@ public class Example { Added before v1.9browserType.connect -This method attaches Playwright to an existing browser instance. When connecting to another browser launched via `BrowserType.launchServer` in Node.js, the major and minor version needs to match the client version (1.2.3 → is compatible with 1.2.x). +This method attaches Playwright to an existing browser instance created via `BrowserType.launchServer` in Node.js. + +:::note + +The major and minor version of the Playwright instance that connects needs to match the version of Playwright that launches the browser (1.2.3 → is compatible with 1.2.x). +::: **Usage** ```java -BrowserType.connect(wsEndpoint); -BrowserType.connect(wsEndpoint, options); +BrowserType.connect(); ``` -**Arguments** -- `wsEndpoint` [String] Added in: v1.10# - - A browser websocket endpoint to connect to. -- `options` `BrowserType.ConnectOptions` *(optional)* - - `setExposeNetwork` [String] *(optional)* Added in: v1.37# - - This option exposes network available on the connecting client to the browser being connected to. Consists of a list of rules separated by comma. - - Available rules: - 1. Hostname pattern, for example: `example.com`, `*.org:99`, `x.*.y.com`, `*foo.org`. - 1. IP literal, for example: `127.0.0.1`, `0.0.0.0:99`, `[::1]`, `[0:0::1]:99`. - 1. `` that matches local loopback interfaces: `localhost`, `*.localhost`, `127.0.0.1`, `[::1]`. - - Some common examples: - 1. `"*"` to expose all network. - 1. `""` to expose localhost network. - 1. `"*.test.internal-domain,*.staging.internal-domain,"` to expose test/staging deployments and localhost. - - `setHeaders` [Map]<[String], [String]> *(optional)* Added in: v1.11# - - Additional HTTP headers to be sent with web socket connect request. Optional. - - `setSlowMo` [double] *(optional)* Added in: v1.10# - - Slows down Playwright operations by the specified amount of milliseconds. Useful so that you can see what is going on. Defaults to 0. - - `setTimeout` [double] *(optional)* Added in: v1.10# - - Maximum time in milliseconds to wait for the connection to be established. Defaults to `0` (no timeout). - **Returns** - [Browser]# @@ -90,6 +66,10 @@ The default browser context is accessible via [Browser.contexts()](/api/class-br Connecting over the Chrome DevTools Protocol is only supported for Chromium-based browsers. ::: +:::note +This connection is significantly lower fidelity than the Playwright protocol connection via [BrowserType.connect()](/api/class-browsertype.mdx#browser-type-connect). If you are experiencing issues or attempting to use advanced functionality, you probably want to use [BrowserType.connect()](/api/class-browsertype.mdx#browser-type-connect). +::: + **Usage** ```java diff --git a/java/docs/api/class-locator.mdx b/java/docs/api/class-locator.mdx index c3b130751f4..51110f0806c 100644 --- a/java/docs/api/class-locator.mdx +++ b/java/docs/api/class-locator.mdx @@ -115,7 +115,7 @@ Locator button = page.getByRole(AriaRole.BUTTON).and(page.getByTitle("Subscribe" Added in: v1.49locator.ariaSnapshot -Captures the aria snapshot of the given element. Read more about [aria snapshots](../aria-snapshots.mdx) and [assertThat(locator).matchesAriaSnapshot()](/api/class-locatorassertions.mdx#locator-assertions-to-match-aria-snapshot-1) for the corresponding assertion. +Captures the aria snapshot of the given element. Read more about [aria snapshots](../aria-snapshots.mdx) and [assertThat(locator).matchesAriaSnapshot()](/api/class-locatorassertions.mdx#locator-assertions-to-match-aria-snapshot) for the corresponding assertion. **Usage** diff --git a/java/docs/api/class-locatorassertions.mdx b/java/docs/api/class-locatorassertions.mdx index ac4c235b14e..90d9da61f98 100644 --- a/java/docs/api/class-locatorassertions.mdx +++ b/java/docs/api/class-locatorassertions.mdx @@ -788,7 +788,7 @@ assertThat( --- -### matchesAriaSnapshot {#locator-assertions-to-match-aria-snapshot-1} +### matchesAriaSnapshot {#locator-assertions-to-match-aria-snapshot} Added in: v1.49locatorAssertions.matchesAriaSnapshot @@ -805,14 +805,14 @@ assertThat(page.locator("body")).matchesAriaSnapshot(""" ``` **Arguments** -- `expected` [String]# +- `expected` [String]# - `options` `LocatorAssertions.MatchesAriaSnapshotOptions` *(optional)* - - `setTimeout` [double] *(optional)*# + - `setTimeout` [double] *(optional)*# Time to retry the assertion for in milliseconds. Defaults to `5000`. **Returns** -- [void]# +- [void]# --- diff --git a/java/docs/aria-snapshots.mdx b/java/docs/aria-snapshots.mdx index 78eba4ad041..ec1d1f0ab99 100644 --- a/java/docs/aria-snapshots.mdx +++ b/java/docs/aria-snapshots.mdx @@ -10,7 +10,7 @@ import LiteYouTube from '@site/src/components/LiteYouTube'; ## Overview -With the Playwright Snapshot testing you can assert the accessibility tree of a page against a predefined snapshot template. +With Playwright's Snapshot testing you can assert the accessibility tree of a page against a predefined snapshot template. ```java page.navigate("https://playwright.dev/"); @@ -31,11 +31,11 @@ Snapshot testing and assertion testing serve different purposes in test automati ### Assertion testing -Assertion testing is a targeted approach where you assert specific values or conditions about elements or components. For instance, with Playwright, [assertThat(locator).hasText()](/api/class-locatorassertions.mdx#locator-assertions-to-have-text) verifies that an element contains the expected text, and [assertThat(locator).hasValue()](/api/class-locatorassertions.mdx#locator-assertions-to-have-value) confirms that an input field has the expected value. Assertion tests are specific and generally check the current state of an element or property against an expected, predefined state. They work well for predictable, single-value checks but are limited in scope when testing the broader structure or variations. +Assertion testing is a targeted approach where you assert specific values or conditions about elements or components. For instance, with Playwright, [assertThat(locator).hasText()](/api/class-locatorassertions.mdx#locator-assertions-to-have-text) verifies that an element contains the expected text, and [assertThat(locator).hasValue()](/api/class-locatorassertions.mdx#locator-assertions-to-have-value) confirms that an input field has the expected value. Assertion tests are specific and generally check the current state of an element or property against an expected, predefined state. They work well for predictable, single-value checks but are limited in scope when testing the broader structure or variations. **Advantages** - **Clarity**: The intent of the test is explicit and easy to understand. -- **Specificity**: Tests focus on particular aspects of functionality, making them more robust against unrelated changes. +- **Specificity**: Tests focus on particular aspects of functionality, making them more robust against unrelated changes. - **Debugging**: Failures provide targeted feedback, pointing directly to the problematic aspect. **Disadvantages** @@ -88,7 +88,7 @@ These values are derived from ARIA attributes or calculated based on HTML semant ## Snapshot matching -The [assertThat(locator).matchesAriaSnapshot()](/api/class-locatorassertions.mdx#locator-assertions-to-match-aria-snapshot-1) assertion method in Playwright compares the accessible structure of the locator scope with a predefined aria snapshot template, helping validate the page's state against testing requirements. +The [assertThat(locator).matchesAriaSnapshot()](/api/class-locatorassertions.mdx#locator-assertions-to-match-aria-snapshot) assertion method in Playwright compares the accessible structure of the locator scope with a predefined aria snapshot template, helping validate the page's state against testing requirements. For the following DOM: @@ -123,7 +123,7 @@ You can perform partial matches on nodes by omitting attributes or accessible na - button ``` -In this example, the button role is matched, but the accessible name ("Submit") is not specified, allowing the test to pass regardless of the button’s label. +In this example, the button role is matched, but the accessible name ("Submit") is not specified, allowing the test to pass regardless of the button's label.
@@ -178,37 +178,17 @@ Regular expressions allow flexible matching for elements with dynamic or variabl ## Generating snapshots -Creating aria snapshots in Playwright helps ensure and maintain your application’s structure. You can generate snapshots in various ways depending on your testing setup and workflow. +Creating aria snapshots in Playwright helps ensure and maintain your application's structure. You can generate snapshots in various ways depending on your testing setup and workflow. -### 1. Generating snapshots with the Playwright code generator +### Generating snapshots with the Playwright code generator -If you’re using Playwright’s [Code Generator](./codegen.mdx), generating aria snapshots is streamlined with its interactive interface: +If you're using Playwright's [Code Generator](./codegen.mdx), generating aria snapshots is streamlined with its interactive interface: - **"Assert snapshot" Action**: In the code generator, you can use the "Assert snapshot" action to automatically create a snapshot assertion for the selected elements. This is a quick way to capture the aria snapshot as part of your recorded test flow. - **"Aria snapshot" Tab**: The "Aria snapshot" tab within the code generator interface visually represents the aria snapshot for a selected locator, letting you explore, inspect, and verify element roles, attributes, and accessible names to aid snapshot creation and review. -### 2. Updating snapshots with `@playwright/test` and the `--update-snapshots` flag +### Using the `Locator.ariaSnapshot` method -When using the Playwright test runner (`@playwright/test`), you can automatically update snapshots by running tests with the `--update-snapshots` flag: - -```bash -npx playwright test --update-snapshots -``` - -This command regenerates snapshots for assertions, including aria snapshots, replacing outdated ones. It’s useful when application structure changes require new snapshots as a baseline. Note that Playwright will wait for the maximum expect timeout specified in the test runner configuration to ensure the page is settled before taking the snapshot. It might be necessary to adjust the `--timeout` if the test hits the timeout while generating snapshots. - -#### Empty template for snapshot generation - -Passing an empty string as the template in an assertion generates a snapshot on-the-fly: - -Note that Playwright will wait for the maximum expect timeout specified in the test runner configuration to ensure the page is settled before taking the snapshot. It might be necessary to adjust the `--timeout` if the test hits the timeout while generating snapshots. - -#### Snapshot patch files - -When updating snapshots, Playwright creates patch files that capture differences. These patch files can be reviewed, applied, and committed to source control, allowing teams to track structural changes over time and ensure updates are consistent with application requirements. - -### 3. Using the `Locator.ariaSnapshot` method - -The [Locator.ariaSnapshot()](/api/class-locator.mdx#locator-aria-snapshot) method allows you to programmatically create a YAML representation of accessible elements within a locator’s scope, especially helpful for generating snapshots dynamically during test execution. +The [Locator.ariaSnapshot()](/api/class-locator.mdx#locator-aria-snapshot) method allows you to programmatically create a YAML representation of accessible elements within a locator's scope, especially helpful for generating snapshots dynamically during test execution. **Example**: @@ -217,7 +197,7 @@ String snapshot = page.locator("body").ariaSnapshot(); System.out.println(snapshot); ``` -This command outputs the aria snapshot within the specified locator’s scope in YAML format, which you can validate or store as needed. +This command outputs the aria snapshot within the specified locator's scope in YAML format, which you can validate or store as needed. ## Accessibility tree examples diff --git a/java/docs/release-notes.mdx b/java/docs/release-notes.mdx index a081b7480f9..9a10ba23947 100644 --- a/java/docs/release-notes.mdx +++ b/java/docs/release-notes.mdx @@ -11,7 +11,7 @@ import HTMLCard from '@site/src/components/HTMLCard'; ### Aria snapshots -New assertion [assertThat(locator).matchesAriaSnapshot()](/api/class-locatorassertions.mdx#locator-assertions-to-match-aria-snapshot-1) verifies page structure by comparing to an expected accessibility tree, represented as YAML. +New assertion [assertThat(locator).matchesAriaSnapshot()](/api/class-locatorassertions.mdx#locator-assertions-to-match-aria-snapshot) verifies page structure by comparing to an expected accessibility tree, represented as YAML. ```java page.navigate("https://playwright.dev"); diff --git a/nodejs/docs/api/class-browsertype.mdx b/nodejs/docs/api/class-browsertype.mdx index b96ebeae216..670cc3a42fc 100644 --- a/nodejs/docs/api/class-browsertype.mdx +++ b/nodejs/docs/api/class-browsertype.mdx @@ -30,7 +30,12 @@ const { chromium } = require('playwright'); // Or 'firefox' or 'webkit'. Added before v1.9browserType.connect -This method attaches Playwright to an existing browser instance. When connecting to another browser launched via `BrowserType.launchServer` in Node.js, the major and minor version needs to match the client version (1.2.3 → is compatible with 1.2.x). +This method attaches Playwright to an existing browser instance created via [browserType.launchServer()](/api/class-browsertype.mdx#browser-type-launch-server). + +:::note + +The major and minor version of the Playwright instance that connects needs to match the version of Playwright that launches the browser (1.2.3 → is compatible with 1.2.x). +::: **Usage** @@ -42,7 +47,7 @@ await browserType.connect(wsEndpoint, options); **Arguments** - `wsEndpoint` [string] Added in: v1.10# - A browser websocket endpoint to connect to. + A Playwright browser websocket endpoint to connect to. You obtain this endpoint via [browserServer.wsEndpoint()](/api/class-browserserver.mdx#browser-server-ws-endpoint). - `options` [Object] *(optional)* - `exposeNetwork` [string] *(optional)* Added in: v1.37# @@ -88,6 +93,10 @@ The default browser context is accessible via [browser.contexts()](/api/class-br Connecting over the Chrome DevTools Protocol is only supported for Chromium-based browsers. ::: +:::note +This connection is significantly lower fidelity than the Playwright protocol connection via [browserType.connect()](/api/class-browsertype.mdx#browser-type-connect). If you are experiencing issues or attempting to use advanced functionality, you probably want to use [browserType.connect()](/api/class-browsertype.mdx#browser-type-connect). +::: + **Usage** ```js diff --git a/nodejs/docs/api/class-locator.mdx b/nodejs/docs/api/class-locator.mdx index 55ebc565219..2a5a9496705 100644 --- a/nodejs/docs/api/class-locator.mdx +++ b/nodejs/docs/api/class-locator.mdx @@ -115,7 +115,7 @@ const button = page.getByRole('button').and(page.getByTitle('Subscribe')); Added in: v1.49locator.ariaSnapshot -Captures the aria snapshot of the given element. Read more about [aria snapshots](../aria-snapshots.mdx) and [expect(locator).toMatchAriaSnapshot()](/api/class-locatorassertions.mdx#locator-assertions-to-match-aria-snapshot-1) for the corresponding assertion. +Captures the aria snapshot of the given element. Read more about [aria snapshots](../aria-snapshots.mdx) and [expect(locator).toMatchAriaSnapshot()](/api/class-locatorassertions.mdx#locator-assertions-to-match-aria-snapshot) for the corresponding assertion. **Usage** diff --git a/nodejs/docs/api/class-locatorassertions.mdx b/nodejs/docs/api/class-locatorassertions.mdx index baec3e7feef..f74b89731bf 100644 --- a/nodejs/docs/api/class-locatorassertions.mdx +++ b/nodejs/docs/api/class-locatorassertions.mdx @@ -963,7 +963,7 @@ await expect(locator).toHaveValues([/R/, /G/]); --- -### toMatchAriaSnapshot(expected) {#locator-assertions-to-match-aria-snapshot-1} +### toMatchAriaSnapshot(expected) {#locator-assertions-to-match-aria-snapshot} Added in: v1.49locatorAssertions.toMatchAriaSnapshot(expected) @@ -980,14 +980,14 @@ await expect(page.locator('body')).toMatchAriaSnapshot(` ``` **Arguments** -- `expected` [string]# +- `expected` [string]# - `options` [Object] *(optional)* - - `timeout` [number] *(optional)*# + - `timeout` [number] *(optional)*# Time to retry the assertion for in milliseconds. Defaults to `timeout` in `TestConfig.expect`. **Returns** -- [Promise]<[void]># +- [Promise]<[void]># --- diff --git a/nodejs/docs/aria-snapshots.mdx b/nodejs/docs/aria-snapshots.mdx index 7753c44e48b..8d302dd7712 100644 --- a/nodejs/docs/aria-snapshots.mdx +++ b/nodejs/docs/aria-snapshots.mdx @@ -10,7 +10,7 @@ import LiteYouTube from '@site/src/components/LiteYouTube'; ## Overview -With the Playwright Snapshot testing you can assert the accessibility tree of a page against a predefined snapshot template. +With Playwright's Snapshot testing you can assert the accessibility tree of a page against a predefined snapshot template. ```js await page.goto('https://playwright.dev/'); @@ -31,11 +31,11 @@ Snapshot testing and assertion testing serve different purposes in test automati ### Assertion testing -Assertion testing is a targeted approach where you assert specific values or conditions about elements or components. For instance, with Playwright, [expect(locator).toHaveText()](/api/class-locatorassertions.mdx#locator-assertions-to-have-text) verifies that an element contains the expected text, and [expect(locator).toHaveValue()](/api/class-locatorassertions.mdx#locator-assertions-to-have-value) confirms that an input field has the expected value. Assertion tests are specific and generally check the current state of an element or property against an expected, predefined state. They work well for predictable, single-value checks but are limited in scope when testing the broader structure or variations. +Assertion testing is a targeted approach where you assert specific values or conditions about elements or components. For instance, with Playwright, [expect(locator).toHaveText()](/api/class-locatorassertions.mdx#locator-assertions-to-have-text) verifies that an element contains the expected text, and [expect(locator).toHaveValue()](/api/class-locatorassertions.mdx#locator-assertions-to-have-value) confirms that an input field has the expected value. Assertion tests are specific and generally check the current state of an element or property against an expected, predefined state. They work well for predictable, single-value checks but are limited in scope when testing the broader structure or variations. **Advantages** - **Clarity**: The intent of the test is explicit and easy to understand. -- **Specificity**: Tests focus on particular aspects of functionality, making them more robust against unrelated changes. +- **Specificity**: Tests focus on particular aspects of functionality, making them more robust against unrelated changes. - **Debugging**: Failures provide targeted feedback, pointing directly to the problematic aspect. **Disadvantages** @@ -88,7 +88,7 @@ These values are derived from ARIA attributes or calculated based on HTML semant ## Snapshot matching -The [expect(locator).toMatchAriaSnapshot()](/api/class-locatorassertions.mdx#locator-assertions-to-match-aria-snapshot-1) assertion method in Playwright compares the accessible structure of the locator scope with a predefined aria snapshot template, helping validate the page's state against testing requirements. +The [expect(locator).toMatchAriaSnapshot()](/api/class-locatorassertions.mdx#locator-assertions-to-match-aria-snapshot) assertion method in Playwright compares the accessible structure of the locator scope with a predefined aria snapshot template, helping validate the page's state against testing requirements. For the following DOM: @@ -123,7 +123,7 @@ You can perform partial matches on nodes by omitting attributes or accessible na - button ``` -In this example, the button role is matched, but the accessible name ("Submit") is not specified, allowing the test to pass regardless of the button’s label. +In this example, the button role is matched, but the accessible name ("Submit") is not specified, allowing the test to pass regardless of the button's label.
@@ -178,23 +178,25 @@ Regular expressions allow flexible matching for elements with dynamic or variabl ## Generating snapshots -Creating aria snapshots in Playwright helps ensure and maintain your application’s structure. You can generate snapshots in various ways depending on your testing setup and workflow. +Creating aria snapshots in Playwright helps ensure and maintain your application's structure. You can generate snapshots in various ways depending on your testing setup and workflow. -### 1. Generating snapshots with the Playwright code generator +### Generating snapshots with the Playwright code generator -If you’re using Playwright’s [Code Generator](./codegen.mdx), generating aria snapshots is streamlined with its interactive interface: +If you're using Playwright's [Code Generator](./codegen.mdx), generating aria snapshots is streamlined with its interactive interface: - **"Assert snapshot" Action**: In the code generator, you can use the "Assert snapshot" action to automatically create a snapshot assertion for the selected elements. This is a quick way to capture the aria snapshot as part of your recorded test flow. - **"Aria snapshot" Tab**: The "Aria snapshot" tab within the code generator interface visually represents the aria snapshot for a selected locator, letting you explore, inspect, and verify element roles, attributes, and accessible names to aid snapshot creation and review. -### 2. Updating snapshots with `@playwright/test` and the `--update-snapshots` flag +### Updating snapshots with `@playwright/test` and the `--update-snapshots` flag -When using the Playwright test runner (`@playwright/test`), you can automatically update snapshots by running tests with the `--update-snapshots` flag: +When using the Playwright test runner (`@playwright/test`), you can automatically update snapshots with the `--update-snapshots` flag, `-u` for short. + +Running tests with the `--update-snapshots` flag will update snapshots that did not match. Matching snapshots will not be updated. ```bash npx playwright test --update-snapshots ``` -This command regenerates snapshots for assertions, including aria snapshots, replacing outdated ones. It’s useful when application structure changes require new snapshots as a baseline. Note that Playwright will wait for the maximum expect timeout specified in the test runner configuration to ensure the page is settled before taking the snapshot. It might be necessary to adjust the `--timeout` if the test hits the timeout while generating snapshots. +Updating snapshots is useful when application structure changes require new snapshots as a baseline. Note that Playwright will wait for the maximum expect timeout specified in the test runner configuration to ensure the page is settled before taking the snapshot. It might be necessary to adjust the `--timeout` if the test hits the timeout while generating snapshots. #### Empty template for snapshot generation @@ -210,9 +212,38 @@ Note that Playwright will wait for the maximum expect timeout specified in the t When updating snapshots, Playwright creates patch files that capture differences. These patch files can be reviewed, applied, and committed to source control, allowing teams to track structural changes over time and ensure updates are consistent with application requirements. -### 3. Using the `Locator.ariaSnapshot` method +The way source code is updated can be changed using the `--update-source-method` flag. There are several options available: +- **"patch"** (default): Generates a unified diff file that can be applied to the source code using `git apply`. +- **"3way"**: Generates merge conflict markers in your source code, allowing you to choose whether to accept changes. +- **"overwrite"**: Overwrites the source code with the new snapshot values. + +```bash +npx playwright test --update-snapshots --update-source-mode=3way +``` + +#### Snapshots as separate files + +To store your snapshots in a separate file, use the `toMatchAriaSnapshot` method with the `name` option, specifying a `.yml` file extension. + +```js +await expect(page.getByRole('main')).toMatchAriaSnapshot({ name: 'main-snapshot.yml' }); +``` + +By default, snapshots from a test file `example.spec.ts` are placed in the `example.spec.ts-snapshots` directory. As snapshots should be the same across browsers, only one snapshot is saved even if testing with multiple browsers. Should you wish, you can customize the [snapshot path template](./api/class-testconfig#test-config-snapshot-path-template) using the following configuration: + +```js +export default defineConfig({ + expect: { + toMatchAriaSnapshot: { + pathTemplate: '__snapshots__/{testFilePath}/{arg}{ext}', + }, + }, +}); +``` + +### Using the `Locator.ariaSnapshot` method -The [locator.ariaSnapshot()](/api/class-locator.mdx#locator-aria-snapshot) method allows you to programmatically create a YAML representation of accessible elements within a locator’s scope, especially helpful for generating snapshots dynamically during test execution. +The [locator.ariaSnapshot()](/api/class-locator.mdx#locator-aria-snapshot) method allows you to programmatically create a YAML representation of accessible elements within a locator's scope, especially helpful for generating snapshots dynamically during test execution. **Example**: @@ -221,7 +252,7 @@ const snapshot = await page.locator('body').ariaSnapshot(); console.log(snapshot); ``` -This command outputs the aria snapshot within the specified locator’s scope in YAML format, which you can validate or store as needed. +This command outputs the aria snapshot within the specified locator's scope in YAML format, which you can validate or store as needed. ## Accessibility tree examples diff --git a/nodejs/docs/release-notes.mdx b/nodejs/docs/release-notes.mdx index f2712ab1b28..cc2558f7371 100644 --- a/nodejs/docs/release-notes.mdx +++ b/nodejs/docs/release-notes.mdx @@ -79,7 +79,7 @@ This version was also tested against the following stable channels: ### Aria snapshots -New assertion [expect(locator).toMatchAriaSnapshot()](/api/class-locatorassertions.mdx#locator-assertions-to-match-aria-snapshot-1) verifies page structure by comparing to an expected accessibility tree, represented as YAML. +New assertion [expect(locator).toMatchAriaSnapshot()](/api/class-locatorassertions.mdx#locator-assertions-to-match-aria-snapshot) verifies page structure by comparing to an expected accessibility tree, represented as YAML. ```js await page.goto('https://playwright.dev'); diff --git a/nodejs/docs/test-cli.mdx b/nodejs/docs/test-cli.mdx index 6dec5cc60ed..61f71e95ec6 100644 --- a/nodejs/docs/test-cli.mdx +++ b/nodejs/docs/test-cli.mdx @@ -125,7 +125,7 @@ Complete set of Playwright Test options is available in the [configuration file] | `--ui` | Run tests in interactive UI mode. | | `--ui-host ` | Host to serve UI on; specifying this option opens UI in a browser tab. | | `--ui-port ` | Port to serve UI on, 0 for any free port; specifying this option opens UI in a browser tab. | -| `-u` or `--update-snapshots [mode]` | Update snapshots with actual results. Possible values are "all", "changed", "missing", and "none". Not passing defaults to "missing"; passing without a value defaults to "changed". | +| `-u` or `--update-snapshots [mode]` | Update snapshots with actual results. Possible values are "all", "changed", "missing", and "none". Running tests without the flag defaults to "missing"; running tests with the flag but without a value defaults to "changed". | | `--update-source-method [mode]` | Update snapshots with actual results. Possible values are "patch" (default), "3way" and "overwrite". "Patch" creates a unified diff file that can be used to update the source code later. "3way" generates merge conflict markers in source code. "Overwrite" overwrites the source code with the new snapshot values.| | `-j ` or `--workers ` | Number of concurrent workers or percentage of logical CPU cores, use 1 to run in a single worker (default: 50%). | | `-x` | Stop after the first failure. | diff --git a/python/docs/api/class-browsertype.mdx b/python/docs/api/class-browsertype.mdx index 765bebf03be..eecd232db65 100644 --- a/python/docs/api/class-browsertype.mdx +++ b/python/docs/api/class-browsertype.mdx @@ -67,42 +67,19 @@ asyncio.run(main()) Added before v1.9browserType.connect -This method attaches Playwright to an existing browser instance. When connecting to another browser launched via `BrowserType.launchServer` in Node.js, the major and minor version needs to match the client version (1.2.3 → is compatible with 1.2.x). +This method attaches Playwright to an existing browser instance created via `BrowserType.launchServer` in Node.js. + +:::note + +The major and minor version of the Playwright instance that connects needs to match the version of Playwright that launches the browser (1.2.3 → is compatible with 1.2.x). +::: **Usage** ```python -browser_type.connect(ws_endpoint) -browser_type.connect(ws_endpoint, **kwargs) +browser_type.connect() ``` -**Arguments** -- `ws_endpoint` [str] Added in: v1.10# - - A browser websocket endpoint to connect to. -- `expose_network` [str] *(optional)* Added in: v1.37# - - This option exposes network available on the connecting client to the browser being connected to. Consists of a list of rules separated by comma. - - Available rules: - 1. Hostname pattern, for example: `example.com`, `*.org:99`, `x.*.y.com`, `*foo.org`. - 1. IP literal, for example: `127.0.0.1`, `0.0.0.0:99`, `[::1]`, `[0:0::1]:99`. - 1. `` that matches local loopback interfaces: `localhost`, `*.localhost`, `127.0.0.1`, `[::1]`. - - Some common examples: - 1. `"*"` to expose all network. - 1. `""` to expose localhost network. - 1. `"*.test.internal-domain,*.staging.internal-domain,"` to expose test/staging deployments and localhost. -- `headers` [Dict]\[[str], [str]\] *(optional)* Added in: v1.11# - - Additional HTTP headers to be sent with web socket connect request. Optional. -- `slow_mo` [float] *(optional)* Added in: v1.10# - - Slows down Playwright operations by the specified amount of milliseconds. Useful so that you can see what is going on. Defaults to 0. -- `timeout` [float] *(optional)* Added in: v1.10# - - Maximum time in milliseconds to wait for the connection to be established. Defaults to `0` (no timeout). - **Returns** - [Browser]# @@ -121,6 +98,10 @@ The default browser context is accessible via [browser.contexts](/api/class-brow Connecting over the Chrome DevTools Protocol is only supported for Chromium-based browsers. ::: +:::note +This connection is significantly lower fidelity than the Playwright protocol connection via [browser_type.connect()](/api/class-browsertype.mdx#browser-type-connect). If you are experiencing issues or attempting to use advanced functionality, you probably want to use [browser_type.connect()](/api/class-browsertype.mdx#browser-type-connect). +::: + **Usage** Added in: v1.49locator.aria_snapshot -Captures the aria snapshot of the given element. Read more about [aria snapshots](../aria-snapshots.mdx) and [expect(locator).to_match_aria_snapshot()](/api/class-locatorassertions.mdx#locator-assertions-to-match-aria-snapshot-1) for the corresponding assertion. +Captures the aria snapshot of the given element. Read more about [aria snapshots](../aria-snapshots.mdx) and [expect(locator).to_match_aria_snapshot()](/api/class-locatorassertions.mdx#locator-assertions-to-match-aria-snapshot) for the corresponding assertion. **Usage** diff --git a/python/docs/api/class-locatorassertions.mdx b/python/docs/api/class-locatorassertions.mdx index c8cdb2ebb23..581d7389a77 100644 --- a/python/docs/api/class-locatorassertions.mdx +++ b/python/docs/api/class-locatorassertions.mdx @@ -344,6 +344,35 @@ expect(locator).not_to_have_accessible_description(name, **kwargs) --- +### not_to_have_accessible_error_message {#locator-assertions-not-to-have-accessible-error-message} + +Added in: v1.50locatorAssertions.not_to_have_accessible_error_message + +The opposite of [expect(locator).to_have_accessible_error_message()](/api/class-locatorassertions.mdx#locator-assertions-to-have-accessible-error-message). + +**Usage** + +```python +expect(locator).not_to_have_accessible_error_message(error_message) +expect(locator).not_to_have_accessible_error_message(error_message, **kwargs) +``` + +**Arguments** +- `error_message` [str] | [Pattern]# + + Expected accessible error message. +- `ignore_case` [bool] *(optional)*# + + Whether to perform case-insensitive match. [ignore_case](/api/class-locatorassertions.mdx#locator-assertions-not-to-have-accessible-error-message-option-ignore-case) option takes precedence over the corresponding regular expression flag if specified. +- `timeout` [float] *(optional)*# + + Time to retry the assertion for in milliseconds. Defaults to `5000`. + +**Returns** +- [NoneType]# + +--- + ### not_to_have_accessible_name {#locator-assertions-not-to-have-accessible-name} Added in: v1.44locatorAssertions.not_to_have_accessible_name @@ -655,7 +684,7 @@ expect(locator).not_to_have_values(values, **kwargs) Added in: v1.49locatorAssertions.not_to_match_aria_snapshot -The opposite of [expect(locator).to_match_aria_snapshot()](/api/class-locatorassertions.mdx#locator-assertions-to-match-aria-snapshot-1). +The opposite of [expect(locator).to_match_aria_snapshot()](/api/class-locatorassertions.mdx#locator-assertions-to-match-aria-snapshot). **Usage** @@ -2124,7 +2153,7 @@ await expect(locator).to_have_values([re.compile(r"R"), re.compile(r"G")]) --- -### to_match_aria_snapshot {#locator-assertions-to-match-aria-snapshot-1} +### to_match_aria_snapshot {#locator-assertions-to-match-aria-snapshot} Added in: v1.49locatorAssertions.to_match_aria_snapshot @@ -2165,13 +2194,13 @@ await expect(page.locator('body')).to_match_aria_snapshot(''' **Arguments** -- `expected` [str]# -- `timeout` [float] *(optional)*# +- `expected` [str]# +- `timeout` [float] *(optional)*# Time to retry the assertion for in milliseconds. Defaults to `5000`. **Returns** -- [NoneType]# +- [NoneType]# [Accessibility]: /api/class-accessibility.mdx "Accessibility" diff --git a/python/docs/aria-snapshots.mdx b/python/docs/aria-snapshots.mdx index b8f73d0293b..988626da702 100644 --- a/python/docs/aria-snapshots.mdx +++ b/python/docs/aria-snapshots.mdx @@ -10,7 +10,7 @@ import LiteYouTube from '@site/src/components/LiteYouTube'; ## Overview -With the Playwright Snapshot testing you can assert the accessibility tree of a page against a predefined snapshot template. +With Playwright's Snapshot testing you can assert the accessibility tree of a page against a predefined snapshot template. @@ -227,37 +227,17 @@ Regular expressions allow flexible matching for elements with dynamic or variabl ## Generating snapshots -Creating aria snapshots in Playwright helps ensure and maintain your application’s structure. You can generate snapshots in various ways depending on your testing setup and workflow. +Creating aria snapshots in Playwright helps ensure and maintain your application's structure. You can generate snapshots in various ways depending on your testing setup and workflow. -### 1. Generating snapshots with the Playwright code generator +### Generating snapshots with the Playwright code generator -If you’re using Playwright’s [Code Generator](./codegen.mdx), generating aria snapshots is streamlined with its interactive interface: +If you're using Playwright's [Code Generator](./codegen.mdx), generating aria snapshots is streamlined with its interactive interface: - **"Assert snapshot" Action**: In the code generator, you can use the "Assert snapshot" action to automatically create a snapshot assertion for the selected elements. This is a quick way to capture the aria snapshot as part of your recorded test flow. - **"Aria snapshot" Tab**: The "Aria snapshot" tab within the code generator interface visually represents the aria snapshot for a selected locator, letting you explore, inspect, and verify element roles, attributes, and accessible names to aid snapshot creation and review. -### 2. Updating snapshots with `@playwright/test` and the `--update-snapshots` flag +### Using the `Locator.ariaSnapshot` method -When using the Playwright test runner (`@playwright/test`), you can automatically update snapshots by running tests with the `--update-snapshots` flag: - -```bash -npx playwright test --update-snapshots -``` - -This command regenerates snapshots for assertions, including aria snapshots, replacing outdated ones. It’s useful when application structure changes require new snapshots as a baseline. Note that Playwright will wait for the maximum expect timeout specified in the test runner configuration to ensure the page is settled before taking the snapshot. It might be necessary to adjust the `--timeout` if the test hits the timeout while generating snapshots. - -#### Empty template for snapshot generation - -Passing an empty string as the template in an assertion generates a snapshot on-the-fly: - -Note that Playwright will wait for the maximum expect timeout specified in the test runner configuration to ensure the page is settled before taking the snapshot. It might be necessary to adjust the `--timeout` if the test hits the timeout while generating snapshots. - -#### Snapshot patch files - -When updating snapshots, Playwright creates patch files that capture differences. These patch files can be reviewed, applied, and committed to source control, allowing teams to track structural changes over time and ensure updates are consistent with application requirements. - -### 3. Using the `Locator.ariaSnapshot` method - -The [locator.aria_snapshot()](/api/class-locator.mdx#locator-aria-snapshot) method allows you to programmatically create a YAML representation of accessible elements within a locator’s scope, especially helpful for generating snapshots dynamically during test execution. +The [locator.aria_snapshot()](/api/class-locator.mdx#locator-aria-snapshot) method allows you to programmatically create a YAML representation of accessible elements within a locator's scope, especially helpful for generating snapshots dynamically during test execution. **Example**: @@ -287,7 +267,7 @@ print(snapshot) -This command outputs the aria snapshot within the specified locator’s scope in YAML format, which you can validate or store as needed. +This command outputs the aria snapshot within the specified locator's scope in YAML format, which you can validate or store as needed. ## Accessibility tree examples diff --git a/python/docs/release-notes.mdx b/python/docs/release-notes.mdx index bb13197cc37..67a2d953de8 100644 --- a/python/docs/release-notes.mdx +++ b/python/docs/release-notes.mdx @@ -11,7 +11,7 @@ import HTMLCard from '@site/src/components/HTMLCard'; ### Aria snapshots -New assertion [expect(locator).to_match_aria_snapshot()](/api/class-locatorassertions.mdx#locator-assertions-to-match-aria-snapshot-1) verifies page structure by comparing to an expected accessibility tree, represented as YAML. +New assertion [expect(locator).to_match_aria_snapshot()](/api/class-locatorassertions.mdx#locator-assertions-to-match-aria-snapshot) verifies page structure by comparing to an expected accessibility tree, represented as YAML. ```python page.goto("https://playwright.dev") diff --git a/python/docs/test-runners.mdx b/python/docs/test-runners.mdx index c76130cdc6e..dfbe5818436 100644 --- a/python/docs/test-runners.mdx +++ b/python/docs/test-runners.mdx @@ -257,7 +257,7 @@ See the [guides for CI providers](./ci.mdx) to deploy your tests to CI/CD. ## Async Fixtures -If you want to use async fixtures, you can use the [`pytest-playwright-asyncio`](https://pypi.org/project/pytest-playwright-asyncio/) plugin. Make sure to use `pytest-asyncio>=0.24.0` and make your tests use of [`loop_scope=sesion`](https://pytest-asyncio.readthedocs.io/en/latest/how-to-guides/run_session_tests_in_same_loop.html). +If you want to use async fixtures, you can use the [`pytest-playwright-asyncio`](https://pypi.org/project/pytest-playwright-asyncio/) plugin. Make sure to use `pytest-asyncio>=0.24.0` and make your tests use of [`loop_scope=session`](https://pytest-asyncio.readthedocs.io/en/latest/how-to-guides/run_session_tests_in_same_loop.html). ```python import pytest