Skip to content

Commit be59662

Browse files
authored
feat: roll driver to 1.33.0 beta (#1266)
1 parent 45591df commit be59662

File tree

12 files changed

+162
-74
lines changed

12 files changed

+162
-74
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ Playwright is a Java library to automate [Chromium](https://www.chromium.org/Hom
1111

1212
| | Linux | macOS | Windows |
1313
| :--- | :---: | :---: | :---: |
14-
| Chromium <!-- GEN:chromium-version -->113.0.5672.24<!-- GEN:stop --> | :white_check_mark: | :white_check_mark: | :white_check_mark: |
14+
| Chromium <!-- GEN:chromium-version -->113.0.5672.53<!-- GEN:stop --> | :white_check_mark: | :white_check_mark: | :white_check_mark: |
1515
| WebKit <!-- GEN:webkit-version -->16.4<!-- GEN:stop --> ||||
16-
| Firefox <!-- GEN:firefox-version -->111.0<!-- GEN:stop --> | :white_check_mark: | :white_check_mark: | :white_check_mark: |
16+
| Firefox <!-- GEN:firefox-version -->112.0<!-- GEN:stop --> | :white_check_mark: | :white_check_mark: | :white_check_mark: |
1717

1818
Headless execution is supported for all the browsers on all platforms. Check out [system requirements](https://playwright.dev/java/docs/next/intro/#system-requirements) for details.
1919

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

Lines changed: 70 additions & 40 deletions
Large diffs are not rendered by default.

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

Lines changed: 35 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,8 @@ class LaunchPersistentContextOptions {
414414
*/
415415
public Optional<ColorScheme> colorScheme;
416416
/**
417-
* Specify device scale factor (can be thought of as dpr). Defaults to {@code 1}.
417+
* Specify device scale factor (can be thought of as dpr). Defaults to {@code 1}. Learn more about <a
418+
* href="https://playwright.dev/java/docs/emulation#devices">emulating devices with device scale factor</a>.
418419
*/
419420
public Double deviceScaleFactor;
420421
/**
@@ -462,7 +463,8 @@ class LaunchPersistentContextOptions {
462463
*/
463464
public Boolean handleSIGTERM;
464465
/**
465-
* Specifies if viewport supports touch events. Defaults to false.
466+
* Specifies if viewport supports touch events. Defaults to false. Learn more about <a
467+
* href="https://playwright.dev/java/docs/emulation#devices">mobile emulation</a>.
466468
*/
467469
public Boolean hasTouch;
468470
/**
@@ -492,21 +494,25 @@ class LaunchPersistentContextOptions {
492494
*/
493495
public Boolean ignoreHTTPSErrors;
494496
/**
495-
* Whether the {@code meta viewport} tag is taken into account and touch events are enabled. Defaults to {@code false}. Not
496-
* supported in Firefox.
497+
* Whether the {@code meta viewport} tag is taken into account and touch events are enabled. isMobile is a part of device,
498+
* so you don't actually need to set it manually. Defaults to {@code false} and is not supported in Firefox. Learn more
499+
* about <a href="https://playwright.dev/java/docs/emulation#isMobile">mobile emulation</a>.
497500
*/
498501
public Boolean isMobile;
499502
/**
500-
* Whether or not to enable JavaScript in the context. Defaults to {@code true}.
503+
* Whether or not to enable JavaScript in the context. Defaults to {@code true}. Learn more about <a
504+
* href="https://playwright.dev/java/docs/emulation#javascript-enabled">disabling JavaScript</a>.
501505
*/
502506
public Boolean javaScriptEnabled;
503507
/**
504508
* Specify user locale, for example {@code en-GB}, {@code de-DE}, etc. Locale will affect {@code navigator.language} value,
505-
* {@code Accept-Language} request header value as well as number and date formatting rules.
509+
* {@code Accept-Language} request header value as well as number and date formatting rules. Learn more about emulation in
510+
* our <a href="https://playwright.dev/java/docs/emulation#locale--timezone">emulation guide</a>.
506511
*/
507512
public String locale;
508513
/**
509-
* Whether to emulate network being offline. Defaults to {@code false}.
514+
* Whether to emulate network being offline. Defaults to {@code false}. Learn more about <a
515+
* href="https://playwright.dev/java/docs/emulation#offline">network emulation</a>.
510516
*/
511517
public Boolean offline;
512518
/**
@@ -602,8 +608,9 @@ class LaunchPersistentContextOptions {
602608
*/
603609
public String userAgent;
604610
/**
605-
* Emulates consistent viewport for each page. Defaults to an 1280x720 viewport. Use {@code null} to disable the consistent
606-
* viewport emulation.
611+
* Emulates consistent viewport for each page. Defaults to an 1280x720 viewport. Use {@code null} to disable the
612+
* consistent viewport emulation. Learn more about <a href="https://playwright.dev/java/docs/emulation#viewport">viewport
613+
* emulation</a>.
607614
*
608615
* <p> <strong>NOTE:</strong> The {@code null} value opts out from the default presets, makes viewport depend on the host window size defined by the
609616
* operating system. It makes the execution of the tests non-deterministic.
@@ -687,7 +694,8 @@ public LaunchPersistentContextOptions setColorScheme(ColorScheme colorScheme) {
687694
return this;
688695
}
689696
/**
690-
* Specify device scale factor (can be thought of as dpr). Defaults to {@code 1}.
697+
* Specify device scale factor (can be thought of as dpr). Defaults to {@code 1}. Learn more about <a
698+
* href="https://playwright.dev/java/docs/emulation#devices">emulating devices with device scale factor</a>.
691699
*/
692700
public LaunchPersistentContextOptions setDeviceScaleFactor(double deviceScaleFactor) {
693701
this.deviceScaleFactor = deviceScaleFactor;
@@ -771,7 +779,8 @@ public LaunchPersistentContextOptions setHandleSIGTERM(boolean handleSIGTERM) {
771779
return this;
772780
}
773781
/**
774-
* Specifies if viewport supports touch events. Defaults to false.
782+
* Specifies if viewport supports touch events. Defaults to false. Learn more about <a
783+
* href="https://playwright.dev/java/docs/emulation#devices">mobile emulation</a>.
775784
*/
776785
public LaunchPersistentContextOptions setHasTouch(boolean hasTouch) {
777786
this.hasTouch = hasTouch;
@@ -826,30 +835,34 @@ public LaunchPersistentContextOptions setIgnoreHTTPSErrors(boolean ignoreHTTPSEr
826835
return this;
827836
}
828837
/**
829-
* Whether the {@code meta viewport} tag is taken into account and touch events are enabled. Defaults to {@code false}. Not
830-
* supported in Firefox.
838+
* Whether the {@code meta viewport} tag is taken into account and touch events are enabled. isMobile is a part of device,
839+
* so you don't actually need to set it manually. Defaults to {@code false} and is not supported in Firefox. Learn more
840+
* about <a href="https://playwright.dev/java/docs/emulation#isMobile">mobile emulation</a>.
831841
*/
832842
public LaunchPersistentContextOptions setIsMobile(boolean isMobile) {
833843
this.isMobile = isMobile;
834844
return this;
835845
}
836846
/**
837-
* Whether or not to enable JavaScript in the context. Defaults to {@code true}.
847+
* Whether or not to enable JavaScript in the context. Defaults to {@code true}. Learn more about <a
848+
* href="https://playwright.dev/java/docs/emulation#javascript-enabled">disabling JavaScript</a>.
838849
*/
839850
public LaunchPersistentContextOptions setJavaScriptEnabled(boolean javaScriptEnabled) {
840851
this.javaScriptEnabled = javaScriptEnabled;
841852
return this;
842853
}
843854
/**
844855
* Specify user locale, for example {@code en-GB}, {@code de-DE}, etc. Locale will affect {@code navigator.language} value,
845-
* {@code Accept-Language} request header value as well as number and date formatting rules.
856+
* {@code Accept-Language} request header value as well as number and date formatting rules. Learn more about emulation in
857+
* our <a href="https://playwright.dev/java/docs/emulation#locale--timezone">emulation guide</a>.
846858
*/
847859
public LaunchPersistentContextOptions setLocale(String locale) {
848860
this.locale = locale;
849861
return this;
850862
}
851863
/**
852-
* Whether to emulate network being offline. Defaults to {@code false}.
864+
* Whether to emulate network being offline. Defaults to {@code false}. Learn more about <a
865+
* href="https://playwright.dev/java/docs/emulation#offline">network emulation</a>.
853866
*/
854867
public LaunchPersistentContextOptions setOffline(boolean offline) {
855868
this.offline = offline;
@@ -1027,8 +1040,9 @@ public LaunchPersistentContextOptions setUserAgent(String userAgent) {
10271040
return this;
10281041
}
10291042
/**
1030-
* Emulates consistent viewport for each page. Defaults to an 1280x720 viewport. Use {@code null} to disable the consistent
1031-
* viewport emulation.
1043+
* Emulates consistent viewport for each page. Defaults to an 1280x720 viewport. Use {@code null} to disable the
1044+
* consistent viewport emulation. Learn more about <a href="https://playwright.dev/java/docs/emulation#viewport">viewport
1045+
* emulation</a>.
10321046
*
10331047
* <p> <strong>NOTE:</strong> The {@code null} value opts out from the default presets, makes viewport depend on the host window size defined by the
10341048
* operating system. It makes the execution of the tests non-deterministic.
@@ -1037,8 +1051,9 @@ public LaunchPersistentContextOptions setViewportSize(int width, int height) {
10371051
return setViewportSize(new ViewportSize(width, height));
10381052
}
10391053
/**
1040-
* Emulates consistent viewport for each page. Defaults to an 1280x720 viewport. Use {@code null} to disable the consistent
1041-
* viewport emulation.
1054+
* Emulates consistent viewport for each page. Defaults to an 1280x720 viewport. Use {@code null} to disable the
1055+
* consistent viewport emulation. Learn more about <a href="https://playwright.dev/java/docs/emulation#viewport">viewport
1056+
* emulation</a>.
10421057
*
10431058
* <p> <strong>NOTE:</strong> The {@code null} value opts out from the default presets, makes viewport depend on the host window size defined by the
10441059
* operating system. It makes the execution of the tests non-deterministic.

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2020,9 +2020,10 @@ public WaitForOptions setTimeout(double timeout) {
20202020
/**
20212021
* When locator points to a list of elements, returns array of locators, pointing to respective elements.
20222022
*
2023-
* <p> Note that {@link Locator#all Locator.all()} does not wait for elements to match the locator, and instead immediately
2024-
* returns whatever is present in the page. To avoid flakiness when elements are loaded dynamically, wait for the loading
2025-
* to finish before calling {@link Locator#all Locator.all()}.
2023+
* <p> <strong>NOTE:</strong> {@link Locator#all Locator.all()} does not wait for elements to match the locator, and instead immediately returns
2024+
* whatever is present in the page. When the list of elements changes dynamically, {@link Locator#all Locator.all()} will
2025+
* produce unpredictable and flaky results. When the list of elements is stable, but loaded dynamically, wait for the full
2026+
* list to finish loading before calling {@link Locator#all Locator.all()}.
20262027
*
20272028
* <p> **Usage**
20282029
* <pre>{@code

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,10 @@ class FetchOptions {
154154
* If set changes the post data of request.
155155
*/
156156
public Object postData;
157+
/**
158+
* Request timeout in milliseconds. Defaults to {@code 30000} (30 seconds). Pass {@code 0} to disable timeout.
159+
*/
160+
public Double timeout;
157161
/**
158162
* If set changes the request URL. New URL must have same protocol as original one.
159163
*/
@@ -195,6 +199,13 @@ public FetchOptions setPostData(byte[] postData) {
195199
this.postData = postData;
196200
return this;
197201
}
202+
/**
203+
* Request timeout in milliseconds. Defaults to {@code 30000} (30 seconds). Pass {@code 0} to disable timeout.
204+
*/
205+
public FetchOptions setTimeout(double timeout) {
206+
this.timeout = timeout;
207+
return this;
208+
}
198209
/**
199210
* If set changes the request URL. New URL must have same protocol as original one.
200211
*/

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,9 @@ public APIResponse fetch(FetchOptions fetchOptions) {
9292
} else {
9393
options.data = request.postDataBuffer();
9494
}
95+
if (fetchOptions != null && fetchOptions.timeout != null) {
96+
options.timeout = fetchOptions.timeout;
97+
}
9598
APIRequestContextImpl apiRequest = request.frame().page().context().request();
9699
String url = (fetchOptions == null || fetchOptions.url == null) ? request().url() : fetchOptions.url;
97100
return apiRequest.fetch(url, options);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ static void writeToFile(byte[] buffer, Path path) {
252252
static void writeToFile(InputStream inputStream, Path path) {
253253
mkParentDirs(path);
254254
try (FileOutputStream out = new FileOutputStream(path.toFile())) {
255-
byte[] buf = new byte[8192];
255+
byte[] buf = new byte[1024 * 1024];
256256
int length;
257257
while ((length = inputStream.read(buf)) > 0) {
258258
out.write(buf, 0, length);

playwright/src/test/java/com/microsoft/playwright/TestClick.java

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,12 @@
1616

1717
package com.microsoft.playwright;
1818

19-
import com.microsoft.playwright.options.AriaRole;
20-
import com.microsoft.playwright.options.WaitUntilState;
2119
import org.junit.jupiter.api.Test;
2220
import org.junit.jupiter.api.condition.DisabledIf;
2321
import org.junit.jupiter.api.condition.EnabledIf;
2422

2523
import java.util.ArrayList;
2624
import java.util.List;
27-
import java.util.function.Predicate;
2825

2926
import static com.microsoft.playwright.options.KeyboardModifier.SHIFT;
3027
import static com.microsoft.playwright.options.MouseButton.RIGHT;
@@ -425,15 +422,23 @@ void shouldClickTheButtonWithOffsetWithPageScale() {
425422
// 20;10 + 8px of border in each direction
426423
int expectedX = 28;
427424
int expectedY = 18;
425+
428426
if (isWebKit()) {
429-
// WebKit rounds up during css -> dip -> css conversion.
430-
expectedX = 26;
431-
expectedY = 17;
427+
// WebKit for macOS 12 has different expectations starting r1829.
428+
if (isMac && Utils.osVersion() < 12) {
429+
// WebKit rounds up during css -> dip -> css conversion.
430+
expectedX = 26;
431+
expectedY = 17;
432+
} else {
433+
expectedX = 29;
434+
expectedY = 19;
435+
}
432436
} else if (isChromium() && !headful) {
433437
// Headless Chromium rounds down during css -> dip -> css conversion.
434438
expectedX = 27;
435439
expectedY = 18;
436440
}
441+
437442
assertEquals(expectedX, Math.round((Integer) page.evaluate("pageX") + 0.01));
438443
assertEquals(expectedY, Math.round((Integer) page.evaluate("pageY") + 0.01));
439444
context.close();

playwright/src/test/java/com/microsoft/playwright/TestPageInterception.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
import org.junit.jupiter.api.Test;
44

5+
import java.io.OutputStreamWriter;
6+
import java.io.Writer;
57
import java.util.HashMap;
68
import java.util.concurrent.ExecutionException;
79
import java.util.concurrent.Future;
@@ -71,6 +73,23 @@ void shouldFulfillInterceptedResponseUsingAlias() {
7173
assertTrue(response.headers().get("content-type").contains("text/html"));
7274
}
7375

76+
@Test
77+
void shouldSupportTimeoutOptionInRouteFetch() {
78+
server.setRoute("/slow", exchange -> {
79+
exchange.getResponseHeaders().set("Content-type", "text/plain");
80+
exchange.sendResponseHeaders(200, 4096);
81+
});
82+
83+
page.route("**/*", route -> {
84+
PlaywrightException error = assertThrows(PlaywrightException.class,
85+
() -> route.fetch(new Route.FetchOptions().setTimeout(1000)));
86+
assertTrue(error.getMessage().contains("Request timed out after 1000ms"), error.getMessage());
87+
});
88+
PlaywrightException error = assertThrows(PlaywrightException.class,
89+
() -> page.navigate(server.PREFIX + "/slow", new Page.NavigateOptions().setTimeout(2000)));
90+
assertTrue(error.getMessage().contains("Timeout 2000ms exceeded"), error.getMessage());
91+
}
92+
7493
@Test
7594
void shouldInterceptWithUrlOverride() {
7695
page.route("**/*.html", route -> {

playwright/src/test/java/com/microsoft/playwright/TestWebSocket.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ void shouldRejectFutureEventOnSocketClose() {
185185
PlaywrightException e = assertThrows(PlaywrightException.class, () -> {
186186
ws.waitForFrameSent(() -> page.evaluate("window.ws.close()"));
187187
});
188-
assertTrue(e.getMessage().contains("Socket closed"), e.getMessage());
188+
assertTrue(e.getMessage().matches("Socket closed|Socket error"), e.getMessage());
189189
}
190190

191191
@Test

0 commit comments

Comments
 (0)