Skip to content

Commit c090824

Browse files
authored
chore: roll 1.51.0 driver, implement new features (#1757)
1 parent add7f56 commit c090824

35 files changed

+1271
-76
lines changed

.github/workflows/test_cli.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
steps:
1616
- uses: actions/checkout@v2
1717
- name: Cache Maven packages
18-
uses: actions/cache@v2
18+
uses: actions/cache@v4
1919
with:
2020
path: ~/.m2
2121
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}

README.md

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

1111
| | Linux | macOS | Windows |
1212
| :--- | :---: | :---: | :---: |
13-
| Chromium <!-- GEN:chromium-version -->133.0.6943.16<!-- GEN:stop --> | :white_check_mark: | :white_check_mark: | :white_check_mark: |
14-
| WebKit <!-- GEN:webkit-version -->18.2<!-- GEN:stop --> ||||
15-
| Firefox <!-- GEN:firefox-version -->134.0<!-- GEN:stop --> | :white_check_mark: | :white_check_mark: | :white_check_mark: |
13+
| Chromium <!-- GEN:chromium-version -->134.0.6998.35<!-- GEN:stop --> | :white_check_mark: | :white_check_mark: | :white_check_mark: |
14+
| WebKit <!-- GEN:webkit-version -->18.4<!-- GEN:stop --> ||||
15+
| Firefox <!-- GEN:firefox-version -->135.0<!-- GEN:stop --> | :white_check_mark: | :white_check_mark: | :white_check_mark: |
1616

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

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.49.0</playwright.version>
13+
<playwright.version>1.51.0</playwright.version>
1414
</properties>
1515
<dependencies>
1616
<dependency>

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@ class NewContextOptions {
5959
* An object containing additional HTTP headers to be sent with every request. Defaults to none.
6060
*/
6161
public Map<String, String> extraHTTPHeaders;
62+
/**
63+
* Whether to throw on response codes other than 2xx and 3xx. By default response object is returned for all status codes.
64+
*/
65+
public Boolean failOnStatusCode;
6266
/**
6367
* Credentials for <a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Authentication">HTTP authentication</a>. If
6468
* no origin is specified, the username and password are sent to any servers upon unauthorized responses.
@@ -138,6 +142,13 @@ public NewContextOptions setExtraHTTPHeaders(Map<String, String> extraHTTPHeader
138142
this.extraHTTPHeaders = extraHTTPHeaders;
139143
return this;
140144
}
145+
/**
146+
* Whether to throw on response codes other than 2xx and 3xx. By default response object is returned for all status codes.
147+
*/
148+
public NewContextOptions setFailOnStatusCode(boolean failOnStatusCode) {
149+
this.failOnStatusCode = failOnStatusCode;
150+
return this;
151+
}
141152
/**
142153
* Credentials for <a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Authentication">HTTP authentication</a>. If
143154
* no origin is specified, the username and password are sent to any servers upon unauthorized responses.

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,23 @@ public DisposeOptions setReason(String reason) {
5858
}
5959
}
6060
class StorageStateOptions {
61+
/**
62+
* Set to {@code true} to include IndexedDB in the storage state snapshot.
63+
*/
64+
public Boolean indexedDB;
6165
/**
6266
* The file path to save the storage state to. If {@code path} is a relative path, then it is resolved relative to current
6367
* working directory. If no path is provided, storage state is still returned, but won't be saved to the disk.
6468
*/
6569
public Path path;
6670

71+
/**
72+
* Set to {@code true} to include IndexedDB in the storage state snapshot.
73+
*/
74+
public StorageStateOptions setIndexedDB(boolean indexedDB) {
75+
this.indexedDB = indexedDB;
76+
return this;
77+
}
6778
/**
6879
* The file path to save the storage state to. If {@code path} is a relative path, then it is resolved relative to current
6980
* working directory. If no path is provided, storage state is still returned, but won't be saved to the disk.

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

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,12 @@ class NewContextOptions {
118118
* "light"}.
119119
*/
120120
public Optional<ColorScheme> colorScheme;
121+
/**
122+
* Emulates {@code "prefers-contrast"} media feature, supported values are {@code "no-preference"}, {@code "more"}. See
123+
* {@link com.microsoft.playwright.Page#emulateMedia Page.emulateMedia()} for more details. Passing {@code null} resets
124+
* emulation to system defaults. Defaults to {@code "no-preference"}.
125+
*/
126+
public Optional<Contrast> contrast;
121127
/**
122128
* Specify device scale factor (can be thought of as dpr). Defaults to {@code 1}. Learn more about <a
123129
* href="https://playwright.dev/java/docs/emulation#devices">emulating devices with device scale factor</a>.
@@ -335,6 +341,15 @@ public NewContextOptions setColorScheme(ColorScheme colorScheme) {
335341
this.colorScheme = Optional.ofNullable(colorScheme);
336342
return this;
337343
}
344+
/**
345+
* Emulates {@code "prefers-contrast"} media feature, supported values are {@code "no-preference"}, {@code "more"}. See
346+
* {@link com.microsoft.playwright.Page#emulateMedia Page.emulateMedia()} for more details. Passing {@code null} resets
347+
* emulation to system defaults. Defaults to {@code "no-preference"}.
348+
*/
349+
public NewContextOptions setContrast(Contrast contrast) {
350+
this.contrast = Optional.ofNullable(contrast);
351+
return this;
352+
}
338353
/**
339354
* Specify device scale factor (can be thought of as dpr). Defaults to {@code 1}. Learn more about <a
340355
* href="https://playwright.dev/java/docs/emulation#devices">emulating devices with device scale factor</a>.
@@ -671,6 +686,12 @@ class NewPageOptions {
671686
* "light"}.
672687
*/
673688
public Optional<ColorScheme> colorScheme;
689+
/**
690+
* Emulates {@code "prefers-contrast"} media feature, supported values are {@code "no-preference"}, {@code "more"}. See
691+
* {@link com.microsoft.playwright.Page#emulateMedia Page.emulateMedia()} for more details. Passing {@code null} resets
692+
* emulation to system defaults. Defaults to {@code "no-preference"}.
693+
*/
694+
public Optional<Contrast> contrast;
674695
/**
675696
* Specify device scale factor (can be thought of as dpr). Defaults to {@code 1}. Learn more about <a
676697
* href="https://playwright.dev/java/docs/emulation#devices">emulating devices with device scale factor</a>.
@@ -888,6 +909,15 @@ public NewPageOptions setColorScheme(ColorScheme colorScheme) {
888909
this.colorScheme = Optional.ofNullable(colorScheme);
889910
return this;
890911
}
912+
/**
913+
* Emulates {@code "prefers-contrast"} media feature, supported values are {@code "no-preference"}, {@code "more"}. See
914+
* {@link com.microsoft.playwright.Page#emulateMedia Page.emulateMedia()} for more details. Passing {@code null} resets
915+
* emulation to system defaults. Defaults to {@code "no-preference"}.
916+
*/
917+
public NewPageOptions setContrast(Contrast contrast) {
918+
this.contrast = Optional.ofNullable(contrast);
919+
return this;
920+
}
891921
/**
892922
* Specify device scale factor (can be thought of as dpr). Defaults to {@code 1}. Learn more about <a
893923
* href="https://playwright.dev/java/docs/emulation#devices">emulating devices with device scale factor</a>.

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

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -407,12 +407,31 @@ public RouteFromHAROptions setUrl(Pattern url) {
407407
}
408408
}
409409
class StorageStateOptions {
410+
/**
411+
* Set to {@code true} to include <a href="https://developer.mozilla.org/en-US/docs/Web/API/IndexedDB_API">IndexedDB</a> in
412+
* the storage state snapshot. If your application uses IndexedDB to store authentication tokens, like Firebase
413+
* Authentication, enable this.
414+
*
415+
* <p> <strong>NOTE:</strong> IndexedDBs with typed arrays are currently not supported.
416+
*/
417+
public Boolean indexedDB;
410418
/**
411419
* The file path to save the storage state to. If {@code path} is a relative path, then it is resolved relative to current
412420
* working directory. If no path is provided, storage state is still returned, but won't be saved to the disk.
413421
*/
414422
public Path path;
415423

424+
/**
425+
* Set to {@code true} to include <a href="https://developer.mozilla.org/en-US/docs/Web/API/IndexedDB_API">IndexedDB</a> in
426+
* the storage state snapshot. If your application uses IndexedDB to store authentication tokens, like Firebase
427+
* Authentication, enable this.
428+
*
429+
* <p> <strong>NOTE:</strong> IndexedDBs with typed arrays are currently not supported.
430+
*/
431+
public StorageStateOptions setIndexedDB(boolean indexedDB) {
432+
this.indexedDB = indexedDB;
433+
return this;
434+
}
416435
/**
417436
* The file path to save the storage state to. If {@code path} is a relative path, then it is resolved relative to current
418437
* working directory. If no path is provided, storage state is still returned, but won't be saved to the disk.
@@ -1435,15 +1454,15 @@ default void routeFromHAR(Path har) {
14351454
*/
14361455
void setOffline(boolean offline);
14371456
/**
1438-
* Returns storage state for this browser context, contains current cookies and local storage snapshot.
1457+
* Returns storage state for this browser context, contains current cookies, local storage snapshot and IndexedDB snapshot.
14391458
*
14401459
* @since v1.8
14411460
*/
14421461
default String storageState() {
14431462
return storageState(null);
14441463
}
14451464
/**
1446-
* Returns storage state for this browser context, contains current cookies and local storage snapshot.
1465+
* Returns storage state for this browser context, contains current cookies, local storage snapshot and IndexedDB snapshot.
14471466
*
14481467
* @since v1.8
14491468
*/

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

Lines changed: 35 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -497,6 +497,12 @@ class LaunchPersistentContextOptions {
497497
* "light"}.
498498
*/
499499
public Optional<ColorScheme> colorScheme;
500+
/**
501+
* Emulates {@code "prefers-contrast"} media feature, supported values are {@code "no-preference"}, {@code "more"}. See
502+
* {@link com.microsoft.playwright.Page#emulateMedia Page.emulateMedia()} for more details. Passing {@code null} resets
503+
* emulation to system defaults. Defaults to {@code "no-preference"}.
504+
*/
505+
public Optional<Contrast> contrast;
500506
/**
501507
* Specify device scale factor (can be thought of as dpr). Defaults to {@code 1}. Learn more about <a
502508
* href="https://playwright.dev/java/docs/emulation#devices">emulating devices with device scale factor</a>.
@@ -816,6 +822,15 @@ public LaunchPersistentContextOptions setColorScheme(ColorScheme colorScheme) {
816822
this.colorScheme = Optional.ofNullable(colorScheme);
817823
return this;
818824
}
825+
/**
826+
* Emulates {@code "prefers-contrast"} media feature, supported values are {@code "no-preference"}, {@code "more"}. See
827+
* {@link com.microsoft.playwright.Page#emulateMedia Page.emulateMedia()} for more details. Passing {@code null} resets
828+
* emulation to system defaults. Defaults to {@code "no-preference"}.
829+
*/
830+
public LaunchPersistentContextOptions setContrast(Contrast contrast) {
831+
this.contrast = Optional.ofNullable(contrast);
832+
return this;
833+
}
819834
/**
820835
* Specify device scale factor (can be thought of as dpr). Defaults to {@code 1}. Learn more about <a
821836
* href="https://playwright.dev/java/docs/emulation#devices">emulating devices with device scale factor</a>.
@@ -1197,22 +1212,24 @@ public LaunchPersistentContextOptions setViewportSize(ViewportSize viewportSize)
11971212
}
11981213
}
11991214
/**
1200-
* This method attaches Playwright to an existing browser instance. When connecting to another browser launched via {@code
1201-
* BrowserType.launchServer} in Node.js, the major and minor version needs to match the client version (1.2.3 → is
1202-
* compatible with 1.2.x).
1215+
* This method attaches Playwright to an existing browser instance created via {@code BrowserType.launchServer} in Node.js.
1216+
*
1217+
* <p> <strong>NOTE:</strong> The major and minor version of the Playwright instance that connects needs to match the version of Playwright that
1218+
* launches the browser (1.2.3 → is compatible with 1.2.x).
12031219
*
1204-
* @param wsEndpoint A browser websocket endpoint to connect to.
1220+
* @param wsEndpoint A Playwright browser websocket endpoint to connect to. You obtain this endpoint via {@code BrowserServer.wsEndpoint}.
12051221
* @since v1.8
12061222
*/
12071223
default Browser connect(String wsEndpoint) {
12081224
return connect(wsEndpoint, null);
12091225
}
12101226
/**
1211-
* This method attaches Playwright to an existing browser instance. When connecting to another browser launched via {@code
1212-
* BrowserType.launchServer} in Node.js, the major and minor version needs to match the client version (1.2.3 → is
1213-
* compatible with 1.2.x).
1227+
* This method attaches Playwright to an existing browser instance created via {@code BrowserType.launchServer} in Node.js.
12141228
*
1215-
* @param wsEndpoint A browser websocket endpoint to connect to.
1229+
* <p> <strong>NOTE:</strong> The major and minor version of the Playwright instance that connects needs to match the version of Playwright that
1230+
* launches the browser (1.2.3 → is compatible with 1.2.x).
1231+
*
1232+
* @param wsEndpoint A Playwright browser websocket endpoint to connect to. You obtain this endpoint via {@code BrowserServer.wsEndpoint}.
12161233
* @since v1.8
12171234
*/
12181235
Browser connect(String wsEndpoint, ConnectOptions options);
@@ -1223,6 +1240,11 @@ default Browser connect(String wsEndpoint) {
12231240
*
12241241
* <p> <strong>NOTE:</strong> Connecting over the Chrome DevTools Protocol is only supported for Chromium-based browsers.
12251242
*
1243+
* <p> <strong>NOTE:</strong> This connection is significantly lower fidelity than the Playwright protocol connection via {@link
1244+
* com.microsoft.playwright.BrowserType#connect BrowserType.connect()}. If you are experiencing issues or attempting to use
1245+
* advanced functionality, you probably want to use {@link com.microsoft.playwright.BrowserType#connect
1246+
* BrowserType.connect()}.
1247+
*
12261248
* <p> <strong>Usage</strong>
12271249
* <pre>{@code
12281250
* Browser browser = playwright.chromium().connectOverCDP("http://localhost:9222");
@@ -1244,6 +1266,11 @@ default Browser connectOverCDP(String endpointURL) {
12441266
*
12451267
* <p> <strong>NOTE:</strong> Connecting over the Chrome DevTools Protocol is only supported for Chromium-based browsers.
12461268
*
1269+
* <p> <strong>NOTE:</strong> This connection is significantly lower fidelity than the Playwright protocol connection via {@link
1270+
* com.microsoft.playwright.BrowserType#connect BrowserType.connect()}. If you are experiencing issues or attempting to use
1271+
* advanced functionality, you probably want to use {@link com.microsoft.playwright.BrowserType#connect
1272+
* BrowserType.connect()}.
1273+
*
12471274
* <p> <strong>Usage</strong>
12481275
* <pre>{@code
12491276
* Browser browser = playwright.chromium().connectOverCDP("http://localhost:9222");

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -599,7 +599,9 @@ class ScreenshotOptions {
599599
public ScreenshotCaret caret;
600600
/**
601601
* Specify locators that should be masked when the screenshot is taken. Masked elements will be overlaid with a pink box
602-
* {@code #FF00FF} (customized by {@code maskColor}) that completely covers its bounding box.
602+
* {@code #FF00FF} (customized by {@code maskColor}) that completely covers its bounding box. The mask is also applied to
603+
* invisible elements, see <a href="https://playwright.dev/java/docs/locators#matching-only-visible-elements">Matching only
604+
* visible elements</a> to disable that.
603605
*/
604606
public List<Locator> mask;
605607
/**
@@ -673,7 +675,9 @@ public ScreenshotOptions setCaret(ScreenshotCaret caret) {
673675
}
674676
/**
675677
* Specify locators that should be masked when the screenshot is taken. Masked elements will be overlaid with a pink box
676-
* {@code #FF00FF} (customized by {@code maskColor}) that completely covers its bounding box.
678+
* {@code #FF00FF} (customized by {@code maskColor}) that completely covers its bounding box. The mask is also applied to
679+
* invisible elements, see <a href="https://playwright.dev/java/docs/locators#matching-only-visible-elements">Matching only
680+
* visible elements</a> to disable that.
677681
*/
678682
public ScreenshotOptions setMask(List<Locator> mask) {
679683
this.mask = mask;

0 commit comments

Comments
 (0)