chore: simplify test setup
This commit is contained in:
@@ -464,7 +464,7 @@ class Interface extends TypeDefinition {
|
||||
"\n" +
|
||||
"package com.microsoft.playwright;\n";
|
||||
|
||||
private static Set<String> allowedBaseInterfaces = new HashSet<>(Arrays.asList("Browser", "JSHandle"));
|
||||
private static Set<String> allowedBaseInterfaces = new HashSet<>(Arrays.asList("Browser", "JSHandle", "BrowserContext"));
|
||||
|
||||
Interface(JsonObject jsonElement) {
|
||||
super(null, jsonElement);
|
||||
|
||||
@@ -19,7 +19,7 @@ package com.microsoft.playwright;
|
||||
import java.util.*;
|
||||
import java.util.function.BiConsumer;
|
||||
|
||||
public interface ChromiumBrowserContext {
|
||||
public interface ChromiumBrowserContext extends BrowserContext {
|
||||
List<Page> backgroundPages();
|
||||
CDPSession newCDPSession(Page page);
|
||||
List<Worker> serviceWorkers();
|
||||
|
||||
@@ -23,23 +23,16 @@ import java.io.IOException;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
public class TestElementHandleClick {
|
||||
private static Playwright playwright;
|
||||
private static Server server;
|
||||
private static Browser browser;
|
||||
private static boolean isChromium;
|
||||
private static boolean isWebKit;
|
||||
private static boolean headful;
|
||||
private BrowserContext context;
|
||||
private Page page;
|
||||
|
||||
@BeforeAll
|
||||
static void launchBrowser() {
|
||||
playwright = Playwright.create();
|
||||
Playwright playwright = Playwright.create();
|
||||
BrowserType.LaunchOptions options = new BrowserType.LaunchOptions();
|
||||
browser = playwright.chromium().launch(options);
|
||||
isChromium = true;
|
||||
isWebKit = false;
|
||||
headful = false;
|
||||
}
|
||||
|
||||
@BeforeAll
|
||||
|
||||
@@ -28,18 +28,16 @@ import static com.microsoft.playwright.Utils.mapOf;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
public class TestPopup {
|
||||
private static Playwright playwright;
|
||||
private static Server server;
|
||||
private Browser browser;
|
||||
private boolean isChromium;
|
||||
private boolean isWebKit;
|
||||
private boolean headful;
|
||||
private static Browser browser;
|
||||
private BrowserContext context;
|
||||
private Page page;
|
||||
|
||||
@BeforeAll
|
||||
static void createPlaywright() {
|
||||
playwright = Playwright.create();
|
||||
static void launchBrowser() {
|
||||
Playwright playwright = Playwright.create();
|
||||
BrowserType.LaunchOptions options = new BrowserType.LaunchOptions();
|
||||
browser = playwright.chromium().launch(options);
|
||||
}
|
||||
|
||||
@BeforeAll
|
||||
@@ -49,25 +47,22 @@ public class TestPopup {
|
||||
|
||||
@AfterAll
|
||||
static void stopServer() throws IOException {
|
||||
browser.close();
|
||||
server.stop();
|
||||
server = null;
|
||||
}
|
||||
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
// BrowserType.LaunchOptions options = new BrowserType.LaunchOptions().withHeadless(false).withSlowMo(1000);
|
||||
BrowserType.LaunchOptions options = new BrowserType.LaunchOptions();
|
||||
browser = playwright.chromium().launch(options);
|
||||
isChromium = true;
|
||||
isWebKit = false;
|
||||
headful = false;
|
||||
context = browser.newContext();
|
||||
page = context.newPage();
|
||||
}
|
||||
|
||||
@AfterEach
|
||||
void tearDown() {
|
||||
browser.close();
|
||||
context.close();
|
||||
context = null;
|
||||
page = null;
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user