diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 722554d4a..27d10d231 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -11,93 +11,12 @@ on: env: PW_MAX_RETRIES: 3 jobs: - dev: - timeout-minutes: 30 - strategy: - fail-fast: false - matrix: - os: [ubuntu-latest, windows-latest, macos-latest] - browser: [chromium, firefox, webkit] - runs-on: ${{ matrix.os }} - steps: - - uses: actions/checkout@v4 - - name: Set up JDK 1.8 - uses: actions/setup-java@v4 - with: - distribution: zulu - java-version: 8 - - name: Download drivers - shell: bash - run: scripts/download_driver.sh - - name: Build & Install - run: mvn -B install -D skipTests --no-transfer-progress - - name: Install browsers - run: mvn exec:java -e -D exec.mainClass=com.microsoft.playwright.CLI -D exec.args="install --with-deps" -f playwright/pom.xml --no-transfer-progress - - name: Run tests - run: mvn test --no-transfer-progress --fail-at-end -D org.slf4j.simpleLogger.showDateTime=true -D org.slf4j.simpleLogger.dateTimeFormat=HH:mm:ss - env: - BROWSER: ${{ matrix.browser }} - - name: Run tracing tests w/ sources - run: mvn test --no-transfer-progress --fail-at-end --projects=playwright -D test=*TestTracing* -D org.slf4j.simpleLogger.showDateTime=true -D org.slf4j.simpleLogger.dateTimeFormat=HH:mm:ss - env: - BROWSER: ${{ matrix.browser }} - PLAYWRIGHT_JAVA_SRC: src/test/java - - name: Test Spring Boot Starter - shell: bash - env: - BROWSER: ${{ matrix.browser }} - run: | - cd tools/test-spring-boot-starter - mvn package -D skipTests --no-transfer-progress - java -jar target/test-spring-boot*.jar - - stable: - timeout-minutes: 30 - strategy: - fail-fast: false - matrix: - os: [ubuntu-latest, windows-latest, macos-latest] - browser-channel: [chrome] - include: - - os: windows-latest - browser-channel: msedge - - os: macos-latest - browser-channel: msedge - runs-on: ${{ matrix.os }} - steps: - - uses: actions/checkout@v4 - - name: Install Media Pack - if: matrix.os == 'windows-latest' - shell: powershell - run: Install-WindowsFeature Server-Media-Foundation - - name: Set up JDK 1.8 - uses: actions/setup-java@v4 - with: - distribution: zulu - java-version: 8 - - name: Download drivers - shell: bash - run: scripts/download_driver.sh - - name: Build & Install - run: mvn -B install -D skipTests --no-transfer-progress - - name: Install browsers - run: mvn exec:java -e -D exec.mainClass=com.microsoft.playwright.CLI -D exec.args="install --with-deps" -f playwright/pom.xml --no-transfer-progress - - name: Install MS Edge - if: matrix.browser-channel == 'msedge' && matrix.os == 'macos-latest' - shell: bash - run: mvn exec:java -e -D exec.mainClass=com.microsoft.playwright.CLI -D exec.args="install msedge" -f playwright/pom.xml - - name: Run tests - run: mvn test --no-transfer-progress --fail-at-end -D org.slf4j.simpleLogger.showDateTime=true -D org.slf4j.simpleLogger.dateTimeFormat=HH:mm:ss - env: - BROWSER: chromium - BROWSER_CHANNEL: ${{ matrix.browser-channel }} - Java_21: - timeout-minutes: 30 + timeout-minutes: 60 strategy: fail-fast: false matrix: - browser: [chromium, firefox, webkit] + browser: [webkit,webkit,webkit,webkit,webkit,webkit,webkit] runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 diff --git a/driver-bundle/src/main/java/com/microsoft/playwright/impl/driver/jar/DriverJar.java b/driver-bundle/src/main/java/com/microsoft/playwright/impl/driver/jar/DriverJar.java index 3fe7537d8..05135799b 100644 --- a/driver-bundle/src/main/java/com/microsoft/playwright/impl/driver/jar/DriverJar.java +++ b/driver-bundle/src/main/java/com/microsoft/playwright/impl/driver/jar/DriverJar.java @@ -87,8 +87,10 @@ private void installBrowsers(Map env) throws IOException, Interr } ProcessBuilder pb = createProcessBuilder(); pb.command().add("install"); - pb.redirectError(ProcessBuilder.Redirect.INHERIT); - pb.redirectOutput(ProcessBuilder.Redirect.INHERIT); + if (System.getenv("PW_JAVA_INTERNAL_SILENT_INSTALL") != null) { + pb.redirectError(ProcessBuilder.Redirect.INHERIT); + pb.redirectOutput(ProcessBuilder.Redirect.INHERIT); + } Process p = pb.start(); boolean result = p.waitFor(10, TimeUnit.MINUTES); if (!result) { diff --git a/driver-bundle/src/test/java/com/microsoft/playwright/impl/driver/jar/TestInstall.java b/driver-bundle/src/test/java/com/microsoft/playwright/impl/driver/jar/TestInstall.java index 953549bf1..2586193c7 100644 --- a/driver-bundle/src/test/java/com/microsoft/playwright/impl/driver/jar/TestInstall.java +++ b/driver-bundle/src/test/java/com/microsoft/playwright/impl/driver/jar/TestInstall.java @@ -74,6 +74,7 @@ void shouldThrowWhenBrowserPathIsInvalid(@TempDir Path tmpDir) throws NoSuchFiel // Make sure the browsers are not installed yet by pointing at an empty dir. env.put("PLAYWRIGHT_BROWSERS_PATH", tmpDir.toString()); env.put("PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD", "false"); + env.put("PW_JAVA_INTERNAL_SILENT_INSTALL", "true"); RuntimeException exception = assertThrows(RuntimeException.class, () -> Driver.createAndInstall(env, true)); String message = exception.getMessage(); diff --git a/playwright/pom.xml b/playwright/pom.xml index 179095ecb..7785e62ca 100644 --- a/playwright/pom.xml +++ b/playwright/pom.xml @@ -57,6 +57,10 @@ org.java-websocket Java-WebSocket + + org.slf4j + slf4j-simple + org.junit.jupiter junit-jupiter-engine diff --git a/playwright/src/test/java/com/microsoft/playwright/Server.java b/playwright/src/test/java/com/microsoft/playwright/Server.java index 5d42d0830..beeea69d8 100644 --- a/playwright/src/test/java/com/microsoft/playwright/Server.java +++ b/playwright/src/test/java/com/microsoft/playwright/Server.java @@ -218,7 +218,7 @@ public void handle(HttpExchange exchange) throws IOException { } long contentLength = body.size(); // -1 means no body, 0 means chunked encoding. - exchange.sendResponseHeaders(200, contentLength == 0 ? -1 : contentLength); + exchange.sendResponseHeaders(200, (contentLength == 0 || exchange.getRequestMethod().equals("HEAD")) ? -1 : contentLength); if (contentLength > 0) { exchange.getResponseBody().write(body.toByteArray()); } diff --git a/playwright/src/test/java/com/microsoft/playwright/TestBrowserContextCredentials.java b/playwright/src/test/java/com/microsoft/playwright/TestBrowserContextCredentials.java index ce556273e..addf6e549 100644 --- a/playwright/src/test/java/com/microsoft/playwright/TestBrowserContextCredentials.java +++ b/playwright/src/test/java/com/microsoft/playwright/TestBrowserContextCredentials.java @@ -33,7 +33,6 @@ static boolean isChromiumHeadedLike() { @Test @DisabledIf(value="isChromiumHeadedLike", disabledReason="fail") void shouldFailWithoutCredentials() { - System.out.println("channel2 " + getBrowserChannelFromEnv()); server.setAuth("/empty.html", "user", "pass"); Response response = page.navigate(server.EMPTY_PAGE); assertEquals(401, response.status()); diff --git a/playwright/src/test/java/com/microsoft/playwright/TestBrowserContextHar.java b/playwright/src/test/java/com/microsoft/playwright/TestBrowserContextHar.java index d46aec960..6602ee560 100644 --- a/playwright/src/test/java/com/microsoft/playwright/TestBrowserContextHar.java +++ b/playwright/src/test/java/com/microsoft/playwright/TestBrowserContextHar.java @@ -20,7 +20,11 @@ import com.microsoft.playwright.options.HarMode; import com.microsoft.playwright.options.HarNotFound; import com.microsoft.playwright.options.RouteFromHarUpdateContentPolicy; + +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInfo; import org.junit.jupiter.api.condition.DisabledIf; import org.junit.jupiter.api.io.TempDir; @@ -44,6 +48,16 @@ import static org.junit.jupiter.api.Assertions.*; public class TestBrowserContextHar extends TestBase { + @BeforeEach + void BeforeEach(TestInfo testInfo) { + System.out.println("BeforeEach::displayName = " + testInfo.getDisplayName()); + } + + @AfterEach + void AfterEach(TestInfo testInfo) { + System.out.println("AfterEach::displayName = " + testInfo.getDisplayName()); + } + @Test void shouldContextRouteFromHARMatchingTheMethodAndFollowingRedirects() { Path path = Paths.get("src/test/resources/har-fulfill.har"); @@ -204,15 +218,25 @@ void shouldChangeDocumentURLAfterRedirectedNavigationOnClick() { @Test void shouldGoBackToRedirectedNavigation() { Path path = Paths.get("src/test/resources/har-redirect.har"); + System.err.println("shouldGoBackToRedirectedNavigation#1"); context.routeFromHAR(path, new BrowserContext.RouteFromHAROptions().setUrl(Pattern.compile(".*theverge.*"))); + System.err.println("shouldGoBackToRedirectedNavigation#2"); Page page = context.newPage(); + System.err.println("shouldGoBackToRedirectedNavigation#3"); page.navigate("https://theverge.com/"); + System.err.println("shouldGoBackToRedirectedNavigation#4"); page.navigate(server.EMPTY_PAGE); + System.err.println("shouldGoBackToRedirectedNavigation#5"); assertThat(page).hasURL(server.EMPTY_PAGE); + System.err.println("shouldGoBackToRedirectedNavigation#6"); Response response = page.goBack(); + System.err.println("shouldGoBackToRedirectedNavigation#7"); assertThat(page).hasURL("https://www.theverge.com/"); + System.err.println("shouldGoBackToRedirectedNavigation#8"); assertEquals("https://www.theverge.com/", response.request().url()); + System.err.println("shouldGoBackToRedirectedNavigation#9"); assertEquals("https://www.theverge.com/", page.evaluate("location.href")); + System.err.println("shouldGoBackToRedirectedNavigation#10"); } @Test diff --git a/playwright/src/test/java/com/microsoft/playwright/TestGlobalFetch.java b/playwright/src/test/java/com/microsoft/playwright/TestGlobalFetch.java index 1993d2aa5..e681d70a6 100644 --- a/playwright/src/test/java/com/microsoft/playwright/TestGlobalFetch.java +++ b/playwright/src/test/java/com/microsoft/playwright/TestGlobalFetch.java @@ -337,7 +337,7 @@ void shouldReturnBodyForFailingRequests() { for (String method : new String[] {"head", "put", "trace"}) { server.setRoute("/empty.html", exchange -> { exchange.getResponseHeaders().set("Content-type", "text/plain"); - exchange.sendResponseHeaders(404, 10); + exchange.sendResponseHeaders(404, exchange.getRequestMethod().equals("HEAD") ? -1 : 10); try (Writer writer = new OutputStreamWriter(exchange.getResponseBody())) { writer.write("Not found."); } diff --git a/pom.xml b/pom.xml index 56fe626f3..8785990f6 100644 --- a/pom.xml +++ b/pom.xml @@ -48,6 +48,7 @@ 5.12.1 UTF-8 1.6.0 + 2.0.17 1.3.0 @@ -91,6 +92,12 @@ ${websocket.version} test + + org.slf4j + slf4j-simple + ${slf4j.version} + test + org.junit.jupiter junit-jupiter-api @@ -151,7 +158,7 @@ - junit.jupiter.execution.parallel.enabled = true + junit.jupiter.execution.parallel.enabled = false junit.jupiter.execution.parallel.mode.default = same_thread junit.jupiter.execution.parallel.mode.classes.default = concurrent junit.jupiter.execution.parallel.config.strategy=dynamic