Skip to content

Commit 96fcac3

Browse files
committed
Sample code for module 4
1 parent 714887c commit 96fcac3

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

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

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import com.microsoft.playwright.Browser;
44
import com.microsoft.playwright.Page;
55
import com.microsoft.playwright.Playwright;
6+
import com.microsoft.playwright.impl.AssertionsTimeout;
67
import org.junit.jupiter.api.Assertions;
78
import org.junit.jupiter.api.Test;
89

@@ -22,4 +23,22 @@ void shouldShowThePageTitle() {
2223
browser.close();
2324
playwright.close();
2425
}
26+
27+
@Test
28+
void shouldShowSearchTermsInTheTitle() {
29+
Playwright playwright = Playwright.create();
30+
Browser browser = playwright.chromium().launch();
31+
Page page = browser.newPage();
32+
33+
page.navigate("https://practicesoftwaretesting.com");
34+
page.locator("[placeholder=Search]").fill("Pliers");
35+
page.locator("button:has-text('Search')").click();
36+
37+
int matchingProductCount = page.locator(".card-title").count();
38+
39+
Assertions.assertTrue(matchingProductCount > 0);
40+
41+
browser.close();
42+
playwright.close();
43+
}
2544
}

0 commit comments

Comments
 (0)