From d3495ca5119782ebff0f999a35907daaf278bec5 Mon Sep 17 00:00:00 2001 From: Yury Semikhatsky Date: Fri, 11 Aug 2023 15:12:37 -0700 Subject: [PATCH] chore: roll driver to 1.37.0-beta (#1348) --- README.md | 2 +- .../com/microsoft/playwright/Browser.java | 32 +++++----- .../microsoft/playwright/BrowserContext.java | 4 +- .../com/microsoft/playwright/BrowserType.java | 59 ++++++++++++++++--- .../java/com/microsoft/playwright/Frame.java | 8 ++- .../com/microsoft/playwright/Locator.java | 14 +++-- .../java/com/microsoft/playwright/Page.java | 12 ++-- .../playwright/impl/ArtifactImpl.java | 16 +++++ .../playwright/impl/BrowserImpl.java | 18 +++++- .../playwright/impl/LocatorImpl.java | 2 +- .../com/microsoft/playwright/impl/Utils.java | 6 ++ .../playwright/TestPageInterception.java | 11 ++++ .../playwright/TestPageLocatorQuery.java | 18 ++++++ .../playwright/TestSelectorsMisc.java | 9 +++ scripts/CLI_VERSION | 2 +- 15 files changed, 172 insertions(+), 41 deletions(-) diff --git a/README.md b/README.md index e60fe747a..ddbf5d933 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 115.0.5790.75 | :white_check_mark: | :white_check_mark: | :white_check_mark: | +| Chromium 116.0.5845.82 | :white_check_mark: | :white_check_mark: | :white_check_mark: | | WebKit 17.0 | ✅ | ✅ | ✅ | | Firefox 115.0 | :white_check_mark: | :white_check_mark: | :white_check_mark: | diff --git a/playwright/src/main/java/com/microsoft/playwright/Browser.java b/playwright/src/main/java/com/microsoft/playwright/Browser.java index b4a8a84b5..a93f98f5a 100644 --- a/playwright/src/main/java/com/microsoft/playwright/Browser.java +++ b/playwright/src/main/java/com/microsoft/playwright/Browser.java @@ -120,7 +120,7 @@ class NewContextOptions { /** * Whether the {@code meta viewport} tag is taken into account and touch events are enabled. isMobile is a part of device, * so you don't actually need to set it manually. Defaults to {@code false} and is not supported in Firefox. Learn more - * about mobile emulation. + * about mobile emulation. */ public Boolean isMobile; /** @@ -236,8 +236,8 @@ class NewContextOptions { */ public String userAgent; /** - * Emulates consistent viewport for each page. Defaults to an 1280x720 viewport. Use {@code null} to disable the - * consistent viewport emulation. Learn more about viewport + * Emulates consistent viewport for each page. Defaults to an 1280x720 viewport. Use {@code null} to disable the consistent + * viewport emulation. Learn more about viewport * emulation. * *

NOTE: The {@code null} value opts out from the default presets, makes viewport depend on the host window size defined by the @@ -351,7 +351,7 @@ public NewContextOptions setIgnoreHTTPSErrors(boolean ignoreHTTPSErrors) { /** * Whether the {@code meta viewport} tag is taken into account and touch events are enabled. isMobile is a part of device, * so you don't actually need to set it manually. Defaults to {@code false} and is not supported in Firefox. Learn more - * about mobile emulation. + * about mobile emulation. */ public NewContextOptions setIsMobile(boolean isMobile) { this.isMobile = isMobile; @@ -559,8 +559,8 @@ public NewContextOptions setUserAgent(String userAgent) { return this; } /** - * Emulates consistent viewport for each page. Defaults to an 1280x720 viewport. Use {@code null} to disable the - * consistent viewport emulation. Learn more about viewport + * Emulates consistent viewport for each page. Defaults to an 1280x720 viewport. Use {@code null} to disable the consistent + * viewport emulation. Learn more about viewport * emulation. * *

NOTE: The {@code null} value opts out from the default presets, makes viewport depend on the host window size defined by the @@ -570,8 +570,8 @@ public NewContextOptions setViewportSize(int width, int height) { return setViewportSize(new ViewportSize(width, height)); } /** - * Emulates consistent viewport for each page. Defaults to an 1280x720 viewport. Use {@code null} to disable the - * consistent viewport emulation. Learn more about viewport + * Emulates consistent viewport for each page. Defaults to an 1280x720 viewport. Use {@code null} to disable the consistent + * viewport emulation. Learn more about viewport * emulation. * *

NOTE: The {@code null} value opts out from the default presets, makes viewport depend on the host window size defined by the @@ -646,7 +646,7 @@ class NewPageOptions { /** * Whether the {@code meta viewport} tag is taken into account and touch events are enabled. isMobile is a part of device, * so you don't actually need to set it manually. Defaults to {@code false} and is not supported in Firefox. Learn more - * about mobile emulation. + * about mobile emulation. */ public Boolean isMobile; /** @@ -762,8 +762,8 @@ class NewPageOptions { */ public String userAgent; /** - * Emulates consistent viewport for each page. Defaults to an 1280x720 viewport. Use {@code null} to disable the - * consistent viewport emulation. Learn more about viewport + * Emulates consistent viewport for each page. Defaults to an 1280x720 viewport. Use {@code null} to disable the consistent + * viewport emulation. Learn more about viewport * emulation. * *

NOTE: The {@code null} value opts out from the default presets, makes viewport depend on the host window size defined by the @@ -877,7 +877,7 @@ public NewPageOptions setIgnoreHTTPSErrors(boolean ignoreHTTPSErrors) { /** * Whether the {@code meta viewport} tag is taken into account and touch events are enabled. isMobile is a part of device, * so you don't actually need to set it manually. Defaults to {@code false} and is not supported in Firefox. Learn more - * about mobile emulation. + * about mobile emulation. */ public NewPageOptions setIsMobile(boolean isMobile) { this.isMobile = isMobile; @@ -1085,8 +1085,8 @@ public NewPageOptions setUserAgent(String userAgent) { return this; } /** - * Emulates consistent viewport for each page. Defaults to an 1280x720 viewport. Use {@code null} to disable the - * consistent viewport emulation. Learn more about viewport + * Emulates consistent viewport for each page. Defaults to an 1280x720 viewport. Use {@code null} to disable the consistent + * viewport emulation. Learn more about viewport * emulation. * *

NOTE: The {@code null} value opts out from the default presets, makes viewport depend on the host window size defined by the @@ -1096,8 +1096,8 @@ public NewPageOptions setViewportSize(int width, int height) { return setViewportSize(new ViewportSize(width, height)); } /** - * Emulates consistent viewport for each page. Defaults to an 1280x720 viewport. Use {@code null} to disable the - * consistent viewport emulation. Learn more about viewport + * Emulates consistent viewport for each page. Defaults to an 1280x720 viewport. Use {@code null} to disable the consistent + * viewport emulation. Learn more about viewport * emulation. * *

NOTE: The {@code null} value opts out from the default presets, makes viewport depend on the host window size defined by the diff --git a/playwright/src/main/java/com/microsoft/playwright/BrowserContext.java b/playwright/src/main/java/com/microsoft/playwright/BrowserContext.java index 74378506d..35338811e 100644 --- a/playwright/src/main/java/com/microsoft/playwright/BrowserContext.java +++ b/playwright/src/main/java/com/microsoft/playwright/BrowserContext.java @@ -1116,7 +1116,7 @@ default void route(Predicate url, Consumer handler) { void route(Predicate url, Consumer handler, RouteOptions options); /** * If specified the network requests that are made in the context will be served from the HAR file. Read more about Replaying from HAR. + * href="https://playwright.dev/java/docs/mock#replaying-from-har">Replaying from HAR. * *

Playwright will not serve requests intercepted by Service Worker from the HAR file. See this issue. We recommend disabling Service Workers when @@ -1131,7 +1131,7 @@ default void routeFromHAR(Path har) { } /** * If specified the network requests that are made in the context will be served from the HAR file. Read more about Replaying from HAR. + * href="https://playwright.dev/java/docs/mock#replaying-from-har">Replaying from HAR. * *

Playwright will not serve requests intercepted by Service Worker from the HAR file. See this issue. We recommend disabling Service Workers when diff --git a/playwright/src/main/java/com/microsoft/playwright/BrowserType.java b/playwright/src/main/java/com/microsoft/playwright/BrowserType.java index 6983b3a65..b94888bda 100644 --- a/playwright/src/main/java/com/microsoft/playwright/BrowserType.java +++ b/playwright/src/main/java/com/microsoft/playwright/BrowserType.java @@ -43,6 +43,26 @@ */ public interface BrowserType { class ConnectOptions { + /** + * This option exposes network available on the connecting client to the browser being connected to. Consists of a list of + * rules separated by comma. + * + *

Available rules: + *

    + *
  1. Hostname pattern, for example: {@code example.com}, {@code *.org:99}, {@code x.*.y.com}, {@code *foo.org}.
  2. + *
  3. IP literal, for example: {@code 127.0.0.1}, {@code 0.0.0.0:99}, {@code [::1]}, {@code [0:0::1]:99}.
  4. + *
  5. {@code } that matches local loopback interfaces: {@code localhost}, {@code *.localhost}, {@code 127.0.0.1}, + * {@code [::1]}.
  6. + *
+ * + *

Some common examples: + *

    + *
  1. {@code "*"} to expose all network.
  2. + *
  3. {@code ""} to expose localhost network.
  4. + *
  5. {@code "*.test.internal-domain,*.staging.internal-domain,"} to expose test/staging deployments and localhost.
  6. + *
+ */ + public String exposeNetwork; /** * Additional HTTP headers to be sent with web socket connect request. Optional. */ @@ -57,6 +77,29 @@ class ConnectOptions { */ public Double timeout; + /** + * This option exposes network available on the connecting client to the browser being connected to. Consists of a list of + * rules separated by comma. + * + *

Available rules: + *

    + *
  1. Hostname pattern, for example: {@code example.com}, {@code *.org:99}, {@code x.*.y.com}, {@code *foo.org}.
  2. + *
  3. IP literal, for example: {@code 127.0.0.1}, {@code 0.0.0.0:99}, {@code [::1]}, {@code [0:0::1]:99}.
  4. + *
  5. {@code } that matches local loopback interfaces: {@code localhost}, {@code *.localhost}, {@code 127.0.0.1}, + * {@code [::1]}.
  6. + *
+ * + *

Some common examples: + *

    + *
  1. {@code "*"} to expose all network.
  2. + *
  3. {@code ""} to expose localhost network.
  4. + *
  5. {@code "*.test.internal-domain,*.staging.internal-domain,"} to expose test/staging deployments and localhost.
  6. + *
+ */ + public ConnectOptions setExposeNetwork(String exposeNetwork) { + this.exposeNetwork = exposeNetwork; + return this; + } /** * Additional HTTP headers to be sent with web socket connect request. Optional. */ @@ -496,7 +539,7 @@ class LaunchPersistentContextOptions { /** * Whether the {@code meta viewport} tag is taken into account and touch events are enabled. isMobile is a part of device, * so you don't actually need to set it manually. Defaults to {@code false} and is not supported in Firefox. Learn more - * about mobile emulation. + * about mobile emulation. */ public Boolean isMobile; /** @@ -610,8 +653,8 @@ class LaunchPersistentContextOptions { */ public String userAgent; /** - * Emulates consistent viewport for each page. Defaults to an 1280x720 viewport. Use {@code null} to disable the - * consistent viewport emulation. Learn more about viewport + * Emulates consistent viewport for each page. Defaults to an 1280x720 viewport. Use {@code null} to disable the consistent + * viewport emulation. Learn more about viewport * emulation. * *

NOTE: The {@code null} value opts out from the default presets, makes viewport depend on the host window size defined by the @@ -839,7 +882,7 @@ public LaunchPersistentContextOptions setIgnoreHTTPSErrors(boolean ignoreHTTPSEr /** * Whether the {@code meta viewport} tag is taken into account and touch events are enabled. isMobile is a part of device, * so you don't actually need to set it manually. Defaults to {@code false} and is not supported in Firefox. Learn more - * about mobile emulation. + * about mobile emulation. */ public LaunchPersistentContextOptions setIsMobile(boolean isMobile) { this.isMobile = isMobile; @@ -1044,8 +1087,8 @@ public LaunchPersistentContextOptions setUserAgent(String userAgent) { return this; } /** - * Emulates consistent viewport for each page. Defaults to an 1280x720 viewport. Use {@code null} to disable the - * consistent viewport emulation. Learn more about viewport + * Emulates consistent viewport for each page. Defaults to an 1280x720 viewport. Use {@code null} to disable the consistent + * viewport emulation. Learn more about viewport * emulation. * *

NOTE: The {@code null} value opts out from the default presets, makes viewport depend on the host window size defined by the @@ -1055,8 +1098,8 @@ public LaunchPersistentContextOptions setViewportSize(int width, int height) { return setViewportSize(new ViewportSize(width, height)); } /** - * Emulates consistent viewport for each page. Defaults to an 1280x720 viewport. Use {@code null} to disable the - * consistent viewport emulation. Learn more about viewport + * Emulates consistent viewport for each page. Defaults to an 1280x720 viewport. Use {@code null} to disable the consistent + * viewport emulation. Learn more about viewport * emulation. * *

NOTE: The {@code null} value opts out from the default presets, makes viewport depend on the host window size defined by the diff --git a/playwright/src/main/java/com/microsoft/playwright/Frame.java b/playwright/src/main/java/com/microsoft/playwright/Frame.java index bd3faada6..a153b96e5 100644 --- a/playwright/src/main/java/com/microsoft/playwright/Frame.java +++ b/playwright/src/main/java/com/microsoft/playwright/Frame.java @@ -4473,7 +4473,9 @@ default void setChecked(String selector, boolean checked) { */ void setChecked(String selector, boolean checked, SetCheckedOptions options); /** - * + * This method internally calls document.write(), inheriting all its specific + * characteristics and behaviors. * * @param html HTML markup to assign to the page. * @since v1.8 @@ -4482,7 +4484,9 @@ default void setContent(String html) { setContent(html, null); } /** - * + * This method internally calls document.write(), inheriting all its specific + * characteristics and behaviors. * * @param html HTML markup to assign to the page. * @since v1.8 diff --git a/playwright/src/main/java/com/microsoft/playwright/Locator.java b/playwright/src/main/java/com/microsoft/playwright/Locator.java index e106f465b..1060d3829 100644 --- a/playwright/src/main/java/com/microsoft/playwright/Locator.java +++ b/playwright/src/main/java/com/microsoft/playwright/Locator.java @@ -23,7 +23,7 @@ /** * Locators are the central piece of Playwright's auto-waiting and retry-ability. In a nutshell, locators represent a way - * to find element(s) on the page at any moment. Locator can be created with the {@link Page#locator Page.locator()} + * to find element(s) on the page at any moment. A locator can be created with the {@link Page#locator Page.locator()} * method. * *

Learn more about locators. @@ -2033,7 +2033,7 @@ public WaitForOptions setTimeout(double timeout) { } } /** - * When locator points to a list of elements, returns array of locators, pointing to respective elements. + * When the locator points to a list of elements, this returns an array of locators, pointing to their respective elements. * *

NOTE: {@link Locator#all Locator.all()} does not wait for elements to match the locator, and instead immediately returns * whatever is present in the page. When the list of elements changes dynamically, {@link Locator#all Locator.all()} will @@ -4865,7 +4865,10 @@ default String textContent() { */ String textContent(TextContentOptions options); /** - * Focuses the element, and then sends a {@code keydown}, {@code keypress}/{@code input}, and {@code keyup} event for each + * NOTE: In most cases, you should use {@link Locator#fill Locator.fill()} instead. You only need to type characters if there is + * special keyboard handling on the page. + * + *

Focuses the element, and then sends a {@code keydown}, {@code keypress}/{@code input}, and {@code keyup} event for each * character in the text. * *

To press a special key, like {@code Control} or {@code ArrowDown}, use {@link Locator#press Locator.press()}. @@ -4890,7 +4893,10 @@ default void type(String text) { type(text, null); } /** - * Focuses the element, and then sends a {@code keydown}, {@code keypress}/{@code input}, and {@code keyup} event for each + * NOTE: In most cases, you should use {@link Locator#fill Locator.fill()} instead. You only need to type characters if there is + * special keyboard handling on the page. + * + *

Focuses the element, and then sends a {@code keydown}, {@code keypress}/{@code input}, and {@code keyup} event for each * character in the text. * *

To press a special key, like {@code Control} or {@code ArrowDown}, use {@link Locator#press Locator.press()}. diff --git a/playwright/src/main/java/com/microsoft/playwright/Page.java b/playwright/src/main/java/com/microsoft/playwright/Page.java index ca4598c88..dfff3ed8c 100644 --- a/playwright/src/main/java/com/microsoft/playwright/Page.java +++ b/playwright/src/main/java/com/microsoft/playwright/Page.java @@ -6201,7 +6201,7 @@ default void route(Predicate url, Consumer handler) { void route(Predicate url, Consumer handler, RouteOptions options); /** * If specified the network requests that are made in the page will be served from the HAR file. Read more about Replaying from HAR. + * href="https://playwright.dev/java/docs/mock#replaying-from-har">Replaying from HAR. * *

Playwright will not serve requests intercepted by Service Worker from the HAR file. See this issue. We recommend disabling Service Workers when @@ -6216,7 +6216,7 @@ default void routeFromHAR(Path har) { } /** * If specified the network requests that are made in the page will be served from the HAR file. Read more about Replaying from HAR. + * href="https://playwright.dev/java/docs/mock#replaying-from-har">Replaying from HAR. * *

Playwright will not serve requests intercepted by Service Worker from the HAR file. See this issue. We recommend disabling Service Workers when @@ -6672,7 +6672,9 @@ default void setChecked(String selector, boolean checked) { */ void setChecked(String selector, boolean checked, SetCheckedOptions options); /** - * + * This method internally calls document.write(), inheriting all its specific + * characteristics and behaviors. * * @param html HTML markup to assign to the page. * @since v1.8 @@ -6681,7 +6683,9 @@ default void setContent(String html) { setContent(html, null); } /** - * + * This method internally calls document.write(), inheriting all its specific + * characteristics and behaviors. * * @param html HTML markup to assign to the page. * @since v1.8 diff --git a/playwright/src/main/java/com/microsoft/playwright/impl/ArtifactImpl.java b/playwright/src/main/java/com/microsoft/playwright/impl/ArtifactImpl.java index 2aa98bd4f..aab984c22 100644 --- a/playwright/src/main/java/com/microsoft/playwright/impl/ArtifactImpl.java +++ b/playwright/src/main/java/com/microsoft/playwright/impl/ArtifactImpl.java @@ -19,6 +19,8 @@ import com.google.gson.JsonObject; import com.microsoft.playwright.PlaywrightException; +import java.io.ByteArrayOutputStream; +import java.io.IOException; import java.io.InputStream; import java.nio.file.FileSystems; import java.nio.file.Path; @@ -39,6 +41,20 @@ public InputStream createReadStream() { return stream.stream(); } + byte[] readAllBytes() { + final int bufLen = 1024 * 1024; + byte[] buf = new byte[bufLen]; + int readLen; + try (ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); InputStream stream = createReadStream()) { + while ((readLen = stream.read(buf, 0, bufLen)) != -1) { + outputStream.write(buf, 0, readLen); + } + return outputStream.toByteArray(); + } catch (IOException e) { + throw new PlaywrightException("Failed to read artifact", e); + } + } + public void cancel() { sendMessage("cancel"); } diff --git a/playwright/src/main/java/com/microsoft/playwright/impl/BrowserImpl.java b/playwright/src/main/java/com/microsoft/playwright/impl/BrowserImpl.java index e630f9ba5..e13368e9d 100644 --- a/playwright/src/main/java/com/microsoft/playwright/impl/BrowserImpl.java +++ b/playwright/src/main/java/com/microsoft/playwright/impl/BrowserImpl.java @@ -28,7 +28,6 @@ import java.nio.file.Path; import java.util.*; import java.util.function.Consumer; -import java.util.regex.Pattern; import static com.microsoft.playwright.impl.Serialization.addHarUrlFilter; import static com.microsoft.playwright.impl.Serialization.gson; @@ -42,6 +41,7 @@ class BrowserImpl extends ChannelOwner implements Browser { private boolean isConnected = true; BrowserTypeImpl browserType; BrowserType.LaunchOptions launchOptions; + private Path tracePath; enum EventType { DISCONNECTED, @@ -231,6 +231,7 @@ private void startTracingImpl(Page page, StartTracingOptions options) { if (options == null) { options = new StartTracingOptions(); } + tracePath = options.path; JsonObject params = gson().toJsonTree(options).getAsJsonObject(); if (page != null) { params.add("page", ((PageImpl) page).toProtocolRef()); @@ -245,7 +246,20 @@ public byte[] stopTracing() { private byte[] stopTracingImpl() { JsonObject json = sendMessage("stopTracing").getAsJsonObject(); - return Base64.getDecoder().decode(json.get("binary").getAsString()); + ArtifactImpl artifact = connection.getExistingObject(json.getAsJsonObject().getAsJsonObject("artifact").get("guid").getAsString()); + byte[] data = artifact.readAllBytes(); + artifact.delete(); + if (tracePath != null) { + try { + Files.createDirectories(tracePath.getParent()); + Files.write(tracePath, data); + } catch (IOException e) { + throw new PlaywrightException("Failed to write trace file", e); + } finally { + tracePath = null; + } + } + return data; } private Page newPageImpl(NewPageOptions options) { diff --git a/playwright/src/main/java/com/microsoft/playwright/impl/LocatorImpl.java b/playwright/src/main/java/com/microsoft/playwright/impl/LocatorImpl.java index 3cf829fa9..c507d50c0 100644 --- a/playwright/src/main/java/com/microsoft/playwright/impl/LocatorImpl.java +++ b/playwright/src/main/java/com/microsoft/playwright/impl/LocatorImpl.java @@ -407,7 +407,7 @@ public Locator locator(Locator selectorOrLocator, LocatorOptions options) { if (other.frame != frame) { throw new PlaywrightException("Locators must belong to the same frame."); } - return locator(other.selector, options); + return new LocatorImpl(frame, this.selector + " >> internal:chain=" + gson().toJson(other.selector), options); } @Override diff --git a/playwright/src/main/java/com/microsoft/playwright/impl/Utils.java b/playwright/src/main/java/com/microsoft/playwright/impl/Utils.java index 84f774c8a..717904fe1 100644 --- a/playwright/src/main/java/com/microsoft/playwright/impl/Utils.java +++ b/playwright/src/main/java/com/microsoft/playwright/impl/Utils.java @@ -128,6 +128,12 @@ static String globToRegex(String glob) { case '?': tokens.append('.'); break; + case '[': + tokens.append('['); + break; + case ']': + tokens.append(']'); + break; case '{': inGroup = true; tokens.append('('); diff --git a/playwright/src/test/java/com/microsoft/playwright/TestPageInterception.java b/playwright/src/test/java/com/microsoft/playwright/TestPageInterception.java index 0df221f83..376fe77e4 100644 --- a/playwright/src/test/java/com/microsoft/playwright/TestPageInterception.java +++ b/playwright/src/test/java/com/microsoft/playwright/TestPageInterception.java @@ -124,4 +124,15 @@ void shouldNotFollowRedirectsWhenMaxRedirectsIsSetTo0InRouteFetch() { page.navigate(server.PREFIX + "/foo"); assertTrue(page.content().contains("hello")); } + + @Test + void shouldProperlyHandleCharacterSetsInGlobs() { + page.route("**/[a-z]*.html", route -> { + APIResponse response = route.fetch(new Route.FetchOptions().setUrl(server.PREFIX + "/one-style.html")); + route.fulfill(new Route.FulfillOptions().setResponse(response)); + }); + Response response = page.navigate(server.PREFIX + "/empty.html"); + assertEquals(200, response.status()); + assertTrue(response.text().contains("one-style.css"), response.text()); + } } diff --git a/playwright/src/test/java/com/microsoft/playwright/TestPageLocatorQuery.java b/playwright/src/test/java/com/microsoft/playwright/TestPageLocatorQuery.java index 1328d985d..30581c07b 100644 --- a/playwright/src/test/java/com/microsoft/playwright/TestPageLocatorQuery.java +++ b/playwright/src/test/java/com/microsoft/playwright/TestPageLocatorQuery.java @@ -16,6 +16,7 @@ package com.microsoft.playwright; +import com.microsoft.playwright.options.AriaRole; import org.junit.jupiter.api.Test; import java.util.regex.Pattern; @@ -207,4 +208,21 @@ void shouldSupportLocatorOr() { assertThat(page.locator("div").or(page.locator("article"))).hasText("hello"); assertThat(page.locator("span").or(page.locator("article"))).hasText("world"); } + + @Test + void shouldSupportLocatorLocatorWithAndOr() { + page.setContent("\n" + + "

one two
\n" + + " four\n" + + " \n" + + " "); + + assertThat(page.locator("div").locator(page.locator("button"))).hasText(new String[] {"three"}); + assertThat(page.locator("div").locator(page.locator("button").or(page.locator("span")))).hasText(new String[]{"two", "three"}); + assertThat(page.locator("button").or(page.locator("span"))).hasText(new String[]{"two", "three", "four", "five"}); + + assertThat(page.locator("div").locator(page.locator("button").and(page.getByRole(AriaRole.BUTTON)))).hasText(new String[]{"three"}); + assertThat(page.locator("button").and(page.getByRole(AriaRole.BUTTON))).hasText(new String[]{"three", "five"}); + } + } diff --git a/playwright/src/test/java/com/microsoft/playwright/TestSelectorsMisc.java b/playwright/src/test/java/com/microsoft/playwright/TestSelectorsMisc.java index 2ecb9e91c..58aa8495f 100644 --- a/playwright/src/test/java/com/microsoft/playwright/TestSelectorsMisc.java +++ b/playwright/src/test/java/com/microsoft/playwright/TestSelectorsMisc.java @@ -230,4 +230,13 @@ void shouldWorkWithInternalOr() { assertEquals("hello", page.locator("div >> internal:or=\"article\"").textContent()); assertEquals("world", page.locator("span >> internal:or=\"article\"").textContent()); } + @Test + void shouldWorkWithInternalChain() { + page.setContent("
one two
\n" + + " four\n" + + " "); + assertEquals(asList("three"), page.evalOnSelectorAll("div >> internal:chain=\"button\"", "els => els.map(e => e.textContent)")); + assertEquals(asList("two", "three"), page.evalOnSelectorAll("div >> internal:chain=\"span >> internal:or=\\\"button\\\"\"", "els => els.map(e => e.textContent)")); + } + } diff --git a/scripts/CLI_VERSION b/scripts/CLI_VERSION index f107550c2..3d0258087 100644 --- a/scripts/CLI_VERSION +++ b/scripts/CLI_VERSION @@ -1 +1 @@ -1.36.1 +1.37.0-beta-1691701681000