Skip to content

Commit 0073e79

Browse files
committed
Merge branch 'sample-code/module-8-locators' into sample-code/module-9-forms
2 parents a64a145 + d19e055 commit 0073e79

File tree

4 files changed

+20
-16
lines changed

4 files changed

+20
-16
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ buildNumber.properties
99
.mvn/timing.properties
1010
# https://github.com/takari/maven-wrapper#usage-without-binary-jar
1111
.mvn/wrapper/maven-wrapper.jar
12-
12+
.allure
13+
.idea
1314
# Eclipse m2e generated files
1415
# Eclipse Core
1516
.project

pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@
1818
<dependency>
1919
<groupId>com.microsoft.playwright</groupId>
2020
<artifactId>playwright</artifactId>
21-
<version>1.48.0</version>
21+
<version>1.57.0</version>
2222
<scope>test</scope>
2323
</dependency>
2424
<dependency>
2525
<groupId>org.junit.jupiter</groupId>
2626
<artifactId>junit-jupiter</artifactId>
27-
<version>5.11.1</version>
27+
<version>6.0.1</version>
2828
<scope>test</scope>
2929
</dependency>
3030
<dependency>

src/test/java/com/serenitydojo/playwright/PlaywrightLocatorsTest.java

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.serenitydojo.playwright;
22

33
import com.microsoft.playwright.*;
4+
import com.microsoft.playwright.assertions.LocatorAssertions;
45
import com.microsoft.playwright.assertions.PlaywrightAssertions;
56
import com.microsoft.playwright.junit.UsePlaywright;
67
import com.microsoft.playwright.options.AriaRole;
@@ -163,12 +164,13 @@ void byHeaderRole(Page page) {
163164
void byHeaderRoleLevel(Page page) {
164165
openPage(page);
165166

166-
List<String> level4Headings
167-
= page.getByRole(AriaRole.HEADING,
168-
new Page.GetByRoleOptions()
169-
.setName("Pliers")
170-
.setLevel(5))
171-
.allTextContents();
167+
Locator headings = page.getByRole(
168+
AriaRole.HEADING,
169+
new Page.GetByRoleOptions().setLevel(5)
170+
);
171+
assertThat(headings.first()).isVisible();
172+
173+
List<String> level4Headings = headings.allTextContents();
172174

173175
org.assertj.core.api.Assertions.assertThat(level4Headings).isNotEmpty();
174176
}
@@ -335,18 +337,19 @@ void filteringMenuItems(Page page) {
335337
void filteringMenuItemsByLocator(Page page) {
336338
openPage(page);
337339

338-
List<String> allProducts = page.locator(".card")
340+
Locator allProducts = page.locator(".card")
339341
.filter(new Locator.FilterOptions().setHas(page.getByText("Out of stock")))
340-
.getByTestId("product-name")
341-
.allTextContents();
342+
.getByTestId("product-name");
343+
344+
assertThat(allProducts.first()).isVisible();
345+
List<String> allProductNames = allProducts.allTextContents();
342346

343-
org.assertj.core.api.Assertions.assertThat(allProducts).hasSize(1)
347+
org.assertj.core.api.Assertions.assertThat(allProductNames).hasSize(1)
344348
.allMatch(name -> name.contains("Long Nose Pliers"));
345349
}
346350
}
347351

348352
private void openPage(Page page) {
349353
page.navigate("https://practicesoftwaretesting.com");
350-
page.waitForLoadState(LoadState.NETWORKIDLE);
351354
}
352355
}

src/test/resources/junit-platform.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# Enable parallel execution
22
junit.jupiter.execution.parallel.enabled = true
33

4-
# Configure the parallel mode (methods, classes, or both)
5-
junit.jupiter.execution.parallel.mode.default = classes
4+
# Configure the parallel mode (concurrent or same_thread)
5+
junit.jupiter.execution.parallel.mode.default = same_thread
66
junit.jupiter.execution.parallel.mode.classes.default = concurrent
77

88
# Set the parallelism (number of threads)

0 commit comments

Comments
 (0)