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 e9bc75a7f..472a9f9a4 100644
--- a/playwright/src/main/java/com/microsoft/playwright/Route.java
+++ b/playwright/src/main/java/com/microsoft/playwright/Route.java
@@ -370,9 +370,10 @@ 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: 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()}.
+ *
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()}.
*
* @since v1.8
*/
@@ -402,9 +403,10 @@ 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: 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()}.
+ *
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()}.
*
* @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 e541404af..df0725d89 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", "Text 4"});
+ * assertThat(page.locator("ul > li")).containsText(new String[] {"Text 1", "Text 3"});
*
* // ✖ 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", "Text 4"});
+ * assertThat(page.locator("ul > li")).containsText(new String[] {"Text 1", "Text 3"});
*
* // ✖ 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", "Text 4"});
+ * assertThat(page.locator("ul > li")).containsText(new String[] {"Text 1", "Text 3"});
*
* // ✖ 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", "Text 4"});
+ * assertThat(page.locator("ul > li")).containsText(new String[] {"Text 1", "Text 3"});
*
* // ✖ 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", "Text 4"});
+ * assertThat(page.locator("ul > li")).containsText(new String[] {"Text 1", "Text 3"});
*
* // ✖ 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", "Text 4"});
+ * assertThat(page.locator("ul > li")).containsText(new String[] {"Text 1", "Text 3"});
*
* // ✖ 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", "Text 4"});
+ * assertThat(page.locator("ul > li")).containsText(new String[] {"Text 1", "Text 3"});
*
* // ✖ 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", "Text 4"});
+ * assertThat(page.locator("ul > li")).containsText(new String[] {"Text 1", "Text 3"});
*
* // ✖ Wrong order
* assertThat(page.locator("ul > li")).containsText(new String[] {"Text 3", "Text 2"});
diff --git a/playwright/src/test/java/com/microsoft/playwright/TestScreencast.java b/playwright/src/test/java/com/microsoft/playwright/TestScreencast.java
index 7f816eade..94847f337 100644
--- a/playwright/src/test/java/com/microsoft/playwright/TestScreencast.java
+++ b/playwright/src/test/java/com/microsoft/playwright/TestScreencast.java
@@ -79,14 +79,8 @@ void saveAsShouldThrowWhenNoVideoFrames(@TempDir Path videosDir) {
if (!popup.isClosed()) {
popup.waitForClose(() -> {});
}
- // 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());
- }
+ 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 379b7d116..36170d681 100644
--- a/playwright/src/test/java/com/microsoft/playwright/TestWorkers.java
+++ b/playwright/src/test/java/com/microsoft/playwright/TestWorkers.java
@@ -193,7 +193,9 @@ 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'})))"));
- assertEquals("10\u00A0000,2", worker.evaluate("() => (10000.20).toLocaleString()"));
+ // https://github.com/microsoft/playwright/issues/38919
+ String expected = isFirefox() ? "10,000.2" : "10\u00A0000,2";
+ assertEquals(expected, 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 ad9f7d107..6ab8933a6 100644
--- a/playwright/src/test/java/com/microsoft/playwright/Utils.java
+++ b/playwright/src/test/java/com/microsoft/playwright/Utils.java
@@ -37,24 +37,12 @@
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() {
- for (int i = 0; i < 100; i++) {
- int port = nextUnusedPort.getAndIncrement();
- if (available(port)) {
- return port;
- }
+ try (ServerSocket socket = new ServerSocket(0)) {
+ return socket.getLocalPort();
+ } catch (IOException e) {
+ throw new RuntimeException("Cannot find free port", e);
}
- 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 755b1365f..79f82f6b8 100644
--- a/scripts/DRIVER_VERSION
+++ b/scripts/DRIVER_VERSION
@@ -1 +1 @@
-1.57.0-beta-1764692940000
+1.58.0