|
1 | 1 | package com.serenitydojo.playwright; |
2 | 2 |
|
3 | 3 | import com.microsoft.playwright.*; |
| 4 | +import com.microsoft.playwright.assertions.LocatorAssertions; |
4 | 5 | import com.microsoft.playwright.assertions.PlaywrightAssertions; |
5 | 6 | import com.microsoft.playwright.options.AriaRole; |
6 | 7 | import com.microsoft.playwright.options.LoadState; |
@@ -194,12 +195,13 @@ void byHeaderRole() { |
194 | 195 | void byHeaderRoleLevel() { |
195 | 196 | openPage(); |
196 | 197 |
|
197 | | - List<String> level4Headings |
198 | | - = page.getByRole(AriaRole.HEADING, |
199 | | - new Page.GetByRoleOptions() |
200 | | - .setName("Pliers") |
201 | | - .setLevel(5)) |
202 | | - .allTextContents(); |
| 198 | + Locator headings = page.getByRole( |
| 199 | + AriaRole.HEADING, |
| 200 | + new Page.GetByRoleOptions().setLevel(5) |
| 201 | + ); |
| 202 | + assertThat(headings.first()).isVisible(); |
| 203 | + |
| 204 | + List<String> level4Headings = headings.allTextContents(); |
203 | 205 |
|
204 | 206 | org.assertj.core.api.Assertions.assertThat(level4Headings).isNotEmpty(); |
205 | 207 | } |
@@ -379,12 +381,14 @@ void filteringMenuItems() { |
379 | 381 | void filteringMenuItemsByLocator() { |
380 | 382 | openPage();; |
381 | 383 |
|
382 | | - List<String> allProducts = page.locator(".card") |
| 384 | + Locator allProducts = page.locator(".card") |
383 | 385 | .filter(new Locator.FilterOptions().setHas(page.getByText("Out of stock"))) |
384 | | - .getByTestId("product-name") |
385 | | - .allTextContents(); |
| 386 | + .getByTestId("product-name"); |
| 387 | + |
| 388 | + assertThat(allProducts.first()).isVisible(); |
| 389 | + List<String> allProductNames = allProducts.allTextContents(); |
386 | 390 |
|
387 | | - org.assertj.core.api.Assertions.assertThat(allProducts).hasSize(1) |
| 391 | + org.assertj.core.api.Assertions.assertThat(allProductNames).hasSize(1) |
388 | 392 | .allMatch(name -> name.contains("Long Nose Pliers")); |
389 | 393 | } |
390 | 394 | } |
|
0 commit comments