diff --git a/playwright/src/main/java/com/microsoft/playwright/Download.java b/playwright/src/main/java/com/microsoft/playwright/Download.java index b5105115..0d93c8bc 100644 --- a/playwright/src/main/java/com/microsoft/playwright/Download.java +++ b/playwright/src/main/java/com/microsoft/playwright/Download.java @@ -45,7 +45,7 @@ public interface Download { */ void cancel(); /** - * Returns readable stream for current download or {@code null} if download failed. + * Returns a readable stream for a successful download, or throws for a failed/canceled download. * * @since v1.8 */ @@ -69,8 +69,8 @@ public interface Download { */ Page page(); /** - * Returns path to the downloaded file in case of successful download. The method will wait for the download to finish if - * necessary. The method throws when connected remotely. + * Returns path to the downloaded file for a successful download, or throws for a failed/canceled download. The method will + * wait for the download to finish if necessary. The method throws when connected remotely. * *
Note that the download's file name is a random GUID, use {@link Download#suggestedFilename Download.suggestedFilename()} * to get suggested file name. diff --git a/playwright/src/main/java/com/microsoft/playwright/ElementHandle.java b/playwright/src/main/java/com/microsoft/playwright/ElementHandle.java index 83be107d..965783f8 100644 --- a/playwright/src/main/java/com/microsoft/playwright/ElementHandle.java +++ b/playwright/src/main/java/com/microsoft/playwright/ElementHandle.java @@ -1411,13 +1411,17 @@ public interface ElementHandle extends JSHandle { * *
Since {@code eventInit} is event-specific, please refer to the events documentation for the lists of initial properties: *
You can also specify {@code JSHandle} as the property value if you want live objects to be passed into the event: @@ -1451,13 +1455,17 @@ public interface ElementHandle extends JSHandle { * *
Since {@code eventInit} is event-specific, please refer to the events documentation for the lists of initial properties: *
You can also specify {@code JSHandle} as the property value if you want live objects to be passed into the event: diff --git a/playwright/src/main/java/com/microsoft/playwright/Frame.java b/playwright/src/main/java/com/microsoft/playwright/Frame.java index ca6bf5a5..dc641ff4 100644 --- a/playwright/src/main/java/com/microsoft/playwright/Frame.java +++ b/playwright/src/main/java/com/microsoft/playwright/Frame.java @@ -2582,13 +2582,17 @@ public interface Frame { * *
Since {@code eventInit} is event-specific, please refer to the events documentation for the lists of initial properties: *
You can also specify {@code JSHandle} as the property value if you want live objects to be passed into the event: @@ -2624,13 +2628,17 @@ public interface Frame { * *
Since {@code eventInit} is event-specific, please refer to the events documentation for the lists of initial properties: *
You can also specify {@code JSHandle} as the property value if you want live objects to be passed into the event: @@ -2665,13 +2673,17 @@ public interface Frame { * *
Since {@code eventInit} is event-specific, please refer to the events documentation for the lists of initial properties: *
You can also specify {@code JSHandle} as the property value if you want live objects to be passed into the event: diff --git a/playwright/src/main/java/com/microsoft/playwright/Locator.java b/playwright/src/main/java/com/microsoft/playwright/Locator.java index 455fd77c..a55c62a9 100644 --- a/playwright/src/main/java/com/microsoft/playwright/Locator.java +++ b/playwright/src/main/java/com/microsoft/playwright/Locator.java @@ -2471,13 +2471,17 @@ public interface Locator { * *
Since {@code eventInit} is event-specific, please refer to the events documentation for the lists of initial properties: *
You can also specify {@code JSHandle} as the property value if you want live objects to be passed into the event: @@ -2516,13 +2520,17 @@ public interface Locator { * *
Since {@code eventInit} is event-specific, please refer to the events documentation for the lists of initial properties: *
You can also specify {@code JSHandle} as the property value if you want live objects to be passed into the event: @@ -2560,13 +2568,17 @@ public interface Locator { * *
Since {@code eventInit} is event-specific, please refer to the events documentation for the lists of initial properties: *
You can also specify {@code JSHandle} as the property value if you want live objects to be passed into the event: diff --git a/playwright/src/main/java/com/microsoft/playwright/Page.java b/playwright/src/main/java/com/microsoft/playwright/Page.java index faa89b07..751fe68e 100644 --- a/playwright/src/main/java/com/microsoft/playwright/Page.java +++ b/playwright/src/main/java/com/microsoft/playwright/Page.java @@ -3869,13 +3869,17 @@ public interface Page extends AutoCloseable { * *
Since {@code eventInit} is event-specific, please refer to the events documentation for the lists of initial properties: *
You can also specify {@code JSHandle} as the property value if you want live objects to be passed into the event: @@ -3911,13 +3915,17 @@ public interface Page extends AutoCloseable { * *
Since {@code eventInit} is event-specific, please refer to the events documentation for the lists of initial properties: *
You can also specify {@code JSHandle} as the property value if you want live objects to be passed into the event: @@ -3952,13 +3960,17 @@ public interface Page extends AutoCloseable { * *
Since {@code eventInit} is event-specific, please refer to the events documentation for the lists of initial properties: *
You can also specify {@code JSHandle} as the property value if you want live objects to be passed into the event: 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 f6295259..f3441965 100644 --- a/playwright/src/main/java/com/microsoft/playwright/assertions/LocatorAssertions.java +++ b/playwright/src/main/java/com/microsoft/playwright/assertions/LocatorAssertions.java @@ -254,11 +254,24 @@ public interface LocatorAssertions { } } class HasAttributeOptions { + /** + * Whether to perform case-insensitive match. {@code ignoreCase} option takes precedence over the corresponding regular + * expression flag if specified. + */ + public Boolean ignoreCase; /** * Time to retry the assertion for in milliseconds. Defaults to {@code 5000}. */ public Double timeout; + /** + * Whether to perform case-insensitive match. {@code ignoreCase} option takes precedence over the corresponding regular + * expression flag if specified. + */ + public HasAttributeOptions setIgnoreCase(boolean ignoreCase) { + this.ignoreCase = ignoreCase; + return this; + } /** * Time to retry the assertion for in milliseconds. Defaults to {@code 5000}. */ @@ -713,6 +726,11 @@ public interface LocatorAssertions { * Ensures the {@code Locator} points to an element that contains the given text. You can use regular expressions for the * value as well. * + *
**Details** + * + *
When {@code expected} parameter is a string, Playwright will normalize whitespaces and line breaks both in the actual + * text and in the expected string before matching. When regular expression is used, the actual text is matched as is. + * *
**Usage** *
{@code
* assertThat(page.locator(".title")).containsText("substring");
@@ -753,6 +771,11 @@ public interface LocatorAssertions {
* Ensures the {@code Locator} points to an element that contains the given text. You can use regular expressions for the
* value as well.
*
+ * **Details**
+ *
+ *
When {@code expected} parameter is a string, Playwright will normalize whitespaces and line breaks both in the actual
+ * text and in the expected string before matching. When regular expression is used, the actual text is matched as is.
+ *
*
**Usage**
*
{@code
* assertThat(page.locator(".title")).containsText("substring");
@@ -791,6 +814,11 @@ public interface LocatorAssertions {
* Ensures the {@code Locator} points to an element that contains the given text. You can use regular expressions for the
* value as well.
*
+ * **Details**
+ *
+ *
When {@code expected} parameter is a string, Playwright will normalize whitespaces and line breaks both in the actual
+ * text and in the expected string before matching. When regular expression is used, the actual text is matched as is.
+ *
*
**Usage**
*
{@code
* assertThat(page.locator(".title")).containsText("substring");
@@ -831,6 +859,11 @@ public interface LocatorAssertions {
* Ensures the {@code Locator} points to an element that contains the given text. You can use regular expressions for the
* value as well.
*
+ * **Details**
+ *
+ *
When {@code expected} parameter is a string, Playwright will normalize whitespaces and line breaks both in the actual
+ * text and in the expected string before matching. When regular expression is used, the actual text is matched as is.
+ *
*
**Usage**
*
{@code
* assertThat(page.locator(".title")).containsText("substring");
@@ -869,6 +902,11 @@ public interface LocatorAssertions {
* Ensures the {@code Locator} points to an element that contains the given text. You can use regular expressions for the
* value as well.
*
+ * **Details**
+ *
+ *
When {@code expected} parameter is a string, Playwright will normalize whitespaces and line breaks both in the actual
+ * text and in the expected string before matching. When regular expression is used, the actual text is matched as is.
+ *
*
**Usage**
*
{@code
* assertThat(page.locator(".title")).containsText("substring");
@@ -909,6 +947,11 @@ public interface LocatorAssertions {
* Ensures the {@code Locator} points to an element that contains the given text. You can use regular expressions for the
* value as well.
*
+ * **Details**
+ *
+ *
When {@code expected} parameter is a string, Playwright will normalize whitespaces and line breaks both in the actual
+ * text and in the expected string before matching. When regular expression is used, the actual text is matched as is.
+ *
*
**Usage**
*
{@code
* assertThat(page.locator(".title")).containsText("substring");
@@ -947,6 +990,11 @@ public interface LocatorAssertions {
* Ensures the {@code Locator} points to an element that contains the given text. You can use regular expressions for the
* value as well.
*
+ * **Details**
+ *
+ *
When {@code expected} parameter is a string, Playwright will normalize whitespaces and line breaks both in the actual
+ * text and in the expected string before matching. When regular expression is used, the actual text is matched as is.
+ *
*
**Usage**
*
{@code
* assertThat(page.locator(".title")).containsText("substring");
@@ -987,6 +1035,11 @@ public interface LocatorAssertions {
* Ensures the {@code Locator} points to an element that contains the given text. You can use regular expressions for the
* value as well.
*
+ * **Details**
+ *
+ *
When {@code expected} parameter is a string, Playwright will normalize whitespaces and line breaks both in the actual
+ * text and in the expected string before matching. When regular expression is used, the actual text is matched as is.
+ *
*
**Usage**
*
{@code
* assertThat(page.locator(".title")).containsText("substring");
@@ -1405,6 +1458,11 @@ public interface LocatorAssertions {
* Ensures the {@code Locator} points to an element with the given text. You can use regular expressions for the value as
* well.
*
+ * **Details**
+ *
+ *
When {@code expected} parameter is a string, Playwright will normalize whitespaces and line breaks both in the actual
+ * text and in the expected string before matching. When regular expression is used, the actual text is matched as is.
+ *
*
**Usage**
*
{@code
* assertThat(page.locator(".title")).hasText("Welcome, Test User");
@@ -1445,6 +1503,11 @@ public interface LocatorAssertions {
* Ensures the {@code Locator} points to an element with the given text. You can use regular expressions for the value as
* well.
*
+ * **Details**
+ *
+ *
When {@code expected} parameter is a string, Playwright will normalize whitespaces and line breaks both in the actual
+ * text and in the expected string before matching. When regular expression is used, the actual text is matched as is.
+ *
*
**Usage**
*
{@code
* assertThat(page.locator(".title")).hasText("Welcome, Test User");
@@ -1483,6 +1546,11 @@ public interface LocatorAssertions {
* Ensures the {@code Locator} points to an element with the given text. You can use regular expressions for the value as
* well.
*
+ * **Details**
+ *
+ *
When {@code expected} parameter is a string, Playwright will normalize whitespaces and line breaks both in the actual
+ * text and in the expected string before matching. When regular expression is used, the actual text is matched as is.
+ *
*
**Usage**
*
{@code
* assertThat(page.locator(".title")).hasText("Welcome, Test User");
@@ -1523,6 +1591,11 @@ public interface LocatorAssertions {
* Ensures the {@code Locator} points to an element with the given text. You can use regular expressions for the value as
* well.
*
+ * **Details**
+ *
+ *
When {@code expected} parameter is a string, Playwright will normalize whitespaces and line breaks both in the actual
+ * text and in the expected string before matching. When regular expression is used, the actual text is matched as is.
+ *
*
**Usage**
*
{@code
* assertThat(page.locator(".title")).hasText("Welcome, Test User");
@@ -1561,6 +1634,11 @@ public interface LocatorAssertions {
* Ensures the {@code Locator} points to an element with the given text. You can use regular expressions for the value as
* well.
*
+ * **Details**
+ *
+ *
When {@code expected} parameter is a string, Playwright will normalize whitespaces and line breaks both in the actual
+ * text and in the expected string before matching. When regular expression is used, the actual text is matched as is.
+ *
*
**Usage**
*
{@code
* assertThat(page.locator(".title")).hasText("Welcome, Test User");
@@ -1601,6 +1679,11 @@ public interface LocatorAssertions {
* Ensures the {@code Locator} points to an element with the given text. You can use regular expressions for the value as
* well.
*
+ * **Details**
+ *
+ *
When {@code expected} parameter is a string, Playwright will normalize whitespaces and line breaks both in the actual
+ * text and in the expected string before matching. When regular expression is used, the actual text is matched as is.
+ *
*
**Usage**
*
{@code
* assertThat(page.locator(".title")).hasText("Welcome, Test User");
@@ -1639,6 +1722,11 @@ public interface LocatorAssertions {
* Ensures the {@code Locator} points to an element with the given text. You can use regular expressions for the value as
* well.
*
+ * **Details**
+ *
+ *
When {@code expected} parameter is a string, Playwright will normalize whitespaces and line breaks both in the actual
+ * text and in the expected string before matching. When regular expression is used, the actual text is matched as is.
+ *
*
**Usage**
*
{@code
* assertThat(page.locator(".title")).hasText("Welcome, Test User");
@@ -1679,6 +1767,11 @@ public interface LocatorAssertions {
* Ensures the {@code Locator} points to an element with the given text. You can use regular expressions for the value as
* well.
*
+ * **Details**
+ *
+ *
When {@code expected} parameter is a string, Playwright will normalize whitespaces and line breaks both in the actual
+ * text and in the expected string before matching. When regular expression is used, the actual text is matched as is.
+ *
*
**Usage**
*
{@code
* assertThat(page.locator(".title")).hasText("Welcome, Test User");
diff --git a/playwright/src/main/java/com/microsoft/playwright/impl/Connection.java b/playwright/src/main/java/com/microsoft/playwright/impl/Connection.java
index d2776818..ac9ace1f 100644
--- a/playwright/src/main/java/com/microsoft/playwright/impl/Connection.java
+++ b/playwright/src/main/java/com/microsoft/playwright/impl/Connection.java
@@ -248,8 +248,6 @@ public class Connection {
String callLog = formatCallLog(message.log);
if (message.error.error == null) {
callback.completeExceptionally(new PlaywrightException(message.error + callLog));
- } else if ("Expect".equals(message.error.error.name)) {
- callback.complete(message.result);
} else if ("TimeoutError".equals(message.error.error.name)) {
callback.completeExceptionally(new TimeoutError(message.error.error + callLog));
} else if ("TargetClosedError".equals(message.error.error.name)) {
diff --git a/playwright/src/main/java/com/microsoft/playwright/impl/LocatorAssertionsImpl.java b/playwright/src/main/java/com/microsoft/playwright/impl/LocatorAssertionsImpl.java
index 45f7935d..04585a5d 100644
--- a/playwright/src/main/java/com/microsoft/playwright/impl/LocatorAssertionsImpl.java
+++ b/playwright/src/main/java/com/microsoft/playwright/impl/LocatorAssertionsImpl.java
@@ -86,12 +86,14 @@ public class LocatorAssertionsImpl extends AssertionsBase implements LocatorAsse
public void hasAttribute(String name, String text, HasAttributeOptions options) {
ExpectedTextValue expected = new ExpectedTextValue();
expected.string = text;
+ expected.ignoreCase = shouldIgnoreCase(options);
hasAttribute(name, expected, text, options);
}
@Override
public void hasAttribute(String name, Pattern pattern, HasAttributeOptions options) {
ExpectedTextValue expected = expectedRegex(pattern);
+ expected.ignoreCase = shouldIgnoreCase(options);
hasAttribute(name, expected, pattern, options);
}
diff --git a/playwright/src/test/java/com/microsoft/playwright/TestElementHandleConvenience.java b/playwright/src/test/java/com/microsoft/playwright/TestElementHandleConvenience.java
index f446439c..84b1cb36 100644
--- a/playwright/src/test/java/com/microsoft/playwright/TestElementHandleConvenience.java
+++ b/playwright/src/test/java/com/microsoft/playwright/TestElementHandleConvenience.java
@@ -18,6 +18,8 @@ package com.microsoft.playwright;
import org.junit.jupiter.api.Test;
+import java.util.Collections;
+
import static org.junit.jupiter.api.Assertions.*;
public class TestElementHandleConvenience extends TestBase {
@@ -35,6 +37,17 @@ public class TestElementHandleConvenience extends TestBase {
assertEquals("JSHandle@", check.toString());
}
+ @Test
+ void shouldHaveANicePreviewForNonAsciiAttributesChildren() {
+ page.navigate(server.EMPTY_PAGE);
+ String text = String.join("", Collections.nCopies(100, "😛"));
+ page.setContent("" + text + "");
+ ElementHandle handle = page.querySelector("div");
+ context.waitForCondition(() -> "JSHandle@😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛…"
+ .equals(handle.toString()), new BrowserContext.WaitForConditionOptions().setTimeout(5_000));
+ assertEquals("JSHandle@😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛😛…", handle.toString());
+ }
+
@Test
void getAttributeShouldWork() {
page.navigate(server.PREFIX + "/dom.html");
diff --git a/playwright/src/test/java/com/microsoft/playwright/TestFirefoxLauncher.java b/playwright/src/test/java/com/microsoft/playwright/TestFirefoxLauncher.java
index 6d097c5b..b9878ccf 100644
--- a/playwright/src/test/java/com/microsoft/playwright/TestFirefoxLauncher.java
+++ b/playwright/src/test/java/com/microsoft/playwright/TestFirefoxLauncher.java
@@ -19,10 +19,14 @@ package com.microsoft.playwright;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.EnabledIf;
+import org.junit.jupiter.api.io.TempDir;
+
+import java.nio.file.Path;
import static com.microsoft.playwright.Utils.mapOf;
import static org.junit.jupiter.api.Assertions.*;
+@EnabledIf(value="com.microsoft.playwright.TestBase#isFirefox", disabledReason="skip")
public class TestFirefoxLauncher extends TestBase {
@Override
@@ -37,7 +41,6 @@ public class TestFirefoxLauncher extends TestBase {
}
@Test
- @EnabledIf(value="com.microsoft.playwright.TestBase#isFirefox", disabledReason="skip")
void shouldPassFirefoxUserPreferences() {
BrowserType.LaunchOptions options = new BrowserType.LaunchOptions().setFirefoxUserPrefs(
mapOf(
@@ -49,4 +52,19 @@ public class TestFirefoxLauncher extends TestBase {
PlaywrightException e = assertThrows(PlaywrightException.class, () -> page.navigate("http://example.com"));
assertTrue(e.getMessage().contains("NS_ERROR_PROXY_CONNECTION_REFUSED"));
}
+
+ @Test
+ void shouldPassFirefoxUserPreferencesInPersistent(@TempDir Path tmpDir) {
+ BrowserType.LaunchPersistentContextOptions options = new BrowserType.LaunchPersistentContextOptions().setFirefoxUserPrefs(
+ mapOf(
+ "network.proxy.type", 1,
+ "network.proxy.http", "127.0.0.1",
+ "network.proxy.http_port", 3333));
+ initBrowserType();
+ context = browserType.launchPersistentContext(tmpDir.resolve("user-data-dir"), options);
+ assertNotNull(context);
+ Page page = context.pages().get(0);
+ PlaywrightException e = assertThrows(PlaywrightException.class, () -> page.navigate("http://example.com"));
+ assertTrue(e.getMessage().contains("NS_ERROR_PROXY_CONNECTION_REFUSED"));
+ }
}
diff --git a/playwright/src/test/java/com/microsoft/playwright/TestLocatorAssertions.java b/playwright/src/test/java/com/microsoft/playwright/TestLocatorAssertions.java
index 27c6aa51..f3b48520 100644
--- a/playwright/src/test/java/com/microsoft/playwright/TestLocatorAssertions.java
+++ b/playwright/src/test/java/com/microsoft/playwright/TestLocatorAssertions.java
@@ -246,6 +246,14 @@ public class TestLocatorAssertions extends TestBase {
assertTrue(e.getMessage().contains("Locator expected to have text"), e.getMessage());
}
+ @Test
+ void hasAttributeTextIgnoreCase() {
+ page.setContent("Text content");
+ Locator locator = page.locator("#NoDe");
+ assertThat(locator).hasAttribute("id", "node", new LocatorAssertions.HasAttributeOptions().setIgnoreCase(true));
+ assertThat(locator).not().hasAttribute("id", "node");
+ }
+
@Test
void hasAttributeTextPass() {
page.setContent("Text content");
diff --git a/scripts/CLI_VERSION b/scripts/CLI_VERSION
index a42ff661..e613c817 100644
--- a/scripts/CLI_VERSION
+++ b/scripts/CLI_VERSION
@@ -1 +1 @@
-1.40.0-alpha-nov-13-2023
+1.40.0-alpha-1699985898000