1
0
mirror of synced 2026-08-05 15:06:54 +00:00

chore: simplify test setup

This commit is contained in:
Yury Semikhatsky
2020-10-05 14:30:10 -07:00
parent 1f44173b8c
commit 491429b768
4 changed files with 12 additions and 24 deletions
@@ -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