diff --git a/.claude/skills/playwright-roll/SKILL.md b/.claude/skills/playwright-roll/SKILL.md deleted file mode 100644 index c33ecdcbb..000000000 --- a/.claude/skills/playwright-roll/SKILL.md +++ /dev/null @@ -1,22 +0,0 @@ ---- -name: playwright-roll -description: Roll Playwright Java to a new version ---- - -Help the user roll to a new version of Playwright. -ROLLING.md contains general instructions and scripts. - -Start with updating the version and generating the API to see the state of things. -Afterwards, work through the list of changes that need to be backported. -You can find a list of pull requests that might need to be taking into account in the issue titled "Backport changes". -Work through them one-by-one and check off the items that you have handled. -Not all of them will be relevant, some might have partially been reverted, etc. - so feel free to check with the upstream release branch. - -Rolling includes: -- updating client implementation to match changes in the upstream JS implementation (see ../playwright/packages/playwright-core/src/client) -- adding a couple of new tests to verify new/changed functionality - -## Tips & Tricks -- Project checkouts are in the parent directory (`../`). -- When updating checkboxes, store the issue content into /tmp and edit it there, then update the issue based on the file -- use the "gh" cli to interact with GitHub diff --git a/README.md b/README.md index e5b87f976..7278f8930 100644 --- a/README.md +++ b/README.md @@ -10,9 +10,9 @@ Playwright is a Java library to automate [Chromium](https://www.chromium.org/Hom | | Linux | macOS | Windows | | :--- | :---: | :---: | :---: | -| Chromium 145.0.7632.6 | :white_check_mark: | :white_check_mark: | :white_check_mark: | +| Chromium 143.0.7499.4 | :white_check_mark: | :white_check_mark: | :white_check_mark: | | WebKit 26.0 | ✅ | ✅ | ✅ | -| Firefox 146.0.1 | :white_check_mark: | :white_check_mark: | :white_check_mark: | +| Firefox 144.0.2 | :white_check_mark: | :white_check_mark: | :white_check_mark: | ## Documentation diff --git a/examples/pom.xml b/examples/pom.xml index 8029f389f..0fb4c580b 100644 --- a/examples/pom.xml +++ b/examples/pom.xml @@ -10,7 +10,7 @@ Playwright Client Examples UTF-8 - 1.58.0 + 1.57.0 diff --git a/playwright/src/main/java/com/microsoft/playwright/BrowserType.java b/playwright/src/main/java/com/microsoft/playwright/BrowserType.java index a0a7383b6..54864b3b0 100644 --- a/playwright/src/main/java/com/microsoft/playwright/BrowserType.java +++ b/playwright/src/main/java/com/microsoft/playwright/BrowserType.java @@ -128,11 +128,6 @@ class ConnectOverCDPOptions { * Additional HTTP headers to be sent with connect request. Optional. */ public Map headers; - /** - * Tells Playwright that it runs on the same host as the CDP server. It will enable certain optimizations that rely upon - * the file system being the same between Playwright and the Browser. - */ - public Boolean isLocal; /** * Slows down Playwright operations by the specified amount of milliseconds. Useful so that you can see what is going on. * Defaults to 0. @@ -151,14 +146,6 @@ public ConnectOverCDPOptions setHeaders(Map headers) { this.headers = headers; return this; } - /** - * Tells Playwright that it runs on the same host as the CDP server. It will enable certain optimizations that rely upon - * the file system being the same between Playwright and the Browser. - */ - public ConnectOverCDPOptions setIsLocal(boolean isLocal) { - this.isLocal = isLocal; - return this; - } /** * Slows down Playwright operations by the specified amount of milliseconds. Useful so that you can see what is going on. * Defaults to 0. @@ -199,6 +186,10 @@ class LaunchOptions { * Enable Chromium sandboxing. Defaults to {@code false}. */ public Boolean chromiumSandbox; + /** + * @deprecated Use debugging tools instead. + */ + public Boolean devtools; /** * If specified, accepted downloads are downloaded into this directory. Otherwise, temporary directory is created and is * deleted when browser is closed. In either case, the downloads are deleted when the browser context they were created in @@ -238,7 +229,8 @@ class LaunchOptions { /** * Whether to run browser in headless mode. More details for Chromium and Firefox. Defaults to {@code true}. + * href="https://hacks.mozilla.org/2017/12/using-headless-mode-in-firefox/">Firefox. Defaults to {@code true} unless + * the {@code devtools} option is {@code true}. */ public Boolean headless; /** @@ -315,6 +307,13 @@ public LaunchOptions setChromiumSandbox(boolean chromiumSandbox) { this.chromiumSandbox = chromiumSandbox; return this; } + /** + * @deprecated Use debugging tools instead. + */ + public LaunchOptions setDevtools(boolean devtools) { + this.devtools = devtools; + return this; + } /** * If specified, accepted downloads are downloaded into this directory. Otherwise, temporary directory is created and is * deleted when browser is closed. In either case, the downloads are deleted when the browser context they were created in @@ -375,7 +374,8 @@ public LaunchOptions setHandleSIGTERM(boolean handleSIGTERM) { /** * Whether to run browser in headless mode. More details for Chromium and Firefox. Defaults to {@code true}. + * href="https://hacks.mozilla.org/2017/12/using-headless-mode-in-firefox/">Firefox. Defaults to {@code true} unless + * the {@code devtools} option is {@code true}. */ public LaunchOptions setHeadless(boolean headless) { this.headless = headless; @@ -518,6 +518,10 @@ class LaunchPersistentContextOptions { * href="https://playwright.dev/java/docs/emulation#devices">emulating devices with device scale factor. */ public Double deviceScaleFactor; + /** + * @deprecated Use debugging tools instead. + */ + public Boolean devtools; /** * If specified, accepted downloads are downloaded into this directory. Otherwise, temporary directory is created and is * deleted when browser is closed. In either case, the downloads are deleted when the browser context they were created in @@ -573,7 +577,8 @@ class LaunchPersistentContextOptions { /** * Whether to run browser in headless mode. More details for Chromium and Firefox. Defaults to {@code true}. + * href="https://hacks.mozilla.org/2017/12/using-headless-mode-in-firefox/">Firefox. Defaults to {@code true} unless + * the {@code devtools} option is {@code true}. */ public Boolean headless; /** @@ -851,6 +856,13 @@ public LaunchPersistentContextOptions setDeviceScaleFactor(double deviceScaleFac this.deviceScaleFactor = deviceScaleFactor; return this; } + /** + * @deprecated Use debugging tools instead. + */ + public LaunchPersistentContextOptions setDevtools(boolean devtools) { + this.devtools = devtools; + return this; + } /** * If specified, accepted downloads are downloaded into this directory. Otherwise, temporary directory is created and is * deleted when browser is closed. In either case, the downloads are deleted when the browser context they were created in @@ -942,7 +954,8 @@ public LaunchPersistentContextOptions setHasTouch(boolean hasTouch) { /** * Whether to run browser in headless mode. More details for Chromium and Firefox. Defaults to {@code true}. + * href="https://hacks.mozilla.org/2017/12/using-headless-mode-in-firefox/">Firefox. Defaults to {@code true} unless + * the {@code devtools} option is {@code true}. */ public LaunchPersistentContextOptions setHeadless(boolean headless) { this.headless = headless; diff --git a/playwright/src/main/java/com/microsoft/playwright/Locator.java b/playwright/src/main/java/com/microsoft/playwright/Locator.java index 8e4317f4f..cba38f1e1 100644 --- a/playwright/src/main/java/com/microsoft/playwright/Locator.java +++ b/playwright/src/main/java/com/microsoft/playwright/Locator.java @@ -2661,7 +2661,8 @@ default void dblclick() { Locator describe(String description); /** * Returns locator description previously set with {@link com.microsoft.playwright.Locator#describe Locator.describe()}. - * Returns {@code null} if no custom description has been set. + * Returns {@code null} if no custom description has been set. Prefer {@code Locator.toString()} for a human-readable + * representation, as it uses the description when available. * *

