Skip to content

Commit

Permalink
feat(roll): roll to ToT Playwright (16-01-25) (#1645)
Browse files Browse the repository at this point in the history
  • Loading branch information
playwrightmachine authored Jan 16, 2025
1 parent 2080652 commit 33cc294
Show file tree
Hide file tree
Showing 18 changed files with 117 additions and 166 deletions.
2 changes: 1 addition & 1 deletion dotnet/docs/api/class-locator.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ var button = page.GetByRole(AriaRole.Button).And(page.GetByTitle("Subscribe"));

<font size="2" style={{position: "relative", top: "-20px"}}>Added in: v1.49</font><x-search>locator.AriaSnapshotAsync</x-search>

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-2) 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-1) for the corresponding assertion.

**Usage**

Expand Down
38 changes: 19 additions & 19 deletions dotnet/docs/api/class-locatorassertions.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -499,21 +499,21 @@ await Expect(locator).ToHaveAttributeAsync("type", "text");

<font size="2" style={{position: "relative", top: "-20px"}}>Added in: v1.20</font><x-search>locatorAssertions.ToHaveClassAsync</x-search>

Ensures the [Locator] points to an element with given CSS classes. This needs to be a full match or using a relaxed regular expression.
Ensures the [Locator] points to an element with given CSS classes. When a string is provided, it must fully match the element's `class` attribute. To match individual classes or perform partial matches, use a regular expression:

**Usage**

```html
<div class='selected row' id='component'></div>
<div class='middle selected row' id='component'></div>
```

```csharp
var locator = Page.Locator("#component");
await Expect(locator).ToHaveClassAsync(new Regex("selected"));
await Expect(locator).ToHaveClassAsync("selected row");
await Expect(locator).ToHaveClassAsync(new Regex("(^|\\s)selected(\\s|$)"));
await Expect(locator).ToHaveClassAsync("middle selected row");
```

Note that if array is passed as an expected value, entire lists of elements can be asserted:
When an array is passed, the method asserts that the list of elements located matches the corresponding list of expected class values. Each element's class attribute is matched against the corresponding string or regular expression in the array:

