Skip to content

Commit 7b8efad

Browse files
authored
chore: roll driver, implement new features (microsoft#1559)
1 parent a654a42 commit 7b8efad

28 files changed

Lines changed: 1112 additions & 99 deletions

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 -->124.0.6367.18<!-- GEN:stop --> | :white_check_mark: | :white_check_mark: | :white_check_mark: |
14+
| Chromium <!-- GEN:chromium-version -->125.0.6422.14<!-- GEN:stop --> | :white_check_mark: | :white_check_mark: | :white_check_mark: |
1515
| WebKit <!-- GEN:webkit-version -->17.4<!-- GEN:stop --> ||||
16-
| Firefox <!-- GEN:firefox-version -->124.0<!-- GEN:stop --> | :white_check_mark: | :white_check_mark: | :white_check_mark: |
16+
| Firefox <!-- GEN:firefox-version -->125.0.1<!-- 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/intro#system-requirements) for details.
1919

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

Lines changed: 36 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -91,19 +91,21 @@ default APIResponse delete(String url) {
9191
void dispose();
9292
/**
9393
* Sends HTTP(S) request and returns its response. The method will populate request cookies from the context and update
94-
* context cookies from the response. The method will automatically follow redirects. JSON objects can be passed directly
95-
* to the request.
94+
* context cookies from the response. The method will automatically follow redirects.
9695
*
9796
* <p> <strong>Usage</strong>
97+
*
98+
* <p> JSON objects can be passed directly to the request:
9899
* <pre>{@code
99100
* Map<String, Object> data = new HashMap();
100101
* data.put("title", "Book Title");
101102
* data.put("body", "John Doe");
102103
* request.fetch("https://example.com/api/createBook", RequestOptions.create().setMethod("post").setData(data));
103104
* }</pre>
104105
*
105-
* <p> The common way to send file(s) in the body of a request is to encode it as form fields with {@code multipart/form-data}
106-
* encoding. You can achieve that with Playwright API like this:
106+
* <p> The common way to send file(s) in the body of a request is to upload them as form fields with {@code
107+
* multipart/form-data} encoding. Use {@code FormData} to construct request body and pass it to the request as {@code
108+
* multipart} parameter:
107109
* <pre>{@code
108110
* // Pass file path to the form data constructor:
109111
* Path file = Paths.get("team.csv");
@@ -114,7 +116,7 @@ default APIResponse delete(String url) {
114116
* // Or you can pass the file content directly as FilePayload object:
115117
* FilePayload filePayload = new FilePayload("f.js", "text/javascript",
116118
* "console.log(2022);".getBytes(StandardCharsets.UTF_8));
117-
* APIResponse response = request.fetch("https://example.com/api/uploadTeamList",
119+
* APIResponse response = request.fetch("https://example.com/api/uploadScript",
118120
* RequestOptions.create().setMethod("post").setMultipart(
119121
* FormData.create().set("fileField", filePayload)));
120122
* }</pre>
@@ -127,19 +129,21 @@ default APIResponse fetch(String urlOrRequest) {
127129
}
128130
/**
129131
* Sends HTTP(S) request and returns its response. The method will populate request cookies from the context and update
130-
* context cookies from the response. The method will automatically follow redirects. JSON objects can be passed directly
131-
* to the request.
132+
* context cookies from the response. The method will automatically follow redirects.
132133
*
133134
* <p> <strong>Usage</strong>
135+
*
136+
* <p> JSON objects can be passed directly to the request:
134137
* <pre>{@code
135138
* Map<String, Object> data = new HashMap();
136139
* data.put("title", "Book Title");
137140
* data.put("body", "John Doe");
138141
* request.fetch("https://example.com/api/createBook", RequestOptions.create().setMethod("post").setData(data));
139142
* }</pre>
140143
*
141-
* <p> The common way to send file(s) in the body of a request is to encode it as form fields with {@code multipart/form-data}
142-
* encoding. You can achieve that with Playwright API like this:
144+
* <p> The common way to send file(s) in the body of a request is to upload them as form fields with {@code
145+
* multipart/form-data} encoding. Use {@code FormData} to construct request body and pass it to the request as {@code
146+
* multipart} parameter:
143147
* <pre>{@code
144148
* // Pass file path to the form data constructor:
145149
* Path file = Paths.get("team.csv");
@@ -150,7 +154,7 @@ default APIResponse fetch(String urlOrRequest) {
150154
* // Or you can pass the file content directly as FilePayload object:
151155
* FilePayload filePayload = new FilePayload("f.js", "text/javascript",
152156
* "console.log(2022);".getBytes(StandardCharsets.UTF_8));
153-
* APIResponse response = request.fetch("https://example.com/api/uploadTeamList",
157+
* APIResponse response = request.fetch("https://example.com/api/uploadScript",
154158
* RequestOptions.create().setMethod("post").setMultipart(
155159
* FormData.create().set("fileField", filePayload)));
156160
* }</pre>
@@ -162,19 +166,21 @@ default APIResponse fetch(String urlOrRequest) {
162166
APIResponse fetch(String urlOrRequest, RequestOptions params);
163167
/**
164168
* Sends HTTP(S) request and returns its response. The method will populate request cookies from the context and update
165-
* context cookies from the response. The method will automatically follow redirects. JSON objects can be passed directly
166-
* to the request.
169+
* context cookies from the response. The method will automatically follow redirects.
167170
*
168171
* <p> <strong>Usage</strong>
172+
*
173+
* <p> JSON objects can be passed directly to the request:
169174
* <pre>{@code
170175
* Map<String, Object> data = new HashMap();
171176
* data.put("title", "Book Title");
172177
* data.put("body", "John Doe");
173178
* request.fetch("https://example.com/api/createBook", RequestOptions.create().setMethod("post").setData(data));
174179
* }</pre>
175180
*
176-
* <p> The common way to send file(s) in the body of a request is to encode it as form fields with {@code multipart/form-data}
177-
* encoding. You can achieve that with Playwright API like this:
181+
* <p> The common way to send file(s) in the body of a request is to upload them as form fields with {@code
182+
* multipart/form-data} encoding. Use {@code FormData} to construct request body and pass it to the request as {@code
183+
* multipart} parameter:
178184
* <pre>{@code
179185
* // Pass file path to the form data constructor:
180186
* Path file = Paths.get("team.csv");
@@ -185,7 +191,7 @@ default APIResponse fetch(String urlOrRequest) {
185191
* // Or you can pass the file content directly as FilePayload object:
186192
* FilePayload filePayload = new FilePayload("f.js", "text/javascript",
187193
* "console.log(2022);".getBytes(StandardCharsets.UTF_8));
188-
* APIResponse response = request.fetch("https://example.com/api/uploadTeamList",
194+
* APIResponse response = request.fetch("https://example.com/api/uploadScript",
189195
* RequestOptions.create().setMethod("post").setMultipart(
190196
* FormData.create().set("fileField", filePayload)));
191197
* }</pre>
@@ -198,19 +204,21 @@ default APIResponse fetch(Request urlOrRequest) {
198204
}
199205
/**
200206
* Sends HTTP(S) request and returns its response. The method will populate request cookies from the context and update
201-
* context cookies from the response. The method will automatically follow redirects. JSON objects can be passed directly
202-
* to the request.
207+
* context cookies from the response. The method will automatically follow redirects.
203208
*
204209
* <p> <strong>Usage</strong>
210+
*
211+
* <p> JSON objects can be passed directly to the request:
205212
* <pre>{@code
206213
* Map<String, Object> data = new HashMap();
207214
* data.put("title", "Book Title");
208215
* data.put("body", "John Doe");
209216
* request.fetch("https://example.com/api/createBook", RequestOptions.create().setMethod("post").setData(data));
210217
* }</pre>
211218
*
212-
* <p> The common way to send file(s) in the body of a request is to encode it as form fields with {@code multipart/form-data}
213-
* encoding. You can achieve that with Playwright API like this:
219+
* <p> The common way to send file(s) in the body of a request is to upload them as form fields with {@code
220+
* multipart/form-data} encoding. Use {@code FormData} to construct request body and pass it to the request as {@code
221+
* multipart} parameter:
214222
* <pre>{@code
215223
* // Pass file path to the form data constructor:
216224
* Path file = Paths.get("team.csv");
@@ -221,7 +229,7 @@ default APIResponse fetch(Request urlOrRequest) {
221229
* // Or you can pass the file content directly as FilePayload object:
222230
* FilePayload filePayload = new FilePayload("f.js", "text/javascript",
223231
* "console.log(2022);".getBytes(StandardCharsets.UTF_8));
224-
* APIResponse response = request.fetch("https://example.com/api/uploadTeamList",
232+
* APIResponse response = request.fetch("https://example.com/api/uploadScript",
225233
* RequestOptions.create().setMethod("post").setMultipart(
226234
* FormData.create().set("fileField", filePayload)));
227235
* }</pre>
@@ -337,7 +345,8 @@ default APIResponse patch(String url) {
337345
* }</pre>
338346
*
339347
* <p> The common way to send file(s) in the body of a request is to upload them as form fields with {@code
340-
* multipart/form-data} encoding. You can achieve that with Playwright API like this:
348+
* multipart/form-data} encoding. Use {@code FormData} to construct request body and pass it to the request as {@code
349+
* multipart} parameter:
341350
* <pre>{@code
342351
* // Pass file path to the form data constructor:
343352
* Path file = Paths.get("team.csv");
@@ -346,9 +355,9 @@ default APIResponse patch(String url) {
346355
* FormData.create().set("fileField", file)));
347356
*
348357
* // Or you can pass the file content directly as FilePayload object:
349-
* FilePayload filePayload = new FilePayload("f.js", "text/javascript",
358+
* FilePayload filePayload1 = new FilePayload("f1.js", "text/javascript",
350359
* "console.log(2022);".getBytes(StandardCharsets.UTF_8));
351-
* APIResponse response = request.post("https://example.com/api/uploadTeamList",
360+
* APIResponse response = request.post("https://example.com/api/uploadScript",
352361
* RequestOptions.create().setMultipart(
353362
* FormData.create().set("fileField", filePayload)));
354363
* }</pre>
@@ -384,7 +393,8 @@ default APIResponse post(String url) {
384393
* }</pre>
385394
*
386395
* <p> The common way to send file(s) in the body of a request is to upload them as form fields with {@code
387-
* multipart/form-data} encoding. You can achieve that with Playwright API like this:
396+
* multipart/form-data} encoding. Use {@code FormData} to construct request body and pass it to the request as {@code
397+
* multipart} parameter:
388398
* <pre>{@code
389399
* // Pass file path to the form data constructor:
390400
* Path file = Paths.get("team.csv");
@@ -393,9 +403,9 @@ default APIResponse post(String url) {
393403
* FormData.create().set("fileField", file)));
394404
*
395405
* // Or you can pass the file content directly as FilePayload object:
396-
* FilePayload filePayload = new FilePayload("f.js", "text/javascript",
406+
* FilePayload filePayload1 = new FilePayload("f1.js", "text/javascript",
397407
* "console.log(2022);".getBytes(StandardCharsets.UTF_8));
398-
* APIResponse response = request.post("https://example.com/api/uploadTeamList",
408+
* APIResponse response = request.post("https://example.com/api/uploadScript",
399409
* RequestOptions.create().setMultipart(
400410
* FormData.create().set("fileField", filePayload)));
401411
* }</pre>

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,9 @@ public interface BrowserContext extends AutoCloseable {
4949
*
5050
* <p> Emitted when new background page is created in the context.
5151
* <pre>{@code
52-
* Page backgroundPage = context.waitForBackgroundPage(() -> {
53-
* page.getByText("activate extension").click();
52+
* context.onBackgroundPage(backgroundPage -> {
53+
* System.out.println(backgroundPage.url());
5454
* });
55-
* System.out.println(backgroundPage.evaluate("location.href"));
5655
* }</pre>
5756
*/
5857
void onBackgroundPage(Consumer<Page> handler);
@@ -128,7 +127,10 @@ public interface BrowserContext extends AutoCloseable {
128127
*
129128
* <p> The earliest moment that page is available is when it has navigated to the initial url. For example, when opening a
130129
* popup with {@code window.open('http://example.com')}, this event will fire when the network request to
131-
* "http://example.com" is done and its response has started loading in the popup.
130+
* "http://example.com" is done and its response has started loading in the popup. If you would like to route/listen to
131+
* this network request, use {@link com.microsoft.playwright.BrowserContext#route BrowserContext.route()} and {@link
132+
* com.microsoft.playwright.BrowserContext#onRequest BrowserContext.onRequest()} respectively instead of similar methods on
133+
* the {@code Page}.
132134
* <pre>{@code
133135
* Page newPage = context.waitForPage(() -> {
134136
* page.getByText("open new page").click();

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4989,6 +4989,9 @@ default JSHandle waitForFunction(String expression) {
49894989
* <p> This returns when the frame reaches a required load state, {@code load} by default. The navigation must have been
49904990
* committed when this method is called. If current document has already reached the required state, resolves immediately.
49914991
*
4992+
* <p> <strong>NOTE:</strong> Most of the time, this method is not needed because Playwright <a
4993+
* href="https://playwright.dev/java/docs/actionability">auto-waits before every action</a>.
4994+
*
49924995
* <p> <strong>Usage</strong>
49934996
* <pre>{@code
49944997
* frame.click("button"); // Click triggers navigation.
@@ -5014,6 +5017,9 @@ default void waitForLoadState(LoadState state) {
50145017
* <p> This returns when the frame reaches a required load state, {@code load} by default. The navigation must have been
50155018
* committed when this method is called. If current document has already reached the required state, resolves immediately.
50165019
*
5020+
* <p> <strong>NOTE:</strong> Most of the time, this method is not needed because Playwright <a
5021+
* href="https://playwright.dev/java/docs/actionability">auto-waits before every action</a>.
5022+
*
50175023
* <p> <strong>Usage</strong>
50185024
* <pre>{@code
50195025
* frame.click("button"); // Click triggers navigation.
@@ -5031,6 +5037,9 @@ default void waitForLoadState() {
50315037
* <p> This returns when the frame reaches a required load state, {@code load} by default. The navigation must have been
50325038
* committed when this method is called. If current document has already reached the required state, resolves immediately.
50335039
*
5040+
* <p> <strong>NOTE:</strong> Most of the time, this method is not needed because Playwright <a
5041+
* href="https://playwright.dev/java/docs/actionability">auto-waits before every action</a>.
5042+
*
50345043
* <p> <strong>Usage</strong>
50355044
* <pre>{@code
50365045
* frame.click("button"); // Click triggers navigation.

0 commit comments

Comments
 (0)