Skip to content

Commit bb4f329

Browse files
authored
feat: roll 1.27.0 alpha oct 5 2022 (#1091)
1 parent ae54a7d commit bb4f329

33 files changed

+3080
-232
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 -->106.0.5249.30<!-- GEN:stop --> | :white_check_mark: | :white_check_mark: | :white_check_mark: |
14+
| Chromium <!-- GEN:chromium-version -->107.0.5304.18<!-- GEN:stop --> | :white_check_mark: | :white_check_mark: | :white_check_mark: |
1515
| WebKit <!-- GEN:webkit-version -->16.0<!-- GEN:stop --> ||||
16-
| Firefox <!-- GEN:firefox-version -->104.0<!-- GEN:stop --> | :white_check_mark: | :white_check_mark: | :white_check_mark: |
16+
| Firefox <!-- GEN:firefox-version -->105.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/next/intro/#system-requirements) for details.
1919

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

Lines changed: 180 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,31 @@ default APIResponse delete(String url) {
8686
* Sends HTTP(S) request and returns its response. The method will populate request cookies from the context and update
8787
* context cookies from the response. The method will automatically follow redirects.
8888
*
89+
* <p> JSON objects can be passed directly to the request:
90+
* <pre>{@code
91+
* Map<String, Object> data = new HashMap();
92+
* data.put("title", "Book Title");
93+
* data.put("body", "John Doe");
94+
* request.fetch("https://example.com/api/createBook", RequestOptions.create().setMethod("post").setData(data));
95+
* }</pre>
96+
*
97+
* <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}
98+
* encoding. You can achieve that with Playwright API like this:
99+
* <pre>{@code
100+
* // Pass file path to the form data constructor:
101+
* Path file = Paths.get("team.csv");
102+
* APIResponse response = request.fetch("https://example.com/api/uploadTeamList",
103+
* RequestOptions.create().setMethod("post").setMultipart(
104+
* FormData.create().set("fileField", file)));
105+
*
106+
* // Or you can pass the file content directly as FilePayload object:
107+
* FilePayload filePayload = new FilePayload("f.js", "text/javascript",
108+
* "console.log(2022);".getBytes(StandardCharsets.UTF_8));
109+
* APIResponse response = request.fetch("https://example.com/api/uploadTeamList",
110+
* RequestOptions.create().setMethod("post").setMultipart(
111+
* FormData.create().set("fileField", filePayload)));
112+
* }</pre>
113+
*
89114
* @param urlOrRequest Target URL or Request to get all parameters from.
90115
*/
91116
default APIResponse fetch(String urlOrRequest) {
@@ -95,6 +120,31 @@ default APIResponse fetch(String urlOrRequest) {
95120
* Sends HTTP(S) request and returns its response. The method will populate request cookies from the context and update
96121
* context cookies from the response. The method will automatically follow redirects.
97122
*
123+
* <p> JSON objects can be passed directly to the request:
124+
* <pre>{@code
125+
* Map<String, Object> data = new HashMap();
126+
* data.put("title", "Book Title");
127+
* data.put("body", "John Doe");
128+
* request.fetch("https://example.com/api/createBook", RequestOptions.create().setMethod("post").setData(data));
129+
* }</pre>
130+
*
131+
* <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}
132+
* encoding. You can achieve that with Playwright API like this:
133+
* <pre>{@code
134+
* // Pass file path to the form data constructor:
135+
* Path file = Paths.get("team.csv");
136+
* APIResponse response = request.fetch("https://example.com/api/uploadTeamList",
137+
* RequestOptions.create().setMethod("post").setMultipart(
138+
* FormData.create().set("fileField", file)));
139+
*
140+
* // Or you can pass the file content directly as FilePayload object:
141+
* FilePayload filePayload = new FilePayload("f.js", "text/javascript",
142+
* "console.log(2022);".getBytes(StandardCharsets.UTF_8));
143+
* APIResponse response = request.fetch("https://example.com/api/uploadTeamList",
144+
* RequestOptions.create().setMethod("post").setMultipart(
145+
* FormData.create().set("fileField", filePayload)));
146+
* }</pre>
147+
*
98148
* @param urlOrRequest Target URL or Request to get all parameters from.
99149
* @param params Optional request parameters.
100150
*/
@@ -103,6 +153,31 @@ default APIResponse fetch(String urlOrRequest) {
103153
* Sends HTTP(S) request and returns its response. The method will populate request cookies from the context and update
104154
* context cookies from the response. The method will automatically follow redirects.
105155
*
156+
* <p> JSON objects can be passed directly to the request:
157+
* <pre>{@code
158+
* Map<String, Object> data = new HashMap();
159+
* data.put("title", "Book Title");
160+
* data.put("body", "John Doe");
161+
* request.fetch("https://example.com/api/createBook", RequestOptions.create().setMethod("post").setData(data));
162+
* }</pre>
163+
*
164+
* <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}
165+
* encoding. You can achieve that with Playwright API like this:
166+
* <pre>{@code
167+
* // Pass file path to the form data constructor:
168+
* Path file = Paths.get("team.csv");
169+
* APIResponse response = request.fetch("https://example.com/api/uploadTeamList",
170+
* RequestOptions.create().setMethod("post").setMultipart(
171+
* FormData.create().set("fileField", file)));
172+
*
173+
* // Or you can pass the file content directly as FilePayload object:
174+
* FilePayload filePayload = new FilePayload("f.js", "text/javascript",
175+
* "console.log(2022);".getBytes(StandardCharsets.UTF_8));
176+
* APIResponse response = request.fetch("https://example.com/api/uploadTeamList",
177+
* RequestOptions.create().setMethod("post").setMultipart(
178+
* FormData.create().set("fileField", filePayload)));
179+
* }</pre>
180+
*
106181
* @param urlOrRequest Target URL or Request to get all parameters from.
107182
*/
108183
default APIResponse fetch(Request urlOrRequest) {
@@ -112,6 +187,31 @@ default APIResponse fetch(Request urlOrRequest) {
112187
* Sends HTTP(S) request and returns its response. The method will populate request cookies from the context and update
113188
* context cookies from the response. The method will automatically follow redirects.
114189
*
190+
* <p> JSON objects can be passed directly to the request:
191+
* <pre>{@code
192+
* Map<String, Object> data = new HashMap();
193+
* data.put("title", "Book Title");
194+
* data.put("body", "John Doe");
195+
* request.fetch("https://example.com/api/createBook", RequestOptions.create().setMethod("post").setData(data));
196+
* }</pre>
197+
*
198+
* <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}
199+
* encoding. You can achieve that with Playwright API like this:
200+
* <pre>{@code
201+
* // Pass file path to the form data constructor:
202+
* Path file = Paths.get("team.csv");
203+
* APIResponse response = request.fetch("https://example.com/api/uploadTeamList",
204+
* RequestOptions.create().setMethod("post").setMultipart(
205+
* FormData.create().set("fileField", file)));
206+
*
207+
* // Or you can pass the file content directly as FilePayload object:
208+
* FilePayload filePayload = new FilePayload("f.js", "text/javascript",
209+
* "console.log(2022);".getBytes(StandardCharsets.UTF_8));
210+
* APIResponse response = request.fetch("https://example.com/api/uploadTeamList",
211+
* RequestOptions.create().setMethod("post").setMultipart(
212+
* FormData.create().set("fileField", filePayload)));
213+
* }</pre>
214+
*
115215
* @param urlOrRequest Target URL or Request to get all parameters from.
116216
* @param params Optional request parameters.
117217
*/
@@ -121,6 +221,13 @@ default APIResponse fetch(Request urlOrRequest) {
121221
* response. The method will populate request cookies from the context and update context cookies from the response. The
122222
* method will automatically follow redirects.
123223
*
224+
* <p> Request parameters can be configured with {@code params} option, they will be serialized into the URL search parameters:
225+
* <pre>{@code
226+
* request.get("https://example.com/api/getText", RequestOptions.create()
227+
* .setQueryParam("isbn", "1234")
228+
* .setQueryParam("page", 23));
229+
* }</pre>
230+
*
124231
* @param url Target URL.
125232
*/
126233
default APIResponse get(String url) {
@@ -131,6 +238,13 @@ default APIResponse get(String url) {
131238
* response. The method will populate request cookies from the context and update context cookies from the response. The
132239
* method will automatically follow redirects.
133240
*
241+
* <p> Request parameters can be configured with {@code params} option, they will be serialized into the URL search parameters:
242+
* <pre>{@code
243+
* request.get("https://example.com/api/getText", RequestOptions.create()
244+
* .setQueryParam("isbn", "1234")
245+
* .setQueryParam("page", 23));
246+
* }</pre>
247+
*
134248
* @param url Target URL.
135249
* @param params Optional request parameters.
136250
*/
@@ -178,6 +292,39 @@ default APIResponse patch(String url) {
178292
* response. The method will populate request cookies from the context and update context cookies from the response. The
179293
* method will automatically follow redirects.
180294
*
295+
* <p> JSON objects can be passed directly to the request:
296+
* <pre>{@code
297+
* Map<String, Object> data = new HashMap();
298+
* data.put("title", "Book Title");
299+
* data.put("body", "John Doe");
300+
* request.post("https://example.com/api/createBook", RequestOptions.create().setData(data));
301+
* }</pre>
302+
*
303+
* <p> To send form data to the server use {@code form} option. Its value will be encoded into the request body with
304+
* {@code application/x-www-form-urlencoded} encoding (see below how to use {@code multipart/form-data} form encoding to send files):
305+
* <pre>{@code
306+
* request.post("https://example.com/api/findBook", RequestOptions.create().setForm(
307+
* FormData.create().set("title", "Book Title").set("body", "John Doe")
308+
* ));
309+
* }</pre>
310+
*
311+
* <p> The common way to send file(s) in the body of a request is to upload them as form fields with {@code multipart/form-data}
312+
* encoding. You can achieve that with Playwright API like this:
313+
* <pre>{@code
314+
* // Pass file path to the form data constructor:
315+
* Path file = Paths.get("team.csv");
316+
* APIResponse response = request.post("https://example.com/api/uploadTeamList",
317+
* RequestOptions.create().setMultipart(
318+
* FormData.create().set("fileField", file)));
319+
*
320+
* // Or you can pass the file content directly as FilePayload object:
321+
* FilePayload filePayload = new FilePayload("f.js", "text/javascript",
322+
* "console.log(2022);".getBytes(StandardCharsets.UTF_8));
323+
* APIResponse response = request.post("https://example.com/api/uploadTeamList",
324+
* RequestOptions.create().setMultipart(
325+
* FormData.create().set("fileField", filePayload)));
326+
* }</pre>
327+
*
181328
* @param url Target URL.
182329
*/
183330
default APIResponse post(String url) {
@@ -188,6 +335,39 @@ default APIResponse post(String url) {
188335
* response. The method will populate request cookies from the context and update context cookies from the response. The
189336
* method will automatically follow redirects.
190337
*
338+
* <p> JSON objects can be passed directly to the request:
339+
* <pre>{@code
340+
* Map<String, Object> data = new HashMap();
341+
* data.put("title", "Book Title");
342+
* data.put("body", "John Doe");
343+
* request.post("https://example.com/api/createBook", RequestOptions.create().setData(data));
344+
* }</pre>
345+
*
346+
* <p> To send form data to the server use {@code form} option. Its value will be encoded into the request body with
347+
* {@code application/x-www-form-urlencoded} encoding (see below how to use {@code multipart/form-data} form encoding to send files):
348+
* <pre>{@code
349+
* request.post("https://example.com/api/findBook", RequestOptions.create().setForm(
350+
* FormData.create().set("title", "Book Title").set("body", "John Doe")
351+
* ));
352+
* }</pre>
353+
*
354+
* <p> The common way to send file(s) in the body of a request is to upload them as form fields with {@code multipart/form-data}
355+
* encoding. You can achieve that with Playwright API like this:
356+
* <pre>{@code
357+
* // Pass file path to the form data constructor:
358+
* Path file = Paths.get("team.csv");
359+
* APIResponse response = request.post("https://example.com/api/uploadTeamList",
360+
* RequestOptions.create().setMultipart(
361+
* FormData.create().set("fileField", file)));
362+
*
363+
* // Or you can pass the file content directly as FilePayload object:
364+
* FilePayload filePayload = new FilePayload("f.js", "text/javascript",
365+
* "console.log(2022);".getBytes(StandardCharsets.UTF_8));
366+
* APIResponse response = request.post("https://example.com/api/uploadTeamList",
367+
* RequestOptions.create().setMultipart(
368+
* FormData.create().set("fileField", filePayload)));
369+
* }</pre>
370+
*
191371
* @param url Target URL.
192372
* @param params Optional request parameters.
193373
*/

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ class NewContextOptions {
143143
public Proxy proxy;
144144
/**
145145
* Optional setting to control resource content management. If {@code omit} is specified, content is not persisted. If {@code attach}
146-
* is specified, resources are persistet as separate files and all of these files are archived along with the HAR file.
146+
* is specified, resources are persisted as separate files and all of these files are archived along with the HAR file.
147147
* Defaults to {@code embed}, which stores content inline the HAR file as per HAR specification.
148148
*/
149149
public HarContentPolicy recordHarContent;
@@ -381,7 +381,7 @@ public NewContextOptions setProxy(Proxy proxy) {
381381
}
382382
/**
383383
* Optional setting to control resource content management. If {@code omit} is specified, content is not persisted. If {@code attach}
384-
* is specified, resources are persistet as separate files and all of these files are archived along with the HAR file.
384+
* is specified, resources are persisted as separate files and all of these files are archived along with the HAR file.
385385
* Defaults to {@code embed}, which stores content inline the HAR file as per HAR specification.
386386
*/
387387
public NewContextOptions setRecordHarContent(HarContentPolicy recordHarContent) {
@@ -623,7 +623,7 @@ class NewPageOptions {
623623
public Proxy proxy;
624624
/**
625625
* Optional setting to control resource content management. If {@code omit} is specified, content is not persisted. If {@code attach}
626-
* is specified, resources are persistet as separate files and all of these files are archived along with the HAR file.
626+
* is specified, resources are persisted as separate files and all of these files are archived along with the HAR file.
627627
* Defaults to {@code embed}, which stores content inline the HAR file as per HAR specification.
628628
*/
629629
public HarContentPolicy recordHarContent;
@@ -861,7 +861,7 @@ public NewPageOptions setProxy(Proxy proxy) {
861861
}
862862
/**
863863
* Optional setting to control resource content management. If {@code omit} is specified, content is not persisted. If {@code attach}
864-
* is specified, resources are persistet as separate files and all of these files are archived along with the HAR file.
864+
* is specified, resources are persisted as separate files and all of these files are archived along with the HAR file.
865865
* Defaults to {@code embed}, which stores content inline the HAR file as per HAR specification.
866866
*/
867867
public NewPageOptions setRecordHarContent(HarContentPolicy recordHarContent) {

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,7 @@ default List<Cookie> cookies() {
404404
* "</script>\n" +
405405
* "<button onclick=\"onClick()\">Click me</button>\n" +
406406
* "<div></div>");
407-
* page.locator("button").click();
407+
* page.getByRole("button").click();
408408
* }
409409
* }
410410
* }
@@ -463,7 +463,7 @@ default void exposeBinding(String name, BindingCallback callback) {
463463
* "</script>\n" +
464464
* "<button onclick=\"onClick()\">Click me</button>\n" +
465465
* "<div></div>");
466-
* page.locator("button").click();
466+
* page.getByRole("button").click();
467467
* }
468468
* }
469469
* }
@@ -533,7 +533,7 @@ default void exposeBinding(String name, BindingCallback callback) {
533533
* "</script>\n" +
534534
* "<button onclick=\"onClick()\">Click me</button>\n" +
535535
* "<div></div>\n");
536-
* page.locator("button").click();
536+
* page.getByRole("button").click();
537537
* }
538538
* }
539539
* }

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -515,7 +515,7 @@ class LaunchPersistentContextOptions {
515515
public Proxy proxy;
516516
/**
517517
* Optional setting to control resource content management. If {@code omit} is specified, content is not persisted. If {@code attach}
518-
* is specified, resources are persistet as separate files and all of these files are archived along with the HAR file.
518+
* is specified, resources are persisted as separate files and all of these files are archived along with the HAR file.
519519
* Defaults to {@code embed}, which stores content inline the HAR file as per HAR specification.
520520
*/
521521
public HarContentPolicy recordHarContent;
@@ -861,7 +861,7 @@ public LaunchPersistentContextOptions setProxy(Proxy proxy) {
861861
}
862862
/**
863863
* Optional setting to control resource content management. If {@code omit} is specified, content is not persisted. If {@code attach}
864-
* is specified, resources are persistet as separate files and all of these files are archived along with the HAR file.
864+
* is specified, resources are persisted as separate files and all of these files are archived along with the HAR file.
865865
* Defaults to {@code embed}, which stores content inline the HAR file as per HAR specification.
866866
*/
867867
public LaunchPersistentContextOptions setRecordHarContent(HarContentPolicy recordHarContent) {

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

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,8 @@
2727
* <p> Download event is emitted once the download starts. Download path becomes available once download completes:
2828
* <pre>{@code
2929
* // wait for download to start
30-
* Download download = page.waitForDownload(() -> page.locator("a").click());
31-
* // wait for download to complete
32-
* Path path = download.path();
33-
* }</pre>
34-
* <pre>{@code
35-
* // wait for download to start
3630
* Download download = page.waitForDownload(() -> {
37-
* page.locator("a").click();
31+
* page.getByText("Download file").click();
3832
* });
3933
* // wait for download to complete
4034
* Path path = download.path();

0 commit comments

Comments
 (0)