diff --git a/README.md b/README.md index 4c91f355..b49ceeb3 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ Playwright is a Java library to automate [Chromium](https://www.chromium.org/Hom | | Linux | macOS | Windows | | :--- | :---: | :---: | :---: | -| Chromium 105.0.5195.52 | :white_check_mark: | :white_check_mark: | :white_check_mark: | +| Chromium 106.0.5249.21 | :white_check_mark: | :white_check_mark: | :white_check_mark: | | WebKit 16.0 | ✅ | ✅ | ✅ | | Firefox 104.0 | :white_check_mark: | :white_check_mark: | :white_check_mark: | 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 34069cfe..d7109771 100644 --- a/playwright/src/main/java/com/microsoft/playwright/assertions/LocatorAssertions.java +++ b/playwright/src/main/java/com/microsoft/playwright/assertions/LocatorAssertions.java @@ -72,11 +72,16 @@ public interface LocatorAssertions { } } class IsEditableOptions { + public Boolean editable; /** * Time to retry the assertion for. */ public Double timeout; + public IsEditableOptions setEditable(boolean editable) { + this.editable = editable; + return this; + } /** * Time to retry the assertion for. */ @@ -100,11 +105,16 @@ public interface LocatorAssertions { } } class IsEnabledOptions { + public Boolean enabled; /** * Time to retry the assertion for. */ public Double timeout; + public IsEnabledOptions setEnabled(boolean enabled) { + this.enabled = enabled; + return this; + } /** * Time to retry the assertion for. */ @@ -456,8 +466,8 @@ public interface LocatorAssertions { */ void isFocused(IsFocusedOptions options); /** - * Ensures the {@code Locator} points to a hidden DOM node, which is the opposite of visible. + * Ensures that {@code Locator} either does not resolve to any DOM node, or resolves to a non-visible one. *
{@code
    * assertThat(page.locator(".my-element")).isHidden();
    * }
@@ -466,16 +476,16 @@ public interface LocatorAssertions { isHidden(null); } /** - * Ensures the {@code Locator} points to a hidden DOM node, which is the opposite of visible. + * Ensures that {@code Locator} either does not resolve to any DOM node, or resolves to a non-visible one. *
{@code
    * assertThat(page.locator(".my-element")).isHidden();
    * }
*/ void isHidden(IsHiddenOptions options); /** - * Ensures the {@code Locator} points to a visible DOM - * node. + * Ensures that {@code Locator} points to an attached + * and visible DOM node. *
{@code
    * assertThat(page.locator(".my-element")).isVisible();
    * }
@@ -484,8 +494,8 @@ public interface LocatorAssertions { isVisible(null); } /** - * Ensures the {@code Locator} points to a visible DOM - * node. + * Ensures that {@code Locator} points to an attached + * and visible DOM node. *
{@code
    * assertThat(page.locator(".my-element")).isVisible();
    * }
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 1a2aba41..efc87175 100644 --- a/playwright/src/main/java/com/microsoft/playwright/impl/LocatorAssertionsImpl.java +++ b/playwright/src/main/java/com/microsoft/playwright/impl/LocatorAssertionsImpl.java @@ -310,7 +310,9 @@ public class LocatorAssertionsImpl extends AssertionsBase implements LocatorAsse @Override public void isEditable(IsEditableOptions options) { - expectTrue("to.be.editable", "Locator expected to be editable", convertType(options, FrameExpectOptions.class)); + FrameExpectOptions frameOptions = convertType(options, FrameExpectOptions.class); + boolean editable = options == null || options.editable == null || options.editable == true; + expectTrue(editable ? "to.be.editable" : "to.be.readonly", "Locator expected to be editable", frameOptions); } @Override @@ -320,7 +322,9 @@ public class LocatorAssertionsImpl extends AssertionsBase implements LocatorAsse @Override public void isEnabled(IsEnabledOptions options) { - expectTrue("to.be.enabled", "Locator expected to be enabled", convertType(options, FrameExpectOptions.class)); + FrameExpectOptions frameOptions = convertType(options, FrameExpectOptions.class); + boolean enabled = options == null || options.enabled == null || options.enabled == true; + expectTrue(enabled ? "to.be.enabled" : "to.be.disabled", "Locator expected to be enabled", frameOptions); } @Override diff --git a/playwright/src/test/java/com/microsoft/playwright/TestBrowserContextFetch.java b/playwright/src/test/java/com/microsoft/playwright/TestBrowserContextFetch.java index 5eac139a..a8cca2e2 100644 --- a/playwright/src/test/java/com/microsoft/playwright/TestBrowserContextFetch.java +++ b/playwright/src/test/java/com/microsoft/playwright/TestBrowserContextFetch.java @@ -573,12 +573,9 @@ public class TestBrowserContextFetch extends TestBase { } @Test - void shouldThrowWhenDataPassedForUnsupportedRequest() { - PlaywrightException e = assertThrows(PlaywrightException.class, () -> { - context.request().fetch(server.EMPTY_PAGE, RequestOptions.create() - .setMethod("GET").setData("bar")); - }); - assertTrue(e.getMessage().contains("Method GET does not accept post data"), e.getMessage()); + void shouldNotThrowWhenDataPassedForUnsupportedRequest() { + context.request().fetch(server.EMPTY_PAGE, RequestOptions.create() + .setMethod("GET").setData("bar")); } @Test diff --git a/playwright/src/test/java/com/microsoft/playwright/TestDownload.java b/playwright/src/test/java/com/microsoft/playwright/TestDownload.java index 32c2965e..be942cf8 100644 --- a/playwright/src/test/java/com/microsoft/playwright/TestDownload.java +++ b/playwright/src/test/java/com/microsoft/playwright/TestDownload.java @@ -102,9 +102,8 @@ public class TestDownload extends TestBase { assertTrue(error[0].getMessage().contains("Download is starting")); assertEquals("about:blank", page.url()); } else { - assertNotNull(response[0]); - assertEquals(200, response[0].status()); - assertEquals(server.PREFIX + "/download", page.url()); + assertNotNull(error[0]); + assertTrue(error[0].getMessage().contains("Download is starting")); } page.close(); } diff --git a/playwright/src/test/java/com/microsoft/playwright/TestLocatorAssertions.java b/playwright/src/test/java/com/microsoft/playwright/TestLocatorAssertions.java index 242f02b1..dad50291 100644 --- a/playwright/src/test/java/com/microsoft/playwright/TestLocatorAssertions.java +++ b/playwright/src/test/java/com/microsoft/playwright/TestLocatorAssertions.java @@ -757,6 +757,33 @@ public class TestLocatorAssertions extends TestBase { assertTrue(e.getMessage().contains("Locator expected not to be editable"), e.getMessage()); } + @Test + void isEditableWithNot() { + page.setContent(""); + Locator locator = page.locator("input"); + assertThat(locator).not().isEditable(); + } + + @Test + void isEditableWithEditableTrue() { + page.setContent(""); + Locator locator = page.locator("input"); + assertThat(locator).isEditable(new LocatorAssertions.IsEditableOptions().setEditable(true)); + } + + @Test + void isEditableWithEditableFalse() { + page.setContent(""); + Locator locator = page.locator("input"); + assertThat(locator).isEditable(new LocatorAssertions.IsEditableOptions().setEditable(false)); + } + + @Test + void isEditableWithNotAndEditableFalse() { + page.setContent(""); + Locator locator = page.locator("input"); + assertThat(locator).not().isEditable(new LocatorAssertions.IsEditableOptions().setEditable(false)); + } @Test void isEmptyPass() { @@ -820,6 +847,47 @@ public class TestLocatorAssertions extends TestBase { assertTrue(e.getMessage().contains("Locator expected not to be enabled"), e.getMessage()); } + @Test + void isEnabledTrue() { + page.setContent(""); + Locator locator = page.locator("button"); + assertThat(locator).isEnabled(new LocatorAssertions.IsEnabledOptions().setEnabled(true)); + } + + @Test + void isEnabledFalse() { + page.setContent(""); + Locator locator = page.locator("button"); + assertThat(locator).isEnabled(new LocatorAssertions.IsEnabledOptions().setEnabled(false)); + } + + @Test + void isEnabledEventually() { + page.setContent(""); + Locator locator = page.locator("button"); + locator.evaluate("e => setTimeout(() => {\n" + + " e.removeAttribute('disabled');\n" + + "}, 500);\n"); + assertThat(locator).isEnabled(); + } + + @Test + void isEnabledEventuallyWithNot() { + page.setContent(""); + Locator locator = page.locator("button"); + locator.evaluate("e => setTimeout(() => {\n" + + " e.setAttribute('disabled', '');\n" + + "}, 500);\n"); + assertThat(locator).not().isEnabled(); + } + + @Test + void isEnabledWithNotAndEnabledFalse() { + page.setContent(""); + Locator locator = page.locator("button"); + assertThat(locator).not().isEnabled(new LocatorAssertions.IsEnabledOptions().setEnabled(false)); + } + @Test void isFocusedPass() { page.setContent(""); diff --git a/playwright/src/test/java/com/microsoft/playwright/TestPageRequestFallback.java b/playwright/src/test/java/com/microsoft/playwright/TestPageRequestFallback.java index c62321a8..c03b54ec 100644 --- a/playwright/src/test/java/com/microsoft/playwright/TestPageRequestFallback.java +++ b/playwright/src/test/java/com/microsoft/playwright/TestPageRequestFallback.java @@ -224,7 +224,8 @@ public class TestPageRequestFallback extends TestBase { page.route("**/foo", route -> route.fallback(new Route.FallbackOptions().setUrl(server.PREFIX + "/global-var.html"))); Response response = page.waitForResponse("**/*", () -> page.navigate(server.PREFIX + "/foo")); assertEquals(server.PREFIX + "/global-var.html", url[0]); - assertEquals(server.PREFIX + "/foo", response.url()); + assertEquals(server.PREFIX + "/global-var.html", response.url()); + assertEquals(server.PREFIX + "/global-var.html", response.request().url()); assertEquals(123, page.evaluate("() => window['globalVar']")); assertEquals("GET", request.get().method); } diff --git a/playwright/src/test/java/com/microsoft/playwright/TestRequestContinue.java b/playwright/src/test/java/com/microsoft/playwright/TestRequestContinue.java index c8fc0852..44c85a3b 100644 --- a/playwright/src/test/java/com/microsoft/playwright/TestRequestContinue.java +++ b/playwright/src/test/java/com/microsoft/playwright/TestRequestContinue.java @@ -67,7 +67,8 @@ public class TestRequestContinue extends TestBase { route.resume(new Route.ResumeOptions().setUrl(server.PREFIX + "/global-var.html")); }); Response response = page.navigate(server.PREFIX + "/foo"); - assertEquals(server.PREFIX + "/foo", response.url()); + assertEquals(server.PREFIX + "/global-var.html", response.url()); + assertEquals(server.PREFIX + "/global-var.html", response.request().url()); assertEquals(123, page.evaluate("window['globalVar']")); assertEquals("GET", serverRequest.get().method); } diff --git a/scripts/CLI_VERSION b/scripts/CLI_VERSION index 85573de6..5540ae2a 100644 --- a/scripts/CLI_VERSION +++ b/scripts/CLI_VERSION @@ -1 +1 @@ -1.26.0-alpha-1661907180000 +1.26.0-alpha-sep-7-2022