```csharp
var locator = Page.Locator("list > .component");
Expand Down Expand Up @@ -811,23 +811,25 @@ await Expect(locator).ToHaveValuesAsync(new Regex[] { new Regex("R"), new Regex(

---

### ToMatchAriaSnapshotAsync(options) {#locator-assertions-to-match-aria-snapshot-1}
### ToMatchAriaSnapshotAsync(expected, options) {#locator-assertions-to-match-aria-snapshot-1}

<font size="2" style={{position: "relative", top: "-20px"}}>Added in: v1.50</font><x-search>locatorAssertions.ToMatchAriaSnapshotAsync(options)</x-search>
<font size="2" style={{position: "relative", top: "-20px"}}>Added in: v1.49</font><x-search>locatorAssertions.ToMatchAriaSnapshotAsync(expected, options)</x-search>

Asserts that the target element matches the given [accessibility snapshot](../aria-snapshots.mdx).

**Usage**

```csharp
await Expect(page.Locator("body")).ToMatchAriaSnapshotAsync(new { Path = "/path/to/snapshot.yml" });
await page.GotoAsync("https://demo.playwright.dev/todomvc/");
await Expect(page.Locator("body")).ToMatchAriaSnapshotAsync(@"
- heading ""todos""
- textbox ""What needs to be done?""
");
```

**Arguments**
- `expected` [string]<a aria-hidden="true" tabIndex="-1" class="list-anchor-link" id="locator-assertions-to-match-aria-snapshot-1-option-expected"/><a href="#locator-assertions-to-match-aria-snapshot-1-option-expected" class="list-anchor">#</a>
- `options` `LocatorAssertionsToMatchAriaSnapshotOptions?` *(optional)*
- `Path` [string]? *(optional)*<a aria-hidden="true" tabIndex="-1" class="list-anchor-link" id="locator-assertions-to-match-aria-snapshot-1-option-path"/><a href="#locator-assertions-to-match-aria-snapshot-1-option-path" class="list-anchor">#</a>

Path to the YAML snapshot file.
- `Timeout` [float]? *(optional)*<a aria-hidden="true" tabIndex="-1" class="list-anchor-link" id="locator-assertions-to-match-aria-snapshot-1-option-timeout"/><a href="#locator-assertions-to-match-aria-snapshot-1-option-timeout" class="list-anchor">#</a>

Time to retry the assertion for in milliseconds. Defaults to `5000`.
Expand All @@ -837,25 +839,23 @@ await Expect(page.Locator("body")).ToMatchAriaSnapshotAsync(new { Path = "/path/

---

### ToMatchAriaSnapshotAsync(expected, options) {#locator-assertions-to-match-aria-snapshot-2}
### ToMatchAriaSnapshotAsync(options) {#locator-assertions-to-match-aria-snapshot-2}

<font size="2" style={{position: "relative", top: "-20px"}}>Added in: v1.49</font><x-search>locatorAssertions.ToMatchAriaSnapshotAsync(expected, options)</x-search>
<font size="2" style={{position: "relative", top: "-20px"}}>Added in: v1.50</font><x-search>locatorAssertions.ToMatchAriaSnapshotAsync(options)</x-search>

Asserts that the target element matches the given [accessibility snapshot](../aria-snapshots.mdx).

**Usage**

```csharp
await page.GotoAsync("https://demo.playwright.dev/todomvc/");
await Expect(page.Locator("body")).ToMatchAriaSnapshotAsync(@"
- heading ""todos""
- textbox ""What needs to be done?""
");
await Expect(page.Locator("body")).ToMatchAriaSnapshotAsync(new { Path = "/path/to/snapshot.yml" });
```

**Arguments**
- `expected` [string]<a aria-hidden="true" tabIndex="-1" class="list-anchor-link" id="locator-assertions-to-match-aria-snapshot-2-option-expected"/><a href="#locator-assertions-to-match-aria-snapshot-2-option-expected" class="list-anchor">#</a>
- `options` `LocatorAssertionsToMatchAriaSnapshotOptions?` *(optional)*
- `Path` [string]? *(optional)*<a aria-hidden="true" tabIndex="-1" class="list-anchor-link" id="locator-assertions-to-match-aria-snapshot-2-option-path"/><a href="#locator-assertions-to-match-aria-snapshot-2-option-path" class="list-anchor">#</a>

Path to the YAML snapshot file.
- `Timeout` [float]? *(optional)*<a aria-hidden="true" tabIndex="-1" class="list-anchor-link" id="locator-assertions-to-match-aria-snapshot-2-option-timeout"/><a href="#locator-assertions-to-match-aria-snapshot-2-option-timeout" class="list-anchor">#</a>

Time to retry the assertion for in milliseconds. Defaults to `5000`.
Expand Down
2 changes: 1 addition & 1 deletion dotnet/docs/aria-snapshots.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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-2) 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-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.

For the following DOM:

Expand Down
2 changes: 1 addition & 1 deletion dotnet/docs/release-notes.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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-2) 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-1) verifies page structure by comparing to an expected accessibility tree, represented as YAML.

```csharp
await page.GotoAsync("https://playwright.dev");
Expand Down
2 changes: 1 addition & 1 deletion java/docs/api/class-locator.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ Locator button = page.getByRole(AriaRole.BUTTON).and(page.getByTitle("Subscribe"

<font size="2" style={{position: "relative", top: "-20px"}}>Added in: v1.49</font><x-search>locator.ariaSnapshot</x-search>

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-2) 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-1) for the corresponding assertion.

**Usage**

Expand Down
38 changes: 19 additions & 19 deletions java/docs/api/class-locatorassertions.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -223,20 +223,20 @@ assertThat(page.locator("input")).hasAttribute("type", "text");

<font size="2" style={{position: "relative", top: "-20px"}}>Added in: v1.20</font><x-search>locatorAssertions.hasClass</x-search>

Ensures the [Locator] points to an element with given CSS classes. This needs to be a full match or using a relaxed regular expression.
Ensures the [Locator] points to an element with given CSS classes. When a string is provided, it must fully match the element's `class` attribute. To match individual classes or perform partial matches, use a regular expression:

**Usage**

```html
<div class='selected row' id='component'></div>
<div class='middle selected row' id='component'></div>
```

```java
assertThat(page.locator("#component")).hasClass(Pattern.compile("selected"));
assertThat(page.locator("#component")).hasClass("selected row");
assertThat(page.locator("#component")).hasClass(Pattern.compile("(^|\\s)selected(\\s|$)"));
assertThat(page.locator("#component")).hasClass("middle selected row");
```

Note that if array is passed as an expected value, entire lists of elements can be asserted:
When an array is passed, the method asserts that the list of elements located matches the corresponding list of expected class values. Each element's class attribute is matched against the corresponding string or regular expression in the array:

```java
assertThat(page.locator("list > .component")).hasClass(new String[] {"component", "component selected", "component"});
Expand Down Expand Up @@ -788,23 +788,25 @@ assertThat(

---

### matchesAriaSnapshot(options) {#locator-assertions-to-match-aria-snapshot-1}
### matchesAriaSnapshot(expected) {#locator-assertions-to-match-aria-snapshot-1}

<font size="2" style={{position: "relative", top: "-20px"}}>Added in: v1.50</font><x-search>locatorAssertions.matchesAriaSnapshot(options)</x-search>
<font size="2" style={{position: "relative", top: "-20px"}}>Added in: v1.49</font><x-search>locatorAssertions.matchesAriaSnapshot(expected)</x-search>

Asserts that the target element matches the given [accessibility snapshot](../aria-snapshots.mdx).

**Usage**

```java
assertThat(page.locator("body")).matchesAriaSnapshot(new LocatorAssertions.MatchesAriaSnapshotOptions().setPath("/path/to/snapshot.yml"));
page.navigate("https://demo.playwright.dev/todomvc/");
assertThat(page.locator("body")).matchesAriaSnapshot("""
- heading "todos"
- textbox "What needs to be done?"
""");
```

**Arguments**
- `expected` [String]<a aria-hidden="true" tabIndex="-1" class="list-anchor-link" id="locator-assertions-to-match-aria-snapshot-1-option-expected"/><a href="#locator-assertions-to-match-aria-snapshot-1-option-expected" class="list-anchor">#</a>
- `options` `LocatorAssertions.MatchesAriaSnapshotOptions` *(optional)*
- `setPath` [String] *(optional)*<a aria-hidden="true" tabIndex="-1" class="list-anchor-link" id="locator-assertions-to-match-aria-snapshot-1-option-path"/><a href="#locator-assertions-to-match-aria-snapshot-1-option-path" class="list-anchor">#</a>

Path to the YAML snapshot file.
- `setTimeout` [double] *(optional)*<a aria-hidden="true" tabIndex="-1" class="list-anchor-link" id="locator-assertions-to-match-aria-snapshot-1-option-timeout"/><a href="#locator-assertions-to-match-aria-snapshot-1-option-timeout" class="list-anchor">#</a>

Time to retry the assertion for in milliseconds. Defaults to `5000`.
Expand All @@ -814,25 +816,23 @@ assertThat(page.locator("body")).matchesAriaSnapshot(new LocatorAssertions.Match

---

### matchesAriaSnapshot(expected) {#locator-assertions-to-match-aria-snapshot-2}
### matchesAriaSnapshot(options) {#locator-assertions-to-match-aria-snapshot-2}

<font size="2" style={{position: "relative", top: "-20px"}}>Added in: v1.49</font><x-search>locatorAssertions.matchesAriaSnapshot(expected)</x-search>
<font size="2" style={{position: "relative", top: "-20px"}}>Added in: v1.50</font><x-search>locatorAssertions.matchesAriaSnapshot(options)</x-search>

Asserts that the target element matches the given [accessibility snapshot](../aria-snapshots.mdx).

**Usage**

```java
page.navigate("https://demo.playwright.dev/todomvc/");
assertThat(page.locator("body")).matchesAriaSnapshot("""
- heading "todos"
- textbox "What needs to be done?"
""");
assertThat(page.locator("body")).matchesAriaSnapshot(new LocatorAssertions.MatchesAriaSnapshotOptions().setPath("/path/to/snapshot.yml"));
```

**Arguments**
- `expected` [String]<a aria-hidden="true" tabIndex="-1" class="list-anchor-link" id="locator-assertions-to-match-aria-snapshot-2-option-expected"/><a href="#locator-assertions-to-match-aria-snapshot-2-option-expected" class="list-anchor">#</a>
- `options` `LocatorAssertions.MatchesAriaSnapshotOptions` *(optional)*
- `setPath` [String] *(optional)*<a aria-hidden="true" tabIndex="-1" class="list-anchor-link" id="locator-assertions-to-match-aria-snapshot-2-option-path"/><a href="#locator-assertions-to-match-aria-snapshot-2-option-path" class="list-anchor">#</a>

Path to the YAML snapshot file.
- `setTimeout` [double] *(optional)*<a aria-hidden="true" tabIndex="-1" class="list-anchor-link" id="locator-assertions-to-match-aria-snapshot-2-option-timeout"/><a href="#locator-assertions-to-match-aria-snapshot-2-option-timeout" class="list-anchor">#</a>

Time to retry the assertion for in milliseconds. Defaults to `5000`.
Expand Down
2 changes: 1 addition & 1 deletion java/docs/aria-snapshots.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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-2) 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-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.

For the following DOM:

Expand Down
2 changes: 1 addition & 1 deletion java/docs/release-notes.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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-2) 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-1) verifies page structure by comparing to an expected accessibility tree, represented as YAML.

```java
page.navigate("https://playwright.dev");
Expand Down
2 changes: 1 addition & 1 deletion nodejs/docs/api/class-locator.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ const button = page.getByRole('button').and(page.getByTitle('Subscribe'));

<font size="2" style={{position: "relative", top: "-20px"}}>Added in: v1.49</font><x-search>locator.ariaSnapshot</x-search>

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-2) 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-1) for the corresponding assertion.

**Usage**

Expand Down
Loading

0 comments on commit 33cc294

Please sign in to comment.