Skip to content

Commit f2de3d4

Browse files
committed
Sample code
1 parent 2ab2cb2 commit f2de3d4

File tree

1 file changed

+17
-16
lines changed

1 file changed

+17
-16
lines changed

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

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,36 @@
11
package com.serenitydojo.playwright;
22

3-
import com.microsoft.playwright.Browser;
4-
import com.microsoft.playwright.BrowserType;
5-
import com.microsoft.playwright.Page;
6-
import com.microsoft.playwright.Playwright;
7-
import org.junit.jupiter.api.AfterEach;
8-
import org.junit.jupiter.api.Assertions;
9-
import org.junit.jupiter.api.BeforeEach;
10-
import org.junit.jupiter.api.Test;
3+
import com.microsoft.playwright.*;
4+
import org.junit.jupiter.api.*;
115

126
import java.util.Arrays;
137

148
public class ASimplePlaywrightTest {
159

16-
Playwright playwright;
17-
Browser browser;
10+
private static Playwright playwright;
11+
private static Browser browser;
12+
private static BrowserContext browserContext;
13+
1814
Page page;
1915

20-
@BeforeEach
21-
public void setUp() {
16+
@BeforeAll
17+
public static void setUpBrowser() {
2218
playwright = Playwright.create();
2319
browser = playwright.chromium().launch(
2420
new BrowserType.LaunchOptions()
25-
// .setHeadless(false)
21+
.setHeadless(false)
2622
.setArgs(Arrays.asList("--no-sandbox","--disable-extensions","--disable-gpu"))
2723
);
28-
page = browser.newPage();
24+
browserContext = browser.newContext();
25+
}
26+
27+
@BeforeEach
28+
public void setUp() {
29+
page = browserContext.newPage();
2930
}
3031

31-
@AfterEach
32-
public void tearDown() {
32+
@AfterAll
33+
public static void tearDown() {
3334
browser.close();
3435
playwright.close();
3536
}

0 commit comments

Comments
 (0)