Skip to content

Commit 8a89e36

Browse files
authored
chore: roll to 1.53.0-alpha-2025-05-21 (#1798)
1 parent f1e6100 commit 8a89e36

23 files changed

+201
-73
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Playwright is a Java library to automate [Chromium](https://www.chromium.org/Hom
1010

1111
| | Linux | macOS | Windows |
1212
| :--- | :---: | :---: | :---: |
13-
| Chromium <!-- GEN:chromium-version -->136.0.7103.25<!-- GEN:stop --> | :white_check_mark: | :white_check_mark: | :white_check_mark: |
13+
| Chromium <!-- GEN:chromium-version -->137.0.7151.27<!-- GEN:stop --> | :white_check_mark: | :white_check_mark: | :white_check_mark: |
1414
| WebKit <!-- GEN:webkit-version -->18.4<!-- GEN:stop --> ||||
1515
| Firefox <!-- GEN:firefox-version -->137.0<!-- GEN:stop --> | :white_check_mark: | :white_check_mark: | :white_check_mark: |
1616

examples/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<name>Playwright Client Examples</name>
1111
<properties>
1212
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
13-
<playwright.version>1.51.0</playwright.version>
13+
<playwright.version>1.53.0</playwright.version>
1414
</properties>
1515
<dependencies>
1616
<dependency>

playwright/src/main/java/com/microsoft/playwright/BrowserType.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,9 @@ class LaunchOptions {
209209
/**
210210
* Firefox user preferences. Learn more about the Firefox user preferences at <a
211211
* href="https://support.mozilla.org/en-US/kb/about-config-editor-firefox">{@code about:config}</a>.
212+
*
213+
* <p> You can also provide a path to a custom <a href="https://mozilla.github.io/policy-templates/">{@code policies.json}
214+
* file</a> via {@code PLAYWRIGHT_FIREFOX_POLICIES_JSON} environment variable.
212215
*/
213216
public Map<String, Object> firefoxUserPrefs;
214217
/**
@@ -339,6 +342,9 @@ public LaunchOptions setExecutablePath(Path executablePath) {
339342
/**
340343
* Firefox user preferences. Learn more about the Firefox user preferences at <a
341344
* href="https://support.mozilla.org/en-US/kb/about-config-editor-firefox">{@code about:config}</a>.
345+
*
346+
* <p> You can also provide a path to a custom <a href="https://mozilla.github.io/policy-templates/">{@code policies.json}
347+
* file</a> via {@code PLAYWRIGHT_FIREFOX_POLICIES_JSON} environment variable.
342348
*/
343349
public LaunchOptions setFirefoxUserPrefs(Map<String, Object> firefoxUserPrefs) {
344350
this.firefoxUserPrefs = firefoxUserPrefs;
@@ -535,6 +541,9 @@ class LaunchPersistentContextOptions {
535541
/**
536542
* Firefox user preferences. Learn more about the Firefox user preferences at <a
537543
* href="https://support.mozilla.org/en-US/kb/about-config-editor-firefox">{@code about:config}</a>.
544+
*
545+
* <p> You can also provide a path to a custom <a href="https://mozilla.github.io/policy-templates/">{@code policies.json}
546+
* file</a> via {@code PLAYWRIGHT_FIREFOX_POLICIES_JSON} environment variable.
538547
*/
539548
public Map<String, Object> firefoxUserPrefs;
540549
/**
@@ -881,6 +890,9 @@ public LaunchPersistentContextOptions setExtraHTTPHeaders(Map<String, String> ex
881890
/**
882891
* Firefox user preferences. Learn more about the Firefox user preferences at <a
883892
* href="https://support.mozilla.org/en-US/kb/about-config-editor-firefox">{@code about:config}</a>.
893+
*
894+
* <p> You can also provide a path to a custom <a href="https://mozilla.github.io/policy-templates/">{@code policies.json}
895+
* file</a> via {@code PLAYWRIGHT_FIREFOX_POLICIES_JSON} environment variable.
884896
*/
885897
public LaunchPersistentContextOptions setFirefoxUserPrefs(Map<String, Object> firefoxUserPrefs) {
886898
this.firefoxUserPrefs = firefoxUserPrefs;

playwright/src/main/java/com/microsoft/playwright/Locator.java

Lines changed: 32 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,6 @@
3030
*/
3131
public interface Locator {
3232
class AriaSnapshotOptions {
33-
/**
34-
* Generate symbolic reference for each element. One can use {@code aria-ref=<ref>} locator immediately after capturing the
35-
* snapshot to perform actions on the element.
36-
*/
37-
public Boolean ref;
3833
/**
3934
* Maximum time in milliseconds. Defaults to {@code 30000} (30 seconds). Pass {@code 0} to disable timeout. The default
4035
* value can be changed by using the {@link com.microsoft.playwright.BrowserContext#setDefaultTimeout
@@ -43,14 +38,6 @@ class AriaSnapshotOptions {
4338
*/
4439
public Double timeout;
4540

46-
/**
47-
* Generate symbolic reference for each element. One can use {@code aria-ref=<ref>} locator immediately after capturing the
48-
* snapshot to perform actions on the element.
49-
*/
50-
public AriaSnapshotOptions setRef(boolean ref) {
51-
this.ref = ref;
52-
return this;
53-
}
5441
/**
5542
* Maximum time in milliseconds. Defaults to {@code 30000} (30 seconds). Pass {@code 0} to disable timeout. The default
5643
* value can be changed by using the {@link com.microsoft.playwright.BrowserContext#setDefaultTimeout
@@ -2615,6 +2602,14 @@ default void dblclick() {
26152602
* @since v1.14
26162603
*/
26172604
void dblclick(DblclickOptions options);
2605+
/**
2606+
* Describes the locator, description is used in the trace viewer and reports. Returns the locator pointing to the same
2607+
* element.
2608+
*
2609+
* @param description Locator description.
2610+
* @since v1.53
2611+
*/
2612+
Locator describe(String description);
26182613
/**
26192614
* Programmatically dispatch an event on the matching element.
26202615
*
@@ -2861,6 +2856,14 @@ default ElementHandle elementHandle() {
28612856
*
28622857
* <p> <strong>Usage</strong>
28632858
*
2859+
* <p> Passing argument to {@code expression}:
2860+
* <pre>{@code
2861+
* Object result = page.getByTestId("myId").evaluate("(element, [x, y]) => {\n" +
2862+
* " return element.textContent + ' ' + x * y;\n" +
2863+
* "}", Arrays.asList(7, 8));
2864+
* System.out.println(result); // prints "myId text 56"
2865+
* }</pre>
2866+
*
28642867
* @param expression JavaScript expression to be evaluated in the browser context. If the expression evaluates to a function, the function is
28652868
* automatically invoked.
28662869
* @param arg Optional argument to pass to {@code expression}.
@@ -2885,6 +2888,14 @@ default Object evaluate(String expression, Object arg) {
28852888
*
28862889
* <p> <strong>Usage</strong>
28872890
*
2891+
* <p> Passing argument to {@code expression}:
2892+
* <pre>{@code
2893+
* Object result = page.getByTestId("myId").evaluate("(element, [x, y]) => {\n" +
2894+
* " return element.textContent + ' ' + x * y;\n" +
2895+
* "}", Arrays.asList(7, 8));
2896+
* System.out.println(result); // prints "myId text 56"
2897+
* }</pre>
2898+
*
28882899
* @param expression JavaScript expression to be evaluated in the browser context. If the expression evaluates to a function, the function is
28892900
* automatically invoked.
28902901
* @since v1.14
@@ -2908,6 +2919,14 @@ default Object evaluate(String expression) {
29082919
*
29092920
* <p> <strong>Usage</strong>
29102921
*
2922+
* <p> Passing argument to {@code expression}:
2923+
* <pre>{@code
2924+
* Object result = page.getByTestId("myId").evaluate("(element, [x, y]) => {\n" +
2925+
* " return element.textContent + ' ' + x * y;\n" +
2926+
* "}", Arrays.asList(7, 8));
2927+
* System.out.println(result); // prints "myId text 56"
2928+
* }</pre>
2929+
*
29112930
* @param expression JavaScript expression to be evaluated in the browser context. If the expression evaluates to a function, the function is
29122931
* automatically invoked.
29132932
* @param arg Optional argument to pass to {@code expression}.

playwright/src/main/java/com/microsoft/playwright/Tracing.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,12 @@
2323
* API for collecting and saving Playwright traces. Playwright traces can be opened in <a
2424
* href="https://playwright.dev/java/docs/trace-viewer">Trace Viewer</a> after Playwright script runs.
2525
*
26+
* <p> <strong>NOTE:</strong> You probably want to <a href="https://playwright.dev/docs/api/class-testoptions#test-options-trace">enable tracing in
27+
* your config file</a> instead of using {@code context.tracing}.The {@code context.tracing} API captures browser operations and network activity, but it doesn't record test assertions
28+
* (like {@code expect} calls). We recommend <a
29+
* href="https://playwright.dev/docs/api/class-testoptions#test-options-trace">enabling tracing through Playwright Test
30+
* configuration</a>, which includes those assertions and provides a more complete trace for debugging test failures.
31+
*
2632
* <p> Start recording a trace before performing actions. At the end, stop tracing and save it to a file.
2733
* <pre>{@code
2834
* Browser browser = chromium.launch();
@@ -200,6 +206,12 @@ public StopChunkOptions setPath(Path path) {
200206
/**
201207
* Start tracing.
202208
*
209+
* <p> <strong>NOTE:</strong> You probably want to <a href="https://playwright.dev/docs/api/class-testoptions#test-options-trace">enable tracing in
210+
* your config file</a> instead of using {@code Tracing.start}.The {@code context.tracing} API captures browser operations and network activity, but it doesn't record test assertions
211+
* (like {@code expect} calls). We recommend <a
212+
* href="https://playwright.dev/docs/api/class-testoptions#test-options-trace">enabling tracing through Playwright Test
213+
* configuration</a>, which includes those assertions and provides a more complete trace for debugging test failures.
214+
*
203215
* <p> <strong>Usage</strong>
204216
* <pre>{@code
205217
* context.tracing().start(new Tracing.StartOptions()
@@ -219,6 +231,12 @@ default void start() {
219231
/**
220232
* Start tracing.
221233
*
234+
* <p> <strong>NOTE:</strong> You probably want to <a href="https://playwright.dev/docs/api/class-testoptions#test-options-trace">enable tracing in
235+
* your config file</a> instead of using {@code Tracing.start}.The {@code context.tracing} API captures browser operations and network activity, but it doesn't record test assertions
236+
* (like {@code expect} calls). We recommend <a
237+
* href="https://playwright.dev/docs/api/class-testoptions#test-options-trace">enabling tracing through Playwright Test
238+
* configuration</a>, which includes those assertions and provides a more complete trace for debugging test failures.
239+
*
222240
* <p> <strong>Usage</strong>
223241
* <pre>{@code
224242
* context.tracing().start(new Tracing.StartOptions()

playwright/src/main/java/com/microsoft/playwright/assertions/LocatorAssertions.java

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -885,7 +885,7 @@ default void isVisible() {
885885
* <p> When an array is passed, the method asserts that the list of elements located matches the corresponding list of expected
886886
* class lists. Each element's class attribute is matched against the corresponding class in the array:
887887
* <pre>{@code
888-
* assertThat(page.locator("list > .component")).containsClass(new String[] {"inactive", "active", "inactive"});
888+
* assertThat(page.locator(".list > .component")).containsClass(new String[] {"inactive", "active", "inactive"});
889889
* }</pre>
890890
*
891891
* @param expected A string containing expected class names, separated by spaces, or a list of such strings to assert multiple elements.
@@ -909,7 +909,7 @@ default void containsClass(String expected) {
909909
* <p> When an array is passed, the method asserts that the list of elements located matches the corresponding list of expected
910910
* class lists. Each element's class attribute is matched against the corresponding class in the array:
911911
* <pre>{@code
912-
* assertThat(page.locator("list > .component")).containsClass(new String[] {"inactive", "active", "inactive"});
912+
* assertThat(page.locator(".list > .component")).containsClass(new String[] {"inactive", "active", "inactive"});
913913
* }</pre>
914914
*
915915
* @param expected A string containing expected class names, separated by spaces, or a list of such strings to assert multiple elements.
@@ -931,7 +931,7 @@ default void containsClass(String expected) {
931931
* <p> When an array is passed, the method asserts that the list of elements located matches the corresponding list of expected
932932
* class lists. Each element's class attribute is matched against the corresponding class in the array:
933933
* <pre>{@code
934-
* assertThat(page.locator("list > .component")).containsClass(new String[] {"inactive", "active", "inactive"});
934+
* assertThat(page.locator(".list > .component")).containsClass(new String[] {"inactive", "active", "inactive"});
935935
* }</pre>
936936
*
937937
* @param expected A string containing expected class names, separated by spaces, or a list of such strings to assert multiple elements.
@@ -955,7 +955,7 @@ default void containsClass(List<String> expected) {
955955
* <p> When an array is passed, the method asserts that the list of elements located matches the corresponding list of expected
956956
* class lists. Each element's class attribute is matched against the corresponding class in the array:
957957
* <pre>{@code
958-
* assertThat(page.locator("list > .component")).containsClass(new String[] {"inactive", "active", "inactive"});
958+
* assertThat(page.locator(".list > .component")).containsClass(new String[] {"inactive", "active", "inactive"});
959959
* }</pre>
960960
*
961961
* @param expected A string containing expected class names, separated by spaces, or a list of such strings to assert multiple elements.
@@ -1565,7 +1565,7 @@ default void hasAttribute(String name, Pattern value) {
15651565
* class values. Each element's class attribute is matched against the corresponding string or regular expression in the
15661566
* array:
15671567
* <pre>{@code
1568-
* assertThat(page.locator("list > .component")).hasClass(new String[] {"component", "component selected", "component"});
1568+
* assertThat(page.locator(".list > .component")).hasClass(new String[] {"component", "component selected", "component"});
15691569
* }</pre>
15701570
*
15711571
* @param expected Expected class or RegExp or a list of those.
@@ -1589,7 +1589,7 @@ default void hasClass(String expected) {
15891589
* class values. Each element's class attribute is matched against the corresponding string or regular expression in the
15901590
* array:
15911591
* <pre>{@code
1592-
* assertThat(page.locator("list > .component")).hasClass(new String[] {"component", "component selected", "component"});
1592+
* assertThat(page.locator(".list > .component")).hasClass(new String[] {"component", "component selected", "component"});
15931593
* }</pre>
15941594
*
15951595
* @param expected Expected class or RegExp or a list of those.
@@ -1611,7 +1611,7 @@ default void hasClass(String expected) {
16111611
* class values. Each element's class attribute is matched against the corresponding string or regular expression in the
16121612
* array:
16131613
* <pre>{@code
1614-
* assertThat(page.locator("list > .component")).hasClass(new String[] {"component", "component selected", "component"});
1614+
* assertThat(page.locator(".list > .component")).hasClass(new String[] {"component", "component selected", "component"});
16151615
* }</pre>
16161616
*
16171617
* @param expected Expected class or RegExp or a list of those.
@@ -1635,7 +1635,7 @@ default void hasClass(Pattern expected) {
16351635
* class values. Each element's class attribute is matched against the corresponding string or regular expression in the
16361636
* array:
16371637
* <pre>{@code
1638-
* assertThat(page.locator("list > .component")).hasClass(new String[] {"component", "component selected", "component"});
1638+
* assertThat(page.locator(".list > .component")).hasClass(new String[] {"component", "component selected", "component"});
16391639
* }</pre>
16401640
*
16411641
* @param expected Expected class or RegExp or a list of those.
@@ -1657,7 +1657,7 @@ default void hasClass(Pattern expected) {
16571657
* class values. Each element's class attribute is matched against the corresponding string or regular expression in the
16581658
* array:
16591659
* <pre>{@code
1660-
* assertThat(page.locator("list > .component")).hasClass(new String[] {"component", "component selected", "component"});
1660+
* assertThat(page.locator(".list > .component")).hasClass(new String[] {"component", "component selected", "component"});
16611661
* }</pre>
16621662
*
16631663
* @param expected Expected class or RegExp or a list of those.
@@ -1681,7 +1681,7 @@ default void hasClass(String[] expected) {
16811681
* class values. Each element's class attribute is matched against the corresponding string or regular expression in the
16821682
* array:
16831683
* <pre>{@code
1684-
* assertThat(page.locator("list > .component")).hasClass(new String[] {"component", "component selected", "component"});
1684+
* assertThat(page.locator(".list > .component")).hasClass(new String[] {"component", "component selected", "component"});
16851685
* }</pre>
16861686
*
16871687
* @param expected Expected class or RegExp or a list of those.
@@ -1703,7 +1703,7 @@ default void hasClass(String[] expected) {
17031703
* class values. Each element's class attribute is matched against the corresponding string or regular expression in the
17041704
* array:
17051705
* <pre>{@code
1706-
* assertThat(page.locator("list > .component")).hasClass(new String[] {"component", "component selected", "component"});
1706+
* assertThat(page.locator(".list > .component")).hasClass(new String[] {"component", "component selected", "component"});
17071707
* }</pre>
17081708
*
17091709
* @param expected Expected class or RegExp or a list of those.
@@ -1727,7 +1727,7 @@ default void hasClass(Pattern[] expected) {
17271727
* class values. Each element's class attribute is matched against the corresponding string or regular expression in the
17281728
* array:
17291729
* <pre>{@code
1730-
* assertThat(page.locator("list > .component")).hasClass(new String[] {"component", "component selected", "component"});
1730+
* assertThat(page.locator(".list > .component")).hasClass(new String[] {"component", "component selected", "component"});
17311731
* }</pre>
17321732
*
17331733
* @param expected Expected class or RegExp or a list of those.

playwright/src/main/java/com/microsoft/playwright/impl/APIRequestContextImpl.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ class APIRequestContextImpl extends ChannelOwner implements APIRequestContext {
3939
private final TracingImpl tracing;
4040
private String disposeReason;
4141

42+
protected TimeoutSettings timeoutSettings = new TimeoutSettings();
43+
4244
APIRequestContextImpl(ChannelOwner parent, String type, String guid, JsonObject initializer) {
4345
super(parent, type, guid, initializer);
4446
this.tracing = connection.getExistingObject(initializer.getAsJsonObject("tracing").get("guid").getAsString());
@@ -93,6 +95,7 @@ private APIResponse fetchImpl(String url, RequestOptionsImpl options) {
9395
if (options == null) {
9496
options = new RequestOptionsImpl();
9597
}
98+
options.timeout = timeoutSettings.timeout(options.timeout);
9699
JsonObject params = new JsonObject();
97100
params.addProperty("url", url);
98101
if (options.params != null) {
@@ -132,9 +135,7 @@ private APIResponse fetchImpl(String url, RequestOptionsImpl options) {
132135
if (options.multipart != null) {
133136
params.add("multipartData", serializeMultipartData(options.multipart.fields));
134137
}
135-
if (options.timeout != null) {
136-
params.addProperty("timeout", options.timeout);
137-
}
138+
params.addProperty("timeout", timeoutSettings.timeout(options.timeout));
138139
if (options.failOnStatusCode != null) {
139140
params.addProperty("failOnStatusCode", options.failOnStatusCode);
140141
}

playwright/src/main/java/com/microsoft/playwright/impl/APIRequestImpl.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ private APIRequestContextImpl newContextImpl(NewContextOptions options) {
7474
addToProtocol(params, clientCertificateList);
7575
JsonObject result = playwright.sendMessage("newRequest", params).getAsJsonObject();
7676
APIRequestContextImpl context = playwright.connection.getExistingObject(result.getAsJsonObject("request").get("guid").getAsString());
77+
context.timeoutSettings.setDefaultTimeout(options.timeout);
7778
return context;
7879
}
7980
}

playwright/src/main/java/com/microsoft/playwright/impl/BrowserContextImpl.java

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ enum EventType {
105105
}
106106
tracing = connection.getExistingObject(initializer.getAsJsonObject("tracing").get("guid").getAsString());
107107
request = connection.getExistingObject(initializer.getAsJsonObject("requestContext").get("guid").getAsString());
108+
request.timeoutSettings = timeoutSettings;
108109
clock = new ClockImpl(this);
109110
closePromise = new WaitableEvent<>(listeners, EventType.CLOSE);
110111
}
@@ -559,30 +560,12 @@ void recordIntoHar(PageImpl page, Path har, RouteFromHAROptions options) {
559560

560561
@Override
561562
public void setDefaultNavigationTimeout(double timeout) {
562-
setDefaultNavigationTimeoutImpl(timeout);
563-
}
564-
565-
void setDefaultNavigationTimeoutImpl(Double timeout) {
566-
withLogging("BrowserContext.setDefaultNavigationTimeout", () -> {
567-
timeoutSettings.setDefaultNavigationTimeout(timeout);
568-
JsonObject params = new JsonObject();
569-
params.addProperty("timeout", timeout);
570-
sendMessage("setDefaultNavigationTimeoutNoReply", params);
571-
});
563+
timeoutSettings.setDefaultNavigationTimeout(timeout);
572564
}
573565

574566
@Override
575567
public void setDefaultTimeout(double timeout) {
576-
setDefaultTimeoutImpl(timeout);
577-
}
578-
579-
void setDefaultTimeoutImpl(Double timeout) {
580-
withLogging("BrowserContext.setDefaultTimeout", () -> {
581-
timeoutSettings.setDefaultTimeout(timeout);
582-
JsonObject params = new JsonObject();
583-
params.addProperty("timeout", timeout);
584-
sendMessage("setDefaultTimeoutNoReply", params);
585-
});
568+
timeoutSettings.setDefaultTimeout(timeout);
586569
}
587570

588571
@Override

0 commit comments

Comments
 (0)