Usage *

{@code
diff --git a/playwright/src/main/java/com/microsoft/playwright/Route.java b/playwright/src/main/java/com/microsoft/playwright/Route.java
index 472a9f9a4..e9bc75a7f 100644
--- a/playwright/src/main/java/com/microsoft/playwright/Route.java
+++ b/playwright/src/main/java/com/microsoft/playwright/Route.java
@@ -370,10 +370,9 @@ default void abort() {
    * matching handlers won't be invoked. Use {@link com.microsoft.playwright.Route#fallback Route.fallback()} If you want
    * next matching handler in the chain to be invoked.
    *
-   * 

NOTE: Some request headers are **forbidden** and cannot be overridden (for example, {@code Cookie}, {@code Host}, {@code - * Content-Length} and others, see this MDN page for full list). If - * an override is provided for a forbidden header, it will be ignored and the original request header will be used.To set custom cookies, use {@link com.microsoft.playwright.BrowserContext#addCookies BrowserContext.addCookies()}. + *

NOTE: The {@code Cookie} header cannot be overridden using this method. If a value is provided, it will be ignored, and the + * cookie will be loaded from the browser's cookie store. To set custom cookies, use {@link + * com.microsoft.playwright.BrowserContext#addCookies BrowserContext.addCookies()}. * * @since v1.8 */ @@ -403,10 +402,9 @@ default void resume() { * matching handlers won't be invoked. Use {@link com.microsoft.playwright.Route#fallback Route.fallback()} If you want * next matching handler in the chain to be invoked. * - *

NOTE: Some request headers are **forbidden** and cannot be overridden (for example, {@code Cookie}, {@code Host}, {@code - * Content-Length} and others, see this MDN page for full list). If - * an override is provided for a forbidden header, it will be ignored and the original request header will be used.To set custom cookies, use {@link com.microsoft.playwright.BrowserContext#addCookies BrowserContext.addCookies()}. + *

NOTE: The {@code Cookie} header cannot be overridden using this method. If a value is provided, it will be ignored, and the + * cookie will be loaded from the browser's cookie store. To set custom cookies, use {@link + * com.microsoft.playwright.BrowserContext#addCookies BrowserContext.addCookies()}. * * @since v1.8 */ diff --git a/playwright/src/main/java/com/microsoft/playwright/assertions/LocatorAssertions.java b/playwright/src/main/java/com/microsoft/playwright/assertions/LocatorAssertions.java index df0725d89..e541404af 100644 --- a/playwright/src/main/java/com/microsoft/playwright/assertions/LocatorAssertions.java +++ b/playwright/src/main/java/com/microsoft/playwright/assertions/LocatorAssertions.java @@ -989,7 +989,7 @@ default void containsClass(List expected) { *

Let's see how we can use the assertion: *

{@code
    * // ✓ Contains the right items in the right order
-   * assertThat(page.locator("ul > li")).containsText(new String[] {"Text 1", "Text 3"});
+   * assertThat(page.locator("ul > li")).containsText(new String[] {"Text 1", "Text 3", "Text 4"});
    *
    * // ✖ Wrong order
    * assertThat(page.locator("ul > li")).containsText(new String[] {"Text 3", "Text 2"});
@@ -1034,7 +1034,7 @@ default void containsText(String expected) {
    * 

Let's see how we can use the assertion: *

{@code
    * // ✓ Contains the right items in the right order
-   * assertThat(page.locator("ul > li")).containsText(new String[] {"Text 1", "Text 3"});
+   * assertThat(page.locator("ul > li")).containsText(new String[] {"Text 1", "Text 3", "Text 4"});
    *
    * // ✖ Wrong order
    * assertThat(page.locator("ul > li")).containsText(new String[] {"Text 3", "Text 2"});
@@ -1077,7 +1077,7 @@ default void containsText(String expected) {
    * 

Let's see how we can use the assertion: *

{@code
    * // ✓ Contains the right items in the right order
-   * assertThat(page.locator("ul > li")).containsText(new String[] {"Text 1", "Text 3"});
+   * assertThat(page.locator("ul > li")).containsText(new String[] {"Text 1", "Text 3", "Text 4"});
    *
    * // ✖ Wrong order
    * assertThat(page.locator("ul > li")).containsText(new String[] {"Text 3", "Text 2"});
@@ -1122,7 +1122,7 @@ default void containsText(Pattern expected) {
    * 

Let's see how we can use the assertion: *

{@code
    * // ✓ Contains the right items in the right order
-   * assertThat(page.locator("ul > li")).containsText(new String[] {"Text 1", "Text 3"});
+   * assertThat(page.locator("ul > li")).containsText(new String[] {"Text 1", "Text 3", "Text 4"});
    *
    * // ✖ Wrong order
    * assertThat(page.locator("ul > li")).containsText(new String[] {"Text 3", "Text 2"});
@@ -1165,7 +1165,7 @@ default void containsText(Pattern expected) {
    * 

Let's see how we can use the assertion: *

{@code
    * // ✓ Contains the right items in the right order
-   * assertThat(page.locator("ul > li")).containsText(new String[] {"Text 1", "Text 3"});
+   * assertThat(page.locator("ul > li")).containsText(new String[] {"Text 1", "Text 3", "Text 4"});
    *
    * // ✖ Wrong order
    * assertThat(page.locator("ul > li")).containsText(new String[] {"Text 3", "Text 2"});
@@ -1210,7 +1210,7 @@ default void containsText(String[] expected) {
    * 

Let's see how we can use the assertion: *

{@code
    * // ✓ Contains the right items in the right order
-   * assertThat(page.locator("ul > li")).containsText(new String[] {"Text 1", "Text 3"});
+   * assertThat(page.locator("ul > li")).containsText(new String[] {"Text 1", "Text 3", "Text 4"});
    *
    * // ✖ Wrong order
    * assertThat(page.locator("ul > li")).containsText(new String[] {"Text 3", "Text 2"});
@@ -1253,7 +1253,7 @@ default void containsText(String[] expected) {
    * 

Let's see how we can use the assertion: *

{@code
    * // ✓ Contains the right items in the right order
-   * assertThat(page.locator("ul > li")).containsText(new String[] {"Text 1", "Text 3"});
+   * assertThat(page.locator("ul > li")).containsText(new String[] {"Text 1", "Text 3", "Text 4"});
    *
    * // ✖ Wrong order
    * assertThat(page.locator("ul > li")).containsText(new String[] {"Text 3", "Text 2"});
@@ -1298,7 +1298,7 @@ default void containsText(Pattern[] expected) {
    * 

Let's see how we can use the assertion: *

{@code
    * // ✓ Contains the right items in the right order
-   * assertThat(page.locator("ul > li")).containsText(new String[] {"Text 1", "Text 3"});
+   * assertThat(page.locator("ul > li")).containsText(new String[] {"Text 1", "Text 3", "Text 4"});
    *
    * // ✖ Wrong order
    * assertThat(page.locator("ul > li")).containsText(new String[] {"Text 3", "Text 2"});
diff --git a/playwright/src/main/java/com/microsoft/playwright/impl/WebSocketRouteImpl.java b/playwright/src/main/java/com/microsoft/playwright/impl/WebSocketRouteImpl.java
index e39ba4a15..ab9ed40a0 100644
--- a/playwright/src/main/java/com/microsoft/playwright/impl/WebSocketRouteImpl.java
+++ b/playwright/src/main/java/com/microsoft/playwright/impl/WebSocketRouteImpl.java
@@ -160,9 +160,9 @@ protected void handleEvent(String event, JsonObject params) {
         sendMessageAsync("sendToPage", messageParams);
       }
     } else if ("closePage".equals(event)) {
-      Integer code = params.has("code") ? params.get("code").getAsInt() : null;
-      String reason = params.has("reason") ? params.get("reason").getAsString() : null;
-      boolean wasClean = params.has("wasClean") && params.get("wasClean").getAsBoolean();
+      int code = params.get("code").getAsInt();
+      String reason = params.get("reason").getAsString();
+      boolean wasClean = params.get("wasClean").getAsBoolean();
       if (onPageClose != null) {
         onPageClose.accept(code, reason);
       } else {
@@ -173,9 +173,9 @@ protected void handleEvent(String event, JsonObject params) {
         sendMessageAsync("closeServer", closeParams);
       }
     } else if ("closeServer".equals(event)) {
-      Integer code = params.has("code") ? params.get("code").getAsInt() : null;
-      String reason = params.has("reason") ? params.get("reason").getAsString() : null;
-      boolean wasClean = params.has("wasClean") && params.get("wasClean").getAsBoolean();
+      int code = params.get("code").getAsInt();
+      String reason = params.get("reason").getAsString();
+      boolean wasClean = params.get("wasClean").getAsBoolean();
       if (onServerClose != null) {
         onServerClose.accept(code, reason);
       } else {
diff --git a/playwright/src/test/java/com/microsoft/playwright/TestScreencast.java b/playwright/src/test/java/com/microsoft/playwright/TestScreencast.java
index 94847f337..7f816eade 100644
--- a/playwright/src/test/java/com/microsoft/playwright/TestScreencast.java
+++ b/playwright/src/test/java/com/microsoft/playwright/TestScreencast.java
@@ -79,8 +79,14 @@ void saveAsShouldThrowWhenNoVideoFrames(@TempDir Path videosDir) {
       if (!popup.isClosed()) {
         popup.waitForClose(() -> {});
       }
-      PlaywrightException e = assertThrows(PlaywrightException.class, () -> popup.video().saveAs(saveAsPath));
-      assertTrue(e.getMessage().contains("Page did not produce any video frames"), e.getMessage());
+      // WebKit pauses renderer before win.close() and actually writes something.
+      if (isWebKit()) {
+        popup.video().saveAs(saveAsPath);
+        assertTrue(Files.exists(saveAsPath));
+      } else {
+        PlaywrightException e = assertThrows(PlaywrightException.class, () -> popup.video().saveAs(saveAsPath));
+        assertTrue(e.getMessage().contains("Page did not produce any video frames"), e.getMessage());
+      }
     }
   }
 
diff --git a/playwright/src/test/java/com/microsoft/playwright/TestWorkers.java b/playwright/src/test/java/com/microsoft/playwright/TestWorkers.java
index 36170d681..379b7d116 100644
--- a/playwright/src/test/java/com/microsoft/playwright/TestWorkers.java
+++ b/playwright/src/test/java/com/microsoft/playwright/TestWorkers.java
@@ -193,9 +193,7 @@ void shouldFormatNumberUsingContextLocale() {
     page.navigate(server.EMPTY_PAGE);
     Worker worker = page.waitForWorker(() -> page.evaluate(
       "() => new Worker(URL.createObjectURL(new Blob(['console.log(1)'], {type: 'application/javascript'})))"));
-    // https://github.com/microsoft/playwright/issues/38919
-    String expected = isFirefox() ? "10,000.2" : "10\u00A0000,2";
-    assertEquals(expected, worker.evaluate("() => (10000.20).toLocaleString()"));
+    assertEquals("10\u00A0000,2", worker.evaluate("() => (10000.20).toLocaleString()"));
     context.close();
   }
 
diff --git a/playwright/src/test/java/com/microsoft/playwright/Utils.java b/playwright/src/test/java/com/microsoft/playwright/Utils.java
index 6ab8933a6..ad9f7d107 100644
--- a/playwright/src/test/java/com/microsoft/playwright/Utils.java
+++ b/playwright/src/test/java/com/microsoft/playwright/Utils.java
@@ -37,12 +37,24 @@
 import static org.junit.jupiter.api.Assertions.assertEquals;
 
 public class Utils {
+  private static final AtomicInteger nextUnusedPort = new AtomicInteger(9000);
+
+  private static boolean available(int port) {
+    try (ServerSocket ignored = new ServerSocket(port)) {
+      return true;
+    } catch (IOException ignored) {
+      return false;
+    }
+  }
+
   public static int nextFreePort() {
-    try (ServerSocket socket = new ServerSocket(0)) {
-      return socket.getLocalPort();
-    } catch (IOException e) {
-      throw new RuntimeException("Cannot find free port", e);
+    for (int i = 0; i < 100; i++) {
+      int port = nextUnusedPort.getAndIncrement();
+      if (available(port)) {
+        return port;
+      }
     }
+    throw new RuntimeException("Cannot find free port: " + nextUnusedPort.get());
   }
 
   static void assertJsonEquals(Object expected, Object actual) {
diff --git a/scripts/DRIVER_VERSION b/scripts/DRIVER_VERSION
index 79f82f6b8..755b1365f 100644
--- a/scripts/DRIVER_VERSION
+++ b/scripts/DRIVER_VERSION
@@ -1 +1 @@
-1.58.0
+1.57.0-beta-1764692940000
diff --git a/utils/docker/Dockerfile.jammy b/utils/docker/Dockerfile.jammy
index e66319a80..d2fccc1ed 100644
--- a/utils/docker/Dockerfile.jammy
+++ b/utils/docker/Dockerfile.jammy
@@ -10,7 +10,7 @@ ENV LC_ALL=C.UTF-8
 # === INSTALL JDK and Maven ===
 
 RUN apt-get update && \
-    apt-get install -y --no-install-recommends openjdk-25-jdk \
+    apt-get install -y --no-install-recommends openjdk-21-jdk \
     # Install utilities required for downloading browsers
     wget \
     # Install utilities required for downloading driver
@@ -22,13 +22,13 @@ RUN apt-get update && \
     adduser pwuser
 
 # Ubuntu 22.04 and earlier come with Maven 3.6.3 which fails with
-# Java 25, so we install latest Maven from Apache instead.
-RUN VERSION=3.9.12 && \
+# Java 21, so we install latest Maven from Apache instead.
+RUN VERSION=3.9.6 && \
     wget -O - https://archive.apache.org/dist/maven/maven-3/$VERSION/binaries/apache-maven-$VERSION-bin.tar.gz | tar zxfv - -C /opt/ && \
     ln -s /opt/apache-maven-$VERSION/bin/mvn /usr/local/bin/
 
 ARG PW_TARGET_ARCH
-ENV JAVA_HOME=/usr/lib/jvm/java-25-openjdk-${PW_TARGET_ARCH}
+ENV JAVA_HOME=/usr/lib/jvm/java-21-openjdk-${PW_TARGET_ARCH}
 
 # === BAKE BROWSERS INTO IMAGE ===
 
diff --git a/utils/docker/Dockerfile.noble b/utils/docker/Dockerfile.noble
index e0173bd6e..5ff4bceb4 100644
--- a/utils/docker/Dockerfile.noble
+++ b/utils/docker/Dockerfile.noble
@@ -10,7 +10,7 @@ ENV LC_ALL=C.UTF-8
 # === INSTALL JDK and Maven ===
 
 RUN apt-get update && \
-    apt-get install -y --no-install-recommends openjdk-25-jdk \
+    apt-get install -y --no-install-recommends openjdk-21-jdk \
     # Install utilities required for downloading browsers
     wget \
     # Install utilities required for downloading driver
@@ -22,13 +22,13 @@ RUN apt-get update && \
     adduser pwuser
 
 # Ubuntu 22.04 and earlier come with Maven 3.6.3 which fails with
-# Java 25, so we install latest Maven from Apache instead.
-RUN VERSION=3.9.12 && \
+# Java 21, so we install latest Maven from Apache instead.
+RUN VERSION=3.9.6 && \
     wget -O - https://archive.apache.org/dist/maven/maven-3/$VERSION/binaries/apache-maven-$VERSION-bin.tar.gz | tar zxfv - -C /opt/ && \
     ln -s /opt/apache-maven-$VERSION/bin/mvn /usr/local/bin/
 
 ARG PW_TARGET_ARCH
-ENV JAVA_HOME=/usr/lib/jvm/java-25-openjdk-${PW_TARGET_ARCH}
+ENV JAVA_HOME=/usr/lib/jvm/java-21-openjdk-${PW_TARGET_ARCH}
 
 # === BAKE BROWSERS INTO IMAGE ===