mirror of
https://github.com/microsoft/playwright-java.git
synced 2025-09-08 21:01:00 +00:00
test: extract fixtures to TestBase (#27)
This commit is contained in:
parent
adc49e496a
commit
043108e09a
@ -0,0 +1,79 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) Microsoft Corporation.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.microsoft.playwright;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.AfterAll;
|
||||||
|
import org.junit.jupiter.api.AfterEach;
|
||||||
|
import org.junit.jupiter.api.BeforeAll;
|
||||||
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
public class TestBase {
|
||||||
|
static Server server;
|
||||||
|
static Server httpsServer;
|
||||||
|
static BrowserType browserType;
|
||||||
|
static Playwright playwright;
|
||||||
|
static Browser browser;
|
||||||
|
static boolean isChromium;
|
||||||
|
static boolean isWebKit;
|
||||||
|
static boolean isFirefox;
|
||||||
|
static boolean headful;
|
||||||
|
Page page;
|
||||||
|
BrowserContext context;
|
||||||
|
|
||||||
|
@BeforeAll
|
||||||
|
static void launchBrowser() {
|
||||||
|
playwright = Playwright.create();
|
||||||
|
BrowserType.LaunchOptions options = new BrowserType.LaunchOptions();
|
||||||
|
browserType = playwright.chromium();
|
||||||
|
browser = browserType.launch(options);
|
||||||
|
isChromium = true;
|
||||||
|
isWebKit = false;
|
||||||
|
headful = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@BeforeAll
|
||||||
|
static void startServer() throws IOException {
|
||||||
|
server = Server.createHttp(8907);
|
||||||
|
httpsServer = Server.createHttps(8908);
|
||||||
|
}
|
||||||
|
|
||||||
|
@AfterAll
|
||||||
|
static void stopServer() throws IOException {
|
||||||
|
browser.close();
|
||||||
|
server.stop();
|
||||||
|
server = null;
|
||||||
|
httpsServer.stop();
|
||||||
|
httpsServer = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@BeforeEach
|
||||||
|
void setUp() {
|
||||||
|
server.reset();
|
||||||
|
httpsServer.reset();
|
||||||
|
context = browser.newContext();
|
||||||
|
page = context.newPage();
|
||||||
|
}
|
||||||
|
|
||||||
|
@AfterEach
|
||||||
|
void tearDown() {
|
||||||
|
context.close();
|
||||||
|
context = null;
|
||||||
|
page = null;
|
||||||
|
}
|
||||||
|
}
|
@ -16,9 +16,8 @@
|
|||||||
|
|
||||||
package com.microsoft.playwright;
|
package com.microsoft.playwright;
|
||||||
|
|
||||||
import org.junit.jupiter.api.*;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@ -26,58 +25,7 @@ import static com.microsoft.playwright.Utils.mapOf;
|
|||||||
import static java.util.Arrays.asList;
|
import static java.util.Arrays.asList;
|
||||||
import static org.junit.jupiter.api.Assertions.*;
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
|
|
||||||
public class TestBrowserContextExposeFunction {
|
public class TestBrowserContextExposeFunction extends TestBase {
|
||||||
private static Playwright playwright;
|
|
||||||
private static Server server;
|
|
||||||
private static Server httpsServer;
|
|
||||||
private static BrowserType browserType;
|
|
||||||
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();
|
|
||||||
BrowserType.LaunchOptions options = new BrowserType.LaunchOptions();
|
|
||||||
browserType = playwright.chromium();
|
|
||||||
browser = browserType.launch(options);
|
|
||||||
isChromium = true;
|
|
||||||
isWebKit = false;
|
|
||||||
headful = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@BeforeAll
|
|
||||||
static void startServer() throws IOException {
|
|
||||||
server = Server.createHttp(8907);
|
|
||||||
httpsServer = Server.createHttps(8908);
|
|
||||||
}
|
|
||||||
|
|
||||||
@AfterAll
|
|
||||||
static void stopServer() throws IOException {
|
|
||||||
browser.close();
|
|
||||||
httpsServer.stop();
|
|
||||||
httpsServer = null;
|
|
||||||
server.stop();
|
|
||||||
server = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@BeforeEach
|
|
||||||
void setUp() {
|
|
||||||
server.reset();
|
|
||||||
httpsServer.reset();
|
|
||||||
context = browser.newContext();
|
|
||||||
page = context.newPage();
|
|
||||||
}
|
|
||||||
|
|
||||||
@AfterEach
|
|
||||||
void tearDown() {
|
|
||||||
context.close();
|
|
||||||
context = null;
|
|
||||||
page = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void exposeBindingShouldWork() {
|
void exposeBindingShouldWork() {
|
||||||
|
@ -16,58 +16,12 @@
|
|||||||
|
|
||||||
package com.microsoft.playwright;
|
package com.microsoft.playwright;
|
||||||
|
|
||||||
import org.junit.jupiter.api.*;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
public class TestCheck {
|
public class TestCheck extends TestBase {
|
||||||
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();
|
|
||||||
BrowserType.LaunchOptions options = new BrowserType.LaunchOptions();
|
|
||||||
browser = playwright.chromium().launch(options);
|
|
||||||
isChromium = true;
|
|
||||||
isWebKit = false;
|
|
||||||
headful = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@BeforeAll
|
|
||||||
static void startServer() throws IOException {
|
|
||||||
server = Server.createHttp(8907);
|
|
||||||
}
|
|
||||||
|
|
||||||
@AfterAll
|
|
||||||
static void stopServer() throws IOException {
|
|
||||||
browser.close();
|
|
||||||
server.stop();
|
|
||||||
server = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@BeforeEach
|
|
||||||
void setUp() {
|
|
||||||
server.reset();
|
|
||||||
context = browser.newContext();
|
|
||||||
page = context.newPage();
|
|
||||||
}
|
|
||||||
|
|
||||||
@AfterEach
|
|
||||||
void tearDown() {
|
|
||||||
context.close();
|
|
||||||
context = null;
|
|
||||||
page = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void shouldCheckTheBox() {
|
void shouldCheckTheBox() {
|
||||||
|
@ -16,12 +16,10 @@
|
|||||||
|
|
||||||
package com.microsoft.playwright;
|
package com.microsoft.playwright;
|
||||||
|
|
||||||
import org.junit.jupiter.api.*;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static com.microsoft.playwright.Keyboard.Modifier.SHIFT;
|
import static com.microsoft.playwright.Keyboard.Modifier.SHIFT;
|
||||||
@ -29,51 +27,7 @@ import static com.microsoft.playwright.Mouse.Button.RIGHT;
|
|||||||
import static com.microsoft.playwright.Page.EventType.CONSOLE;
|
import static com.microsoft.playwright.Page.EventType.CONSOLE;
|
||||||
import static org.junit.jupiter.api.Assertions.*;
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
|
|
||||||
public class TestClick {
|
public class TestClick extends TestBase {
|
||||||
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();
|
|
||||||
BrowserType.LaunchOptions options = new BrowserType.LaunchOptions();
|
|
||||||
browser = playwright.chromium().launch(options);
|
|
||||||
isChromium = true;
|
|
||||||
isWebKit = false;
|
|
||||||
headful = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@BeforeAll
|
|
||||||
static void startServer() throws IOException {
|
|
||||||
server = Server.createHttp(8907);
|
|
||||||
}
|
|
||||||
|
|
||||||
@AfterAll
|
|
||||||
static void stopServer() throws IOException {
|
|
||||||
browser.close();
|
|
||||||
server.stop();
|
|
||||||
server = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@BeforeEach
|
|
||||||
void setUp() {
|
|
||||||
server.reset();
|
|
||||||
context = browser.newContext();
|
|
||||||
page = context.newPage();
|
|
||||||
}
|
|
||||||
|
|
||||||
@AfterEach
|
|
||||||
void tearDown() {
|
|
||||||
context.close();
|
|
||||||
context = null;
|
|
||||||
page = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void shouldClickTheButton() {
|
void shouldClickTheButton() {
|
||||||
|
@ -16,52 +16,13 @@
|
|||||||
|
|
||||||
package com.microsoft.playwright;
|
package com.microsoft.playwright;
|
||||||
|
|
||||||
import org.junit.jupiter.api.*;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
import static com.microsoft.playwright.Page.EventType.DIALOG;
|
import static com.microsoft.playwright.Page.EventType.DIALOG;
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||||
|
|
||||||
public class TestDialog {
|
public class TestDialog extends TestBase {
|
||||||
private static Server server;
|
|
||||||
private static Browser browser;
|
|
||||||
private BrowserContext context;
|
|
||||||
private Page page;
|
|
||||||
|
|
||||||
@BeforeAll
|
|
||||||
static void launchBrowser() {
|
|
||||||
Playwright playwright = Playwright.create();
|
|
||||||
BrowserType.LaunchOptions options = new BrowserType.LaunchOptions();
|
|
||||||
browser = playwright.chromium().launch(options);
|
|
||||||
}
|
|
||||||
|
|
||||||
@BeforeAll
|
|
||||||
static void startServer() throws IOException {
|
|
||||||
server = Server.createHttp(8907);
|
|
||||||
}
|
|
||||||
|
|
||||||
@AfterAll
|
|
||||||
static void stopServer() throws IOException {
|
|
||||||
browser.close();
|
|
||||||
server.stop();
|
|
||||||
server = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@BeforeEach
|
|
||||||
void setUp() {
|
|
||||||
server.reset();
|
|
||||||
context = browser.newContext();
|
|
||||||
page = context.newPage();
|
|
||||||
}
|
|
||||||
|
|
||||||
@AfterEach
|
|
||||||
void tearDown() {
|
|
||||||
context.close();
|
|
||||||
context = null;
|
|
||||||
page = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void shouldFire() {
|
void shouldFire() {
|
||||||
|
@ -16,50 +16,11 @@
|
|||||||
|
|
||||||
package com.microsoft.playwright;
|
package com.microsoft.playwright;
|
||||||
|
|
||||||
import org.junit.jupiter.api.*;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.*;
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
|
|
||||||
public class TestElementHandleClick {
|
public class TestElementHandleClick extends TestBase {
|
||||||
private static Server server;
|
|
||||||
private static Browser browser;
|
|
||||||
private BrowserContext context;
|
|
||||||
private Page page;
|
|
||||||
|
|
||||||
@BeforeAll
|
|
||||||
static void launchBrowser() {
|
|
||||||
Playwright playwright = Playwright.create();
|
|
||||||
BrowserType.LaunchOptions options = new BrowserType.LaunchOptions();
|
|
||||||
browser = playwright.chromium().launch(options);
|
|
||||||
}
|
|
||||||
|
|
||||||
@BeforeAll
|
|
||||||
static void startServer() throws IOException {
|
|
||||||
server = Server.createHttp(8907);
|
|
||||||
}
|
|
||||||
|
|
||||||
@AfterAll
|
|
||||||
static void stopServer() throws IOException {
|
|
||||||
browser.close();
|
|
||||||
server.stop();
|
|
||||||
server = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@BeforeEach
|
|
||||||
void setUp() {
|
|
||||||
server.reset();
|
|
||||||
context = browser.newContext();
|
|
||||||
page = context.newPage();
|
|
||||||
}
|
|
||||||
|
|
||||||
@AfterEach
|
|
||||||
void tearDown() {
|
|
||||||
context.close();
|
|
||||||
context = null;
|
|
||||||
page = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void shouldWork() {
|
void shouldWork() {
|
||||||
|
@ -16,59 +16,14 @@
|
|||||||
|
|
||||||
package com.microsoft.playwright;
|
package com.microsoft.playwright;
|
||||||
|
|
||||||
import org.junit.jupiter.api.*;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.*;
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
|
|
||||||
public class TestEvalOnSelector {
|
public class TestEvalOnSelector extends TestBase {
|
||||||
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();
|
|
||||||
BrowserType.LaunchOptions options = new BrowserType.LaunchOptions();
|
|
||||||
browser = playwright.chromium().launch(options);
|
|
||||||
isChromium = true;
|
|
||||||
isWebKit = false;
|
|
||||||
headful = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@BeforeAll
|
|
||||||
static void startServer() throws IOException {
|
|
||||||
server = Server.createHttp(8907);
|
|
||||||
}
|
|
||||||
|
|
||||||
@AfterAll
|
|
||||||
static void stopServer() throws IOException {
|
|
||||||
browser.close();
|
|
||||||
server.stop();
|
|
||||||
server = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@BeforeEach
|
|
||||||
void setUp() {
|
|
||||||
server.reset();
|
|
||||||
context = browser.newContext();
|
|
||||||
page = context.newPage();
|
|
||||||
}
|
|
||||||
|
|
||||||
@AfterEach
|
|
||||||
void tearDown() {
|
|
||||||
context.close();
|
|
||||||
context = null;
|
|
||||||
page = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void shouldWorkWithCssSelector() {
|
void shouldWorkWithCssSelector() {
|
||||||
|
@ -16,58 +16,14 @@
|
|||||||
|
|
||||||
package com.microsoft.playwright;
|
package com.microsoft.playwright;
|
||||||
|
|
||||||
import org.junit.jupiter.api.*;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
|
||||||
public class TestEvalOnSelectorAll {
|
public class TestEvalOnSelectorAll extends TestBase {
|
||||||
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();
|
|
||||||
BrowserType.LaunchOptions options = new BrowserType.LaunchOptions();
|
|
||||||
browser = playwright.chromium().launch(options);
|
|
||||||
isChromium = true;
|
|
||||||
isWebKit = false;
|
|
||||||
headful = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@BeforeAll
|
|
||||||
static void startServer() throws IOException {
|
|
||||||
server = Server.createHttp(8907);
|
|
||||||
}
|
|
||||||
|
|
||||||
@AfterAll
|
|
||||||
static void stopServer() throws IOException {
|
|
||||||
browser.close();
|
|
||||||
server.stop();
|
|
||||||
server = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@BeforeEach
|
|
||||||
void setUp() {
|
|
||||||
server.reset();
|
|
||||||
context = browser.newContext();
|
|
||||||
page = context.newPage();
|
|
||||||
}
|
|
||||||
|
|
||||||
@AfterEach
|
|
||||||
void tearDown() {
|
|
||||||
context.close();
|
|
||||||
context = null;
|
|
||||||
page = null;
|
|
||||||
}
|
|
||||||
@Test
|
@Test
|
||||||
void shouldWorkWithCssSelector() {
|
void shouldWorkWithCssSelector() {
|
||||||
page.setContent("<div>hello</div><div>beautiful</div><div>world!</div>");
|
page.setContent("<div>hello</div><div>beautiful</div><div>world!</div>");
|
||||||
|
@ -16,52 +16,13 @@
|
|||||||
|
|
||||||
package com.microsoft.playwright;
|
package com.microsoft.playwright;
|
||||||
|
|
||||||
import org.junit.jupiter.api.*;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
import static com.microsoft.playwright.Frame.LoadState.NETWORKIDLE;
|
import static com.microsoft.playwright.Frame.LoadState.NETWORKIDLE;
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
public class TestFrameNavigate {
|
public class TestFrameNavigate extends TestBase {
|
||||||
private static Server server;
|
|
||||||
private static Browser browser;
|
|
||||||
private BrowserContext context;
|
|
||||||
private Page page;
|
|
||||||
|
|
||||||
@BeforeAll
|
|
||||||
static void launchBrowser() {
|
|
||||||
Playwright playwright = Playwright.create();
|
|
||||||
BrowserType.LaunchOptions options = new BrowserType.LaunchOptions();
|
|
||||||
browser = playwright.chromium().launch(options);
|
|
||||||
}
|
|
||||||
|
|
||||||
@BeforeAll
|
|
||||||
static void startServer() throws IOException {
|
|
||||||
server = Server.createHttp(8907);
|
|
||||||
}
|
|
||||||
|
|
||||||
@AfterAll
|
|
||||||
static void stopServer() throws IOException {
|
|
||||||
browser.close();
|
|
||||||
server.stop();
|
|
||||||
server = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@BeforeEach
|
|
||||||
void setUp() {
|
|
||||||
server.reset();
|
|
||||||
context = browser.newContext();
|
|
||||||
page = context.newPage();
|
|
||||||
}
|
|
||||||
|
|
||||||
@AfterEach
|
|
||||||
void tearDown() {
|
|
||||||
context.close();
|
|
||||||
context = null;
|
|
||||||
page = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void shouldNavigateSubframes() {
|
void shouldNavigateSubframes() {
|
||||||
|
@ -16,9 +16,8 @@
|
|||||||
|
|
||||||
package com.microsoft.playwright;
|
package com.microsoft.playwright;
|
||||||
|
|
||||||
import org.junit.jupiter.api.*;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -30,48 +29,7 @@ import static com.microsoft.playwright.Page.LoadState.DOMCONTENTLOADED;
|
|||||||
import static com.microsoft.playwright.Page.LoadState.LOAD;
|
import static com.microsoft.playwright.Page.LoadState.LOAD;
|
||||||
import static org.junit.jupiter.api.Assertions.*;
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
|
|
||||||
public class TestPageBasic {
|
public class TestPageBasic extends TestBase {
|
||||||
private static Server server;
|
|
||||||
private static Browser browser;
|
|
||||||
private static boolean isChromium;
|
|
||||||
private static boolean isWebKit;
|
|
||||||
private static boolean isFirefox;
|
|
||||||
private BrowserContext context;
|
|
||||||
private Page page;
|
|
||||||
|
|
||||||
@BeforeAll
|
|
||||||
static void launchBrowser() {
|
|
||||||
Playwright playwright = Playwright.create();
|
|
||||||
BrowserType.LaunchOptions options = new BrowserType.LaunchOptions();
|
|
||||||
browser = playwright.chromium().launch(options);
|
|
||||||
isChromium = true;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@BeforeAll
|
|
||||||
static void startServer() throws IOException {
|
|
||||||
server = Server.createHttp(8907);
|
|
||||||
}
|
|
||||||
|
|
||||||
@AfterAll
|
|
||||||
static void stopServer() throws IOException {
|
|
||||||
browser.close();
|
|
||||||
server.stop();
|
|
||||||
server = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@BeforeEach
|
|
||||||
void setUp() {
|
|
||||||
context = browser.newContext();
|
|
||||||
page = context.newPage();
|
|
||||||
}
|
|
||||||
|
|
||||||
@AfterEach
|
|
||||||
void tearDown() {
|
|
||||||
context.close();
|
|
||||||
context = null;
|
|
||||||
page = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void shouldRejectAllPromisesWhenPageIsClosed() {
|
void shouldRejectAllPromisesWhenPageIsClosed() {
|
||||||
|
@ -16,9 +16,8 @@
|
|||||||
|
|
||||||
package com.microsoft.playwright;
|
package com.microsoft.playwright;
|
||||||
|
|
||||||
import org.junit.jupiter.api.*;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import static com.microsoft.playwright.Frame.LoadState.LOAD;
|
import static com.microsoft.playwright.Frame.LoadState.LOAD;
|
||||||
@ -26,58 +25,7 @@ import static com.microsoft.playwright.Utils.mapOf;
|
|||||||
import static java.util.Arrays.asList;
|
import static java.util.Arrays.asList;
|
||||||
import static org.junit.jupiter.api.Assertions.*;
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
|
|
||||||
public class TestPageExposeFunction {
|
public class TestPageExposeFunction extends TestBase {
|
||||||
private static Playwright playwright;
|
|
||||||
private static Server server;
|
|
||||||
private static Server httpsServer;
|
|
||||||
private static BrowserType browserType;
|
|
||||||
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();
|
|
||||||
BrowserType.LaunchOptions options = new BrowserType.LaunchOptions();
|
|
||||||
browserType = playwright.chromium();
|
|
||||||
browser = browserType.launch(options);
|
|
||||||
isChromium = true;
|
|
||||||
isWebKit = false;
|
|
||||||
headful = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@BeforeAll
|
|
||||||
static void startServer() throws IOException {
|
|
||||||
server = Server.createHttp(8907);
|
|
||||||
httpsServer = Server.createHttps(8908);
|
|
||||||
}
|
|
||||||
|
|
||||||
@AfterAll
|
|
||||||
static void stopServer() throws IOException {
|
|
||||||
browser.close();
|
|
||||||
httpsServer.stop();
|
|
||||||
httpsServer = null;
|
|
||||||
server.stop();
|
|
||||||
server = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@BeforeEach
|
|
||||||
void setUp() {
|
|
||||||
server.reset();
|
|
||||||
httpsServer.reset();
|
|
||||||
context = browser.newContext();
|
|
||||||
page = context.newPage();
|
|
||||||
}
|
|
||||||
|
|
||||||
@AfterEach
|
|
||||||
void tearDown() {
|
|
||||||
context.close();
|
|
||||||
context = null;
|
|
||||||
page = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void exposeBindingShouldWork() {
|
void exposeBindingShouldWork() {
|
||||||
|
@ -16,54 +16,11 @@
|
|||||||
|
|
||||||
package com.microsoft.playwright;
|
package com.microsoft.playwright;
|
||||||
|
|
||||||
import org.junit.jupiter.api.*;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.*;
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
|
|
||||||
public class TestPageFill {
|
public class TestPageFill extends TestBase {
|
||||||
private static Server server;
|
|
||||||
private static Browser browser;
|
|
||||||
private static boolean isChromium;
|
|
||||||
private static boolean isWebKit;
|
|
||||||
private static boolean isFirefox;
|
|
||||||
private BrowserContext context;
|
|
||||||
private Page page;
|
|
||||||
|
|
||||||
@BeforeAll
|
|
||||||
static void launchBrowser() {
|
|
||||||
Playwright playwright = Playwright.create();
|
|
||||||
BrowserType.LaunchOptions options = new BrowserType.LaunchOptions();
|
|
||||||
browser = playwright.chromium().launch(options);
|
|
||||||
isChromium = true;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@BeforeAll
|
|
||||||
static void startServer() throws IOException {
|
|
||||||
server = Server.createHttp(8907);
|
|
||||||
}
|
|
||||||
|
|
||||||
@AfterAll
|
|
||||||
static void stopServer() throws IOException {
|
|
||||||
browser.close();
|
|
||||||
server.stop();
|
|
||||||
server = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@BeforeEach
|
|
||||||
void setUp() {
|
|
||||||
context = browser.newContext();
|
|
||||||
page = context.newPage();
|
|
||||||
}
|
|
||||||
|
|
||||||
@AfterEach
|
|
||||||
void tearDown() {
|
|
||||||
context.close();
|
|
||||||
context = null;
|
|
||||||
page = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void shouldFillTextarea() {
|
void shouldFillTextarea() {
|
||||||
|
@ -16,9 +16,8 @@
|
|||||||
|
|
||||||
package com.microsoft.playwright;
|
package com.microsoft.playwright;
|
||||||
|
|
||||||
import org.junit.jupiter.api.*;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.concurrent.ExecutionException;
|
import java.util.concurrent.ExecutionException;
|
||||||
import java.util.concurrent.Future;
|
import java.util.concurrent.Future;
|
||||||
@ -26,48 +25,7 @@ import java.util.function.BiConsumer;
|
|||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.*;
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
|
|
||||||
public class TestPageRoute {
|
public class TestPageRoute extends TestBase {
|
||||||
private static Server server;
|
|
||||||
private static Browser browser;
|
|
||||||
private static boolean isChromium;
|
|
||||||
private static boolean isWebKit;
|
|
||||||
private static boolean isFirefox;
|
|
||||||
private BrowserContext context;
|
|
||||||
private Page page;
|
|
||||||
|
|
||||||
@BeforeAll
|
|
||||||
static void launchBrowser() {
|
|
||||||
Playwright playwright = Playwright.create();
|
|
||||||
BrowserType.LaunchOptions options = new BrowserType.LaunchOptions();
|
|
||||||
browser = playwright.chromium().launch(options);
|
|
||||||
isChromium = true;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@BeforeAll
|
|
||||||
static void startServer() throws IOException {
|
|
||||||
server = Server.createHttp(8907);
|
|
||||||
}
|
|
||||||
|
|
||||||
@AfterAll
|
|
||||||
static void stopServer() throws IOException {
|
|
||||||
browser.close();
|
|
||||||
server.stop();
|
|
||||||
server = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@BeforeEach
|
|
||||||
void setUp() {
|
|
||||||
context = browser.newContext();
|
|
||||||
page = context.newPage();
|
|
||||||
}
|
|
||||||
|
|
||||||
@AfterEach
|
|
||||||
void tearDown() {
|
|
||||||
context.close();
|
|
||||||
context = null;
|
|
||||||
page = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void shouldIntercept() {
|
void shouldIntercept() {
|
||||||
|
@ -16,9 +16,8 @@
|
|||||||
|
|
||||||
package com.microsoft.playwright;
|
package com.microsoft.playwright;
|
||||||
|
|
||||||
import org.junit.jupiter.api.*;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.net.MalformedURLException;
|
import java.net.MalformedURLException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
@ -27,58 +26,7 @@ import static com.microsoft.playwright.Page.EventType.FRAMENAVIGATED;
|
|||||||
import static com.microsoft.playwright.Utils.expectedSSLError;
|
import static com.microsoft.playwright.Utils.expectedSSLError;
|
||||||
import static org.junit.jupiter.api.Assertions.*;
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
|
|
||||||
public class TestPageWaitForNavigation {
|
public class TestPageWaitForNavigation extends TestBase {
|
||||||
private static Playwright playwright;
|
|
||||||
private static Server server;
|
|
||||||
private static Server httpsServer;
|
|
||||||
private static BrowserType browserType;
|
|
||||||
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();
|
|
||||||
BrowserType.LaunchOptions options = new BrowserType.LaunchOptions();
|
|
||||||
browserType = playwright.chromium();
|
|
||||||
browser = browserType.launch(options);
|
|
||||||
isChromium = true;
|
|
||||||
isWebKit = false;
|
|
||||||
headful = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@BeforeAll
|
|
||||||
static void startServer() throws IOException {
|
|
||||||
server = Server.createHttp(8907);
|
|
||||||
httpsServer = Server.createHttps(8908);
|
|
||||||
}
|
|
||||||
|
|
||||||
@AfterAll
|
|
||||||
static void stopServer() throws IOException {
|
|
||||||
browser.close();
|
|
||||||
server.stop();
|
|
||||||
server = null;
|
|
||||||
httpsServer.stop();
|
|
||||||
httpsServer = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@BeforeEach
|
|
||||||
void setUp() {
|
|
||||||
server.reset();
|
|
||||||
httpsServer.reset();
|
|
||||||
context = browser.newContext();
|
|
||||||
page = context.newPage();
|
|
||||||
}
|
|
||||||
|
|
||||||
@AfterEach
|
|
||||||
void tearDown() {
|
|
||||||
context.close();
|
|
||||||
context = null;
|
|
||||||
page = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void shouldWork() {
|
void shouldWork() {
|
||||||
|
@ -16,10 +16,11 @@
|
|||||||
|
|
||||||
package com.microsoft.playwright;
|
package com.microsoft.playwright;
|
||||||
|
|
||||||
import org.junit.jupiter.api.*;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.util.ArrayList;
|
||||||
import java.util.*;
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
import java.util.concurrent.ExecutionException;
|
import java.util.concurrent.ExecutionException;
|
||||||
import java.util.concurrent.Future;
|
import java.util.concurrent.Future;
|
||||||
|
|
||||||
@ -28,44 +29,7 @@ import static com.microsoft.playwright.Page.LoadState.DOMCONTENTLOADED;
|
|||||||
import static com.microsoft.playwright.Utils.mapOf;
|
import static com.microsoft.playwright.Utils.mapOf;
|
||||||
import static org.junit.jupiter.api.Assertions.*;
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
|
|
||||||
public class TestPopup {
|
public class TestPopup extends TestBase {
|
||||||
private static Server server;
|
|
||||||
private static Browser browser;
|
|
||||||
private BrowserContext context;
|
|
||||||
private Page page;
|
|
||||||
|
|
||||||
@BeforeAll
|
|
||||||
static void launchBrowser() {
|
|
||||||
Playwright playwright = Playwright.create();
|
|
||||||
BrowserType.LaunchOptions options = new BrowserType.LaunchOptions();
|
|
||||||
browser = playwright.chromium().launch(options);
|
|
||||||
}
|
|
||||||
|
|
||||||
@BeforeAll
|
|
||||||
static void startServer() throws IOException {
|
|
||||||
server = Server.createHttp(8907);
|
|
||||||
}
|
|
||||||
|
|
||||||
@AfterAll
|
|
||||||
static void stopServer() throws IOException {
|
|
||||||
browser.close();
|
|
||||||
server.stop();
|
|
||||||
server = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@BeforeEach
|
|
||||||
void setUp() {
|
|
||||||
server.reset();
|
|
||||||
context = browser.newContext();
|
|
||||||
page = context.newPage();
|
|
||||||
}
|
|
||||||
|
|
||||||
@AfterEach
|
|
||||||
void tearDown() {
|
|
||||||
context.close();
|
|
||||||
context = null;
|
|
||||||
page = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void shouldInheritUserAgentFromBrowserContext() throws ExecutionException, InterruptedException {
|
void shouldInheritUserAgentFromBrowserContext() throws ExecutionException, InterruptedException {
|
||||||
|
@ -16,9 +16,8 @@
|
|||||||
|
|
||||||
package com.microsoft.playwright;
|
package com.microsoft.playwright;
|
||||||
|
|
||||||
import org.junit.jupiter.api.*;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
@ -26,52 +25,7 @@ import java.util.List;
|
|||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.*;
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
|
|
||||||
public class TestQuerySelector {
|
public class TestQuerySelector extends TestBase {
|
||||||
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();
|
|
||||||
BrowserType.LaunchOptions options = new BrowserType.LaunchOptions();
|
|
||||||
browser = playwright.chromium().launch(options);
|
|
||||||
isChromium = true;
|
|
||||||
isWebKit = false;
|
|
||||||
headful = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@BeforeAll
|
|
||||||
static void startServer() throws IOException {
|
|
||||||
server = Server.createHttp(8907);
|
|
||||||
}
|
|
||||||
|
|
||||||
@AfterAll
|
|
||||||
static void stopServer() throws IOException {
|
|
||||||
browser.close();
|
|
||||||
server.stop();
|
|
||||||
server = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@BeforeEach
|
|
||||||
void setUp() {
|
|
||||||
server.reset();
|
|
||||||
context = browser.newContext();
|
|
||||||
page = context.newPage();
|
|
||||||
}
|
|
||||||
|
|
||||||
@AfterEach
|
|
||||||
void tearDown() {
|
|
||||||
context.close();
|
|
||||||
context = null;
|
|
||||||
page = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void shouldThrowForNonStringSelector() {
|
void shouldThrowForNonStringSelector() {
|
||||||
|
@ -16,9 +16,8 @@
|
|||||||
|
|
||||||
package com.microsoft.playwright;
|
package com.microsoft.playwright;
|
||||||
|
|
||||||
import org.junit.jupiter.api.*;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@ -29,51 +28,7 @@ import static java.nio.charset.StandardCharsets.UTF_8;
|
|||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
public class TestRequestContinue {
|
public class TestRequestContinue extends TestBase {
|
||||||
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();
|
|
||||||
BrowserType.LaunchOptions options = new BrowserType.LaunchOptions();
|
|
||||||
browser = playwright.chromium().launch(options);
|
|
||||||
isChromium = true;
|
|
||||||
isWebKit = false;
|
|
||||||
headful = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@BeforeAll
|
|
||||||
static void startServer() throws IOException {
|
|
||||||
server = Server.createHttp(8907);
|
|
||||||
}
|
|
||||||
|
|
||||||
@AfterAll
|
|
||||||
static void stopServer() throws IOException {
|
|
||||||
browser.close();
|
|
||||||
server.stop();
|
|
||||||
server = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@BeforeEach
|
|
||||||
void setUp() {
|
|
||||||
server.reset();
|
|
||||||
context = browser.newContext();
|
|
||||||
page = context.newPage();
|
|
||||||
}
|
|
||||||
|
|
||||||
@AfterEach
|
|
||||||
void tearDown() {
|
|
||||||
context.close();
|
|
||||||
context = null;
|
|
||||||
page = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void shouldWork() {
|
void shouldWork() {
|
||||||
|
@ -16,9 +16,8 @@
|
|||||||
|
|
||||||
package com.microsoft.playwright;
|
package com.microsoft.playwright;
|
||||||
|
|
||||||
import org.junit.jupiter.api.*;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -30,58 +29,7 @@ import static java.util.Arrays.asList;
|
|||||||
import static org.junit.jupiter.api.Assertions.*;
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
|
|
||||||
|
|
||||||
public class TestWaitForFunction {
|
public class TestWaitForFunction extends TestBase {
|
||||||
private static Playwright playwright;
|
|
||||||
private static Server server;
|
|
||||||
private static Server httpsServer;
|
|
||||||
private static BrowserType browserType;
|
|
||||||
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();
|
|
||||||
BrowserType.LaunchOptions options = new BrowserType.LaunchOptions();
|
|
||||||
browserType = playwright.chromium();
|
|
||||||
browser = browserType.launch(options);
|
|
||||||
isChromium = true;
|
|
||||||
isWebKit = false;
|
|
||||||
headful = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@BeforeAll
|
|
||||||
static void startServer() throws IOException {
|
|
||||||
server = Server.createHttp(8907);
|
|
||||||
httpsServer = Server.createHttps(8908);
|
|
||||||
}
|
|
||||||
|
|
||||||
@AfterAll
|
|
||||||
static void stopServer() throws IOException {
|
|
||||||
browser.close();
|
|
||||||
server.stop();
|
|
||||||
server = null;
|
|
||||||
httpsServer.stop();
|
|
||||||
httpsServer = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@BeforeEach
|
|
||||||
void setUp() {
|
|
||||||
server.reset();
|
|
||||||
httpsServer.reset();
|
|
||||||
context = browser.newContext();
|
|
||||||
page = context.newPage();
|
|
||||||
}
|
|
||||||
|
|
||||||
@AfterEach
|
|
||||||
void tearDown() {
|
|
||||||
context.close();
|
|
||||||
context = null;
|
|
||||||
page = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void shouldTimeout() {
|
void shouldTimeout() {
|
||||||
|
@ -16,63 +16,14 @@
|
|||||||
|
|
||||||
package com.microsoft.playwright;
|
package com.microsoft.playwright;
|
||||||
|
|
||||||
import org.junit.jupiter.api.*;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import static com.google.gson.internal.bind.TypeAdapters.URL;
|
|
||||||
import static com.microsoft.playwright.Page.EventType.*;
|
import static com.microsoft.playwright.Page.EventType.*;
|
||||||
import static com.microsoft.playwright.Utils.attachFrame;
|
import static com.microsoft.playwright.Utils.attachFrame;
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
public class TestWorkers {
|
public class TestWorkers extends TestBase {
|
||||||
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();
|
|
||||||
BrowserType.LaunchOptions options = new BrowserType.LaunchOptions();
|
|
||||||
browser = playwright.chromium().launch(options);
|
|
||||||
isChromium = true;
|
|
||||||
isWebKit = false;
|
|
||||||
headful = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@BeforeAll
|
|
||||||
static void startServer() throws IOException {
|
|
||||||
server = Server.createHttp(8907);
|
|
||||||
}
|
|
||||||
|
|
||||||
@AfterAll
|
|
||||||
static void stopServer() throws IOException {
|
|
||||||
browser.close();
|
|
||||||
server.stop();
|
|
||||||
server = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@BeforeEach
|
|
||||||
void setUp() {
|
|
||||||
server.reset();
|
|
||||||
context = browser.newContext();
|
|
||||||
page = context.newPage();
|
|
||||||
}
|
|
||||||
|
|
||||||
@AfterEach
|
|
||||||
void tearDown() {
|
|
||||||
context.close();
|
|
||||||
context = null;
|
|
||||||
page = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void pageWorkers() {
|
void pageWorkers() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user