|
1 | 1 | package com.serenitydojo.playwright; |
2 | 2 |
|
| 3 | +import com.microsoft.playwright.Browser; |
| 4 | +import com.microsoft.playwright.BrowserType; |
3 | 5 | import com.microsoft.playwright.Page; |
4 | 6 | import com.microsoft.playwright.junit.UsePlaywright; |
| 7 | +import com.microsoft.playwright.junit.Options; |
| 8 | +import com.microsoft.playwright.junit.OptionsFactory; |
5 | 9 | import org.junit.jupiter.api.Assertions; |
6 | 10 | import org.junit.jupiter.api.Test; |
7 | 11 |
|
8 | | -@UsePlaywright |
| 12 | +import java.util.Arrays; |
| 13 | + |
| 14 | +@UsePlaywright(ASimplePlaywrightTest.CustomOptions.class) |
9 | 15 | public class ASimplePlaywrightTest { |
10 | 16 |
|
| 17 | + public static class CustomOptions implements OptionsFactory { |
| 18 | + @Override |
| 19 | + public Options getOptions() { |
| 20 | + return new Options() |
| 21 | +// .setHeadless(false) |
| 22 | + .setLaunchOptions( |
| 23 | + new BrowserType.LaunchOptions() |
| 24 | + .setArgs(Arrays.asList("--no-sandbox", |
| 25 | + "--disable-gpu", |
| 26 | + "--disable-extensions")) |
| 27 | + ); |
| 28 | + } |
| 29 | + } |
| 30 | + |
11 | 31 | @Test |
12 | 32 | void shouldShowThePageTitle(Page page) { |
13 | 33 | page.navigate("https://practicesoftwaretesting.com"); |
14 | 34 | String title = page.title(); |
15 | | - |
16 | 35 | Assertions.assertTrue(title.contains("Practice Software Testing")); |
17 | 36 | } |
18 | 37 |
|
19 | 38 | @Test |
20 | | - void shouldShowSearchTermsInTheTitle(Page page) { |
| 39 | + void shouldShowSearchTermsInTheTitle1(Page page) { |
21 | 40 | page.navigate("https://practicesoftwaretesting.com"); |
22 | 41 | page.locator("[placeholder=Search]").fill("Pliers"); |
23 | 42 | page.locator("button:has-text('Search')").click(); |
|
0 commit comments