docs: improve aria overload docs (#34319)
This commit is contained in:
parent
ad365c3bc3
commit
b0f0a2951a
|
@ -155,7 +155,7 @@ Additional locator to match.
|
||||||
- returns: <[string]>
|
- returns: <[string]>
|
||||||
|
|
||||||
Captures the aria snapshot of the given element.
|
Captures the aria snapshot of the given element.
|
||||||
Read more about [aria snapshots](../aria-snapshots.md) and [`method: LocatorAssertions.toMatchAriaSnapshot#2`] for the corresponding assertion.
|
Read more about [aria snapshots](../aria-snapshots.md) and [`method: LocatorAssertions.toMatchAriaSnapshot#1`] for the corresponding assertion.
|
||||||
|
|
||||||
**Usage**
|
**Usage**
|
||||||
|
|
||||||
|
|
|
@ -446,7 +446,7 @@ Expected options currently selected.
|
||||||
* since: v1.49
|
* since: v1.49
|
||||||
* langs: python
|
* langs: python
|
||||||
|
|
||||||
The opposite of [`method: LocatorAssertions.toMatchAriaSnapshot#2`].
|
The opposite of [`method: LocatorAssertions.toMatchAriaSnapshot#1`].
|
||||||
|
|
||||||
### param: LocatorAssertions.NotToMatchAriaSnapshot.expected
|
### param: LocatorAssertions.NotToMatchAriaSnapshot.expected
|
||||||
* since: v1.49
|
* since: v1.49
|
||||||
|
@ -2182,57 +2182,6 @@ Expected options currently selected.
|
||||||
|
|
||||||
|
|
||||||
## async method: LocatorAssertions.toMatchAriaSnapshot#1
|
## async method: LocatorAssertions.toMatchAriaSnapshot#1
|
||||||
* since: v1.50
|
|
||||||
* langs:
|
|
||||||
- alias-java: matchesAriaSnapshot
|
|
||||||
|
|
||||||
Asserts that the target element matches the given [accessibility snapshot](../aria-snapshots.md).
|
|
||||||
|
|
||||||
**Usage**
|
|
||||||
|
|
||||||
```js
|
|
||||||
await expect(page.locator('body')).toMatchAriaSnapshot();
|
|
||||||
await expect(page.locator('body')).toMatchAriaSnapshot({ name: 'snapshot' });
|
|
||||||
await expect(page.locator('body')).toMatchAriaSnapshot({ path: '/path/to/snapshot.yml' });
|
|
||||||
```
|
|
||||||
|
|
||||||
```python async
|
|
||||||
await expect(page.locator('body')).to_match_aria_snapshot(path='/path/to/snapshot.yml')
|
|
||||||
```
|
|
||||||
|
|
||||||
```python sync
|
|
||||||
expect(page.locator('body')).to_match_aria_snapshot(path='/path/to/snapshot.yml')
|
|
||||||
```
|
|
||||||
|
|
||||||
```csharp
|
|
||||||
await Expect(page.Locator("body")).ToMatchAriaSnapshotAsync(new { Path = "/path/to/snapshot.yml" });
|
|
||||||
```
|
|
||||||
|
|
||||||
```java
|
|
||||||
assertThat(page.locator("body")).matchesAriaSnapshot(new LocatorAssertions.MatchesAriaSnapshotOptions().setPath("/path/to/snapshot.yml"));
|
|
||||||
```
|
|
||||||
|
|
||||||
### option: LocatorAssertions.toMatchAriaSnapshot#1.name
|
|
||||||
* since: v1.50
|
|
||||||
* langs: js
|
|
||||||
- `name` <[string]>
|
|
||||||
|
|
||||||
Name of the snapshot to store in the snapshot folder corresponding to this test. Generates ordinal name if not specified.
|
|
||||||
|
|
||||||
### option: LocatorAssertions.toMatchAriaSnapshot#1.path
|
|
||||||
* since: v1.50
|
|
||||||
- `path` <[string]>
|
|
||||||
|
|
||||||
Path to the YAML snapshot file.
|
|
||||||
|
|
||||||
### option: LocatorAssertions.toMatchAriaSnapshot#1.timeout = %%-js-assertions-timeout-%%
|
|
||||||
* since: v1.50
|
|
||||||
|
|
||||||
### option: LocatorAssertions.toMatchAriaSnapshot#1.timeout = %%-csharp-java-python-assertions-timeout-%%
|
|
||||||
* since: v1.50
|
|
||||||
|
|
||||||
|
|
||||||
## async method: LocatorAssertions.toMatchAriaSnapshot#2
|
|
||||||
* since: v1.49
|
* since: v1.49
|
||||||
* langs:
|
* langs:
|
||||||
- alias-java: matchesAriaSnapshot
|
- alias-java: matchesAriaSnapshot
|
||||||
|
@ -2281,12 +2230,62 @@ assertThat(page.locator("body")).matchesAriaSnapshot("""
|
||||||
""");
|
""");
|
||||||
```
|
```
|
||||||
|
|
||||||
### param: LocatorAssertions.toMatchAriaSnapshot#2.expected
|
### param: LocatorAssertions.toMatchAriaSnapshot#1.expected
|
||||||
* since: v1.49
|
* since: v1.49
|
||||||
- `expected` <string>
|
- `expected` <string>
|
||||||
|
|
||||||
### option: LocatorAssertions.toMatchAriaSnapshot#2.timeout = %%-js-assertions-timeout-%%
|
### option: LocatorAssertions.toMatchAriaSnapshot#1.timeout = %%-js-assertions-timeout-%%
|
||||||
* since: v1.49
|
* since: v1.49
|
||||||
|
|
||||||
### option: LocatorAssertions.toMatchAriaSnapshot#2.timeout = %%-csharp-java-python-assertions-timeout-%%
|
### option: LocatorAssertions.toMatchAriaSnapshot#1.timeout = %%-csharp-java-python-assertions-timeout-%%
|
||||||
* since: v1.49
|
* since: v1.49
|
||||||
|
|
||||||
|
## async method: LocatorAssertions.toMatchAriaSnapshot#2
|
||||||
|
* since: v1.50
|
||||||
|
* langs:
|
||||||
|
- alias-java: matchesAriaSnapshot
|
||||||
|
|
||||||
|
Asserts that the target element matches the given [accessibility snapshot](../aria-snapshots.md).
|
||||||
|
|
||||||
|
**Usage**
|
||||||
|
|
||||||
|
```js
|
||||||
|
await expect(page.locator('body')).toMatchAriaSnapshot();
|
||||||
|
await expect(page.locator('body')).toMatchAriaSnapshot({ name: 'snapshot' });
|
||||||
|
await expect(page.locator('body')).toMatchAriaSnapshot({ path: '/path/to/snapshot.yml' });
|
||||||
|
```
|
||||||
|
|
||||||
|
```python async
|
||||||
|
await expect(page.locator('body')).to_match_aria_snapshot(path='/path/to/snapshot.yml')
|
||||||
|
```
|
||||||
|
|
||||||
|
```python sync
|
||||||
|
expect(page.locator('body')).to_match_aria_snapshot(path='/path/to/snapshot.yml')
|
||||||
|
```
|
||||||
|
|
||||||
|
```csharp
|
||||||
|
await Expect(page.Locator("body")).ToMatchAriaSnapshotAsync(new { Path = "/path/to/snapshot.yml" });
|
||||||
|
```
|
||||||
|
|
||||||
|
```java
|
||||||
|
assertThat(page.locator("body")).matchesAriaSnapshot(new LocatorAssertions.MatchesAriaSnapshotOptions().setPath("/path/to/snapshot.yml"));
|
||||||
|
```
|
||||||
|
|
||||||
|
### option: LocatorAssertions.toMatchAriaSnapshot#2.name
|
||||||
|
* since: v1.50
|
||||||
|
* langs: js
|
||||||
|
- `name` <[string]>
|
||||||
|
|
||||||
|
Name of the snapshot to store in the snapshot folder corresponding to this test. Generates ordinal name if not specified.
|
||||||
|
|
||||||
|
### option: LocatorAssertions.toMatchAriaSnapshot#2.path
|
||||||
|
* since: v1.50
|
||||||
|
- `path` <[string]>
|
||||||
|
|
||||||
|
Path to the YAML snapshot file.
|
||||||
|
|
||||||
|
### option: LocatorAssertions.toMatchAriaSnapshot#2.timeout = %%-js-assertions-timeout-%%
|
||||||
|
* since: v1.50
|
||||||
|
|
||||||
|
### option: LocatorAssertions.toMatchAriaSnapshot#2.timeout = %%-csharp-java-python-assertions-timeout-%%
|
||||||
|
* since: v1.50
|
||||||
|
|
|
@ -154,7 +154,7 @@ structure of a page, use the [Chrome DevTools Accessibility Pane](https://develo
|
||||||
|
|
||||||
## Snapshot matching
|
## Snapshot matching
|
||||||
|
|
||||||
The [`method: LocatorAssertions.toMatchAriaSnapshot#2`] assertion method in Playwright compares the accessible
|
The [`method: LocatorAssertions.toMatchAriaSnapshot#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
|
structure of the locator scope with a predefined aria snapshot template, helping validate the page's state against
|
||||||
testing requirements.
|
testing requirements.
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@ toc_max_heading_level: 2
|
||||||
|
|
||||||
### Aria snapshots
|
### Aria snapshots
|
||||||
|
|
||||||
New assertion [`method: LocatorAssertions.toMatchAriaSnapshot#2`] verifies page structure by comparing to an expected accessibility tree, represented as YAML.
|
New assertion [`method: LocatorAssertions.toMatchAriaSnapshot#1`] verifies page structure by comparing to an expected accessibility tree, represented as YAML.
|
||||||
|
|
||||||
```csharp
|
```csharp
|
||||||
await page.GotoAsync("https://playwright.dev");
|
await page.GotoAsync("https://playwright.dev");
|
||||||
|
|
|
@ -8,7 +8,7 @@ toc_max_heading_level: 2
|
||||||
|
|
||||||
### Aria snapshots
|
### Aria snapshots
|
||||||
|
|
||||||
New assertion [`method: LocatorAssertions.toMatchAriaSnapshot#2`] verifies page structure by comparing to an expected accessibility tree, represented as YAML.
|
New assertion [`method: LocatorAssertions.toMatchAriaSnapshot#1`] verifies page structure by comparing to an expected accessibility tree, represented as YAML.
|
||||||
|
|
||||||
```java
|
```java
|
||||||
page.navigate("https://playwright.dev");
|
page.navigate("https://playwright.dev");
|
||||||
|
|
|
@ -15,7 +15,7 @@ import LiteYouTube from '@site/src/components/LiteYouTube';
|
||||||
|
|
||||||
### Aria snapshots
|
### Aria snapshots
|
||||||
|
|
||||||
New assertion [`method: LocatorAssertions.toMatchAriaSnapshot#2`] verifies page structure by comparing to an expected accessibility tree, represented as YAML.
|
New assertion [`method: LocatorAssertions.toMatchAriaSnapshot#1`] verifies page structure by comparing to an expected accessibility tree, represented as YAML.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
await page.goto('https://playwright.dev');
|
await page.goto('https://playwright.dev');
|
||||||
|
|
|
@ -8,7 +8,7 @@ toc_max_heading_level: 2
|
||||||
|
|
||||||
### Aria snapshots
|
### Aria snapshots
|
||||||
|
|
||||||
New assertion [`method: LocatorAssertions.toMatchAriaSnapshot#2`] verifies page structure by comparing to an expected accessibility tree, represented as YAML.
|
New assertion [`method: LocatorAssertions.toMatchAriaSnapshot#1`] verifies page structure by comparing to an expected accessibility tree, represented as YAML.
|
||||||
|
|
||||||
```python
|
```python
|
||||||
page.goto("https://playwright.dev")
|
page.goto("https://playwright.dev")
|
||||||
|
|
|
@ -12429,7 +12429,7 @@ export interface Locator {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Captures the aria snapshot of the given element. Read more about [aria snapshots](https://playwright.dev/docs/aria-snapshots) and
|
* Captures the aria snapshot of the given element. Read more about [aria snapshots](https://playwright.dev/docs/aria-snapshots) and
|
||||||
* [expect(locator).toMatchAriaSnapshot(expected[, options])](https://playwright.dev/docs/api/class-locatorassertions#locator-assertions-to-match-aria-snapshot-2)
|
* [expect(locator).toMatchAriaSnapshot(expected[, options])](https://playwright.dev/docs/api/class-locatorassertions#locator-assertions-to-match-aria-snapshot-1)
|
||||||
* for the corresponding assertion.
|
* for the corresponding assertion.
|
||||||
*
|
*
|
||||||
* **Usage**
|
* **Usage**
|
||||||
|
|
|
@ -8682,6 +8682,29 @@ interface LocatorAssertions {
|
||||||
timeout?: number;
|
timeout?: number;
|
||||||
}): Promise<void>;
|
}): Promise<void>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Asserts that the target element matches the given [accessibility snapshot](https://playwright.dev/docs/aria-snapshots).
|
||||||
|
*
|
||||||
|
* **Usage**
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* await page.goto('https://demo.playwright.dev/todomvc/');
|
||||||
|
* await expect(page.locator('body')).toMatchAriaSnapshot(`
|
||||||
|
* - heading "todos"
|
||||||
|
* - textbox "What needs to be done?"
|
||||||
|
* `);
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* @param expected
|
||||||
|
* @param options
|
||||||
|
*/
|
||||||
|
toMatchAriaSnapshot(expected: string, options?: {
|
||||||
|
/**
|
||||||
|
* Time to retry the assertion for in milliseconds. Defaults to `timeout` in `TestConfig.expect`.
|
||||||
|
*/
|
||||||
|
timeout?: number;
|
||||||
|
}): Promise<void>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Asserts that the target element matches the given [accessibility snapshot](https://playwright.dev/docs/aria-snapshots).
|
* Asserts that the target element matches the given [accessibility snapshot](https://playwright.dev/docs/aria-snapshots).
|
||||||
*
|
*
|
||||||
|
@ -8713,29 +8736,6 @@ interface LocatorAssertions {
|
||||||
timeout?: number;
|
timeout?: number;
|
||||||
}): Promise<void>;
|
}): Promise<void>;
|
||||||
|
|
||||||
/**
|
|
||||||
* Asserts that the target element matches the given [accessibility snapshot](https://playwright.dev/docs/aria-snapshots).
|
|
||||||
*
|
|
||||||
* **Usage**
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* await page.goto('https://demo.playwright.dev/todomvc/');
|
|
||||||
* await expect(page.locator('body')).toMatchAriaSnapshot(`
|
|
||||||
* - heading "todos"
|
|
||||||
* - textbox "What needs to be done?"
|
|
||||||
* `);
|
|
||||||
* ```
|
|
||||||
*
|
|
||||||
* @param expected
|
|
||||||
* @param options
|
|
||||||
*/
|
|
||||||
toMatchAriaSnapshot(expected: string, options?: {
|
|
||||||
/**
|
|
||||||
* Time to retry the assertion for in milliseconds. Defaults to `timeout` in `TestConfig.expect`.
|
|
||||||
*/
|
|
||||||
timeout?: number;
|
|
||||||
}): Promise<void>;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Makes the assertion check for the opposite condition. For example, this code tests that the Locator doesn't contain
|
* Makes the assertion check for the opposite condition. For example, this code tests that the Locator doesn't contain
|
||||||
* text `"error"`:
|
* text `"error"`:
|
||||||
|
|
Loading…
Reference in New Issue