Skip to content

Commit fa75e29

Browse files
authored
chore: roll driver to 1.38.0-alpha-aug-23 (#1362)
Reference #1353
1 parent 7d5953c commit fa75e29

25 files changed

+390
-157
lines changed

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,16 @@ public interface BrowserContext extends AutoCloseable {
127127
*/
128128
void offPage(Consumer<Page> handler);
129129

130+
/**
131+
* Emitted when unhandled exceptions occur on any pages created through this context. To only listen for {@code pageError}
132+
* events from a particular page, use {@link Page#onPageError Page.onPageError()}.
133+
*/
134+
void onPageError(Consumer<PageError> handler);
135+
/**
136+
* Removes handler that was previously added with {@link #onPageError onPageError(handler)}.
137+
*/
138+
void offPageError(Consumer<PageError> handler);
139+
130140
/**
131141
* Emitted when a request is issued from any pages created through this context. The [request] object is read-only. To only
132142
* listen for requests from a particular page, use {@link Page#onRequest Page.onRequest()}.

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

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,16 @@
2424
*
2525
* <p> All the downloaded files belonging to the browser context are deleted when the browser context is closed.
2626
*
27-
* <p> Download event is emitted once the download starts. Download path becomes available once download completes:
27+
* <p> Download event is emitted once the download starts. Download path becomes available once download completes.
2828
* <pre>{@code
29-
* // wait for download to start
29+
* // Wait for the download to start
3030
* Download download = page.waitForDownload(() -> {
31-
* page.getByText("Download file").click();
31+
* // Perform the action that initiates download
32+
* page.getByText("Download file").click();
3233
* });
33-
* // wait for download to complete
34-
* Path path = download.path();
34+
*
35+
* // Wait for the download process to complete and save the downloaded file somewhere
36+
* download.saveAs(Paths.get("/path/to/save/at/", download.suggestedFilename()));
3537
* }</pre>
3638
*/
3739
public interface Download {
@@ -80,6 +82,11 @@ public interface Download {
8082
* Copy the download to a user-specified path. It is safe to call this method while the download is still in progress. Will
8183
* wait for the download to finish if necessary.
8284
*
85+
* <p> **Usage**
86+
* <pre>{@code
87+
* download.saveAs(Paths.get("/path/to/save/at/", download.suggestedFilename()));
88+
* }</pre>
89+
*
8390
* @param path Path where the download should be copied.
8491
* @since v1.8
8592
*/

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

Lines changed: 6 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1582,7 +1582,7 @@ default Object evalOnSelectorAll(String selector, String expression) {
15821582
* href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control">control</a>, the control will be filled
15831583
* instead.
15841584
*
1585-
* <p> To send fine-grained keyboard events, use {@link ElementHandle#type ElementHandle.type()}.
1585+
* <p> To send fine-grained keyboard events, use {@link Keyboard#type Keyboard.type()}.
15861586
*
15871587
* @param value Value to set for the {@code <input>}, {@code <textarea>} or {@code [contenteditable]} element.
15881588
* @since v1.8
@@ -1600,7 +1600,7 @@ default void fill(String value) {
16001600
* href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control">control</a>, the control will be filled
16011601
* instead.
16021602
*
1603-
* <p> To send fine-grained keyboard events, use {@link ElementHandle#type ElementHandle.type()}.
1603+
* <p> To send fine-grained keyboard events, use {@link Keyboard#type Keyboard.type()}.
16041604
*
16051605
* @param value Value to set for the {@code <input>}, {@code <textarea>} or {@code [contenteditable]} element.
16061606
* @since v1.8
@@ -2450,24 +2450,8 @@ default void tap() {
24502450
*/
24512451
String textContent();
24522452
/**
2453-
* Focuses the element, and then sends a {@code keydown}, {@code keypress}/{@code input}, and {@code keyup} event for each
2454-
* character in the text.
2455-
*
2456-
* <p> To press a special key, like {@code Control} or {@code ArrowDown}, use {@link ElementHandle#press
2457-
* ElementHandle.press()}.
2458-
*
2459-
* <p> **Usage**
2460-
* <pre>{@code
2461-
* elementHandle.type("Hello"); // Types instantly
2462-
* elementHandle.type("World", new ElementHandle.TypeOptions().setDelay(100)); // Types slower, like a user
2463-
* }</pre>
2464-
*
2465-
* <p> An example of typing into a text field and then submitting the form:
2466-
* <pre>{@code
2467-
* ElementHandle elementHandle = page.querySelector("input");
2468-
* elementHandle.type("some text");
2469-
* elementHandle.press("Enter");
2470-
* }</pre>
2453+
* @deprecated Use locator-based {@link Locator#pressSequentially Locator.pressSequentially()} instead. Read more about <a
2454+
* href="https://playwright.dev/java/docs/locators">locators</a>.
24712455
*
24722456
* @param text A text to type into a focused element.
24732457
* @since v1.8
@@ -2476,24 +2460,8 @@ default void type(String text) {
24762460
type(text, null);
24772461
}
24782462
/**
2479-
* Focuses the element, and then sends a {@code keydown}, {@code keypress}/{@code input}, and {@code keyup} event for each
2480-
* character in the text.
2481-
*
2482-
* <p> To press a special key, like {@code Control} or {@code ArrowDown}, use {@link ElementHandle#press
2483-
* ElementHandle.press()}.
2484-
*
2485-
* <p> **Usage**
2486-
* <pre>{@code
2487-
* elementHandle.type("Hello"); // Types instantly
2488-
* elementHandle.type("World", new ElementHandle.TypeOptions().setDelay(100)); // Types slower, like a user
2489-
* }</pre>
2490-
*
2491-
* <p> An example of typing into a text field and then submitting the form:
2492-
* <pre>{@code
2493-
* ElementHandle elementHandle = page.querySelector("input");
2494-
* elementHandle.type("some text");
2495-
* elementHandle.press("Enter");
2496-
* }</pre>
2463+
* @deprecated Use locator-based {@link Locator#pressSequentially Locator.pressSequentially()} instead. Read more about <a
2464+
* href="https://playwright.dev/java/docs/locators">locators</a>.
24972465
*
24982466
* @param text A text to type into a focused element.
24992467
* @since v1.8

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

Lines changed: 4 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -4677,19 +4677,8 @@ default String textContent(String selector) {
46774677
*/
46784678
String title();
46794679
/**
4680-
* Sends a {@code keydown}, {@code keypress}/{@code input}, and {@code keyup} event for each character in the text. {@code
4681-
* frame.type} can be used to send fine-grained keyboard events. To fill values in form fields, use {@link Frame#fill
4682-
* Frame.fill()}.
4683-
*
4684-
* <p> To press a special key, like {@code Control} or {@code ArrowDown}, use {@link Keyboard#press Keyboard.press()}.
4685-
*
4686-
* <p> **Usage**
4687-
* <pre>{@code
4688-
* // Types instantly
4689-
* frame.type("#mytextarea", "Hello");
4690-
* // Types slower, like a user
4691-
* frame.type("#mytextarea", "World", new Frame.TypeOptions().setDelay(100));
4692-
* }</pre>
4680+
* @deprecated Use locator-based {@link Locator#pressSequentially Locator.pressSequentially()} instead. Read more about <a
4681+
* href="https://playwright.dev/java/docs/locators">locators</a>.
46934682
*
46944683
* @param selector A selector to search for an element. If there are multiple elements satisfying the selector, the first will be used.
46954684
* @param text A text to type into a focused element.
@@ -4699,19 +4688,8 @@ default void type(String selector, String text) {
46994688
type(selector, text, null);
47004689
}
47014690
/**
4702-
* Sends a {@code keydown}, {@code keypress}/{@code input}, and {@code keyup} event for each character in the text. {@code
4703-
* frame.type} can be used to send fine-grained keyboard events. To fill values in form fields, use {@link Frame#fill
4704-
* Frame.fill()}.
4705-
*
4706-
* <p> To press a special key, like {@code Control} or {@code ArrowDown}, use {@link Keyboard#press Keyboard.press()}.
4707-
*
4708-
* <p> **Usage**
4709-
* <pre>{@code
4710-
* // Types instantly
4711-
* frame.type("#mytextarea", "Hello");
4712-
* // Types slower, like a user
4713-
* frame.type("#mytextarea", "World", new Frame.TypeOptions().setDelay(100));
4714-
* }</pre>
4691+
* @deprecated Use locator-based {@link Locator#pressSequentially Locator.pressSequentially()} instead. Read more about <a
4692+
* href="https://playwright.dev/java/docs/locators">locators</a>.
47154693
*
47164694
* @param selector A selector to search for an element. If there are multiple elements satisfying the selector, the first will be used.
47174695
* @param text A text to type into a focused element.

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

Lines changed: 106 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1388,6 +1388,50 @@ public PressOptions setTimeout(double timeout) {
13881388
return this;
13891389
}
13901390
}
1391+
class PressSequentiallyOptions {
1392+
/**
1393+
* Time to wait between key presses in milliseconds. Defaults to 0.
1394+
*/
1395+
public Double delay;
1396+
/**
1397+
* Actions that initiate navigations are waiting for these navigations to happen and for pages to start loading. You can
1398+
* opt out of waiting via setting this flag. You would only need this option in the exceptional cases such as navigating to
1399+
* inaccessible pages. Defaults to {@code false}.
1400+
*/
1401+
public Boolean noWaitAfter;
1402+
/**
1403+
* Maximum time in milliseconds. Defaults to {@code 30000} (30 seconds). Pass {@code 0} to disable timeout. The default
1404+
* value can be changed by using the {@link BrowserContext#setDefaultTimeout BrowserContext.setDefaultTimeout()} or {@link
1405+
* Page#setDefaultTimeout Page.setDefaultTimeout()} methods.
1406+
*/
1407+
public Double timeout;
1408+
1409+
/**
1410+
* Time to wait between key presses in milliseconds. Defaults to 0.
1411+
*/
1412+
public PressSequentiallyOptions setDelay(double delay) {
1413+
this.delay = delay;
1414+
return this;
1415+
}
1416+
/**
1417+
* Actions that initiate navigations are waiting for these navigations to happen and for pages to start loading. You can
1418+
* opt out of waiting via setting this flag. You would only need this option in the exceptional cases such as navigating to
1419+
* inaccessible pages. Defaults to {@code false}.
1420+
*/
1421+
public PressSequentiallyOptions setNoWaitAfter(boolean noWaitAfter) {
1422+
this.noWaitAfter = noWaitAfter;
1423+
return this;
1424+
}
1425+
/**
1426+
* Maximum time in milliseconds. Defaults to {@code 30000} (30 seconds). Pass {@code 0} to disable timeout. The default
1427+
* value can be changed by using the {@link BrowserContext#setDefaultTimeout BrowserContext.setDefaultTimeout()} or {@link
1428+
* Page#setDefaultTimeout Page.setDefaultTimeout()} methods.
1429+
*/
1430+
public PressSequentiallyOptions setTimeout(double timeout) {
1431+
this.timeout = timeout;
1432+
return this;
1433+
}
1434+
}
13911435
class ScreenshotOptions {
13921436
/**
13931437
* When set to {@code "disabled"}, stops CSS animations, CSS transitions and Web Animations. Animations get different
@@ -2832,7 +2876,7 @@ default JSHandle evaluateHandle(String expression) {
28322876
* href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control">control</a>, the control will be filled
28332877
* instead.
28342878
*
2835-
* <p> To send fine-grained keyboard events, use {@link Locator#type Locator.type()}.
2879+
* <p> To send fine-grained keyboard events, use {@link Locator#pressSequentially Locator.pressSequentially()}.
28362880
*
28372881
* @param value Value to set for the {@code <input>}, {@code <textarea>} or {@code [contenteditable]} element.
28382882
* @since v1.14
@@ -2859,7 +2903,7 @@ default void fill(String value) {
28592903
* href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control">control</a>, the control will be filled
28602904
* instead.
28612905
*
2862-
* <p> To send fine-grained keyboard events, use {@link Locator#type Locator.type()}.
2906+
* <p> To send fine-grained keyboard events, use {@link Locator#pressSequentially Locator.pressSequentially()}.
28632907
*
28642908
* @param value Value to set for the {@code <input>}, {@code <textarea>} or {@code [contenteditable]} element.
28652909
* @since v1.14
@@ -3956,6 +4000,60 @@ default void press(String key) {
39564000
* @since v1.14
39574001
*/
39584002
void press(String key, PressOptions options);
4003+
/**
4004+
* <strong>NOTE:</strong> In most cases, you should use {@link Locator#fill Locator.fill()} instead. You only need to press keys one by one if
4005+
* there is special keyboard handling on the page.
4006+
*
4007+
* <p> Focuses the element, and then sends a {@code keydown}, {@code keypress}/{@code input}, and {@code keyup} event for each
4008+
* character in the text.
4009+
*
4010+
* <p> To press a special key, like {@code Control} or {@code ArrowDown}, use {@link Locator#press Locator.press()}.
4011+
*
4012+
* <p> **Usage**
4013+
* <pre>{@code
4014+
* locator.pressSequentially("Hello"); // Types instantly
4015+
* locator.pressSequentially("World", new Locator.pressSequentiallyOptions().setDelay(100)); // Types slower, like a user
4016+
* }</pre>
4017+
*
4018+
* <p> An example of typing into a text field and then submitting the form:
4019+
* <pre>{@code
4020+
* Locator locator = page.getByLabel("Password");
4021+
* locator.pressSequentially("my password");
4022+
* locator.press("Enter");
4023+
* }</pre>
4024+
*
4025+
* @param text String of characters to sequentially press into a focused element.
4026+
* @since v1.38
4027+
*/
4028+
default void pressSequentially(String text) {
4029+
pressSequentially(text, null);
4030+
}
4031+
/**
4032+
* <strong>NOTE:</strong> In most cases, you should use {@link Locator#fill Locator.fill()} instead. You only need to press keys one by one if
4033+
* there is special keyboard handling on the page.
4034+
*
4035+
* <p> Focuses the element, and then sends a {@code keydown}, {@code keypress}/{@code input}, and {@code keyup} event for each
4036+
* character in the text.
4037+
*
4038+
* <p> To press a special key, like {@code Control} or {@code ArrowDown}, use {@link Locator#press Locator.press()}.
4039+
*
4040+
* <p> **Usage**
4041+
* <pre>{@code
4042+
* locator.pressSequentially("Hello"); // Types instantly
4043+
* locator.pressSequentially("World", new Locator.pressSequentiallyOptions().setDelay(100)); // Types slower, like a user
4044+
* }</pre>
4045+
*
4046+
* <p> An example of typing into a text field and then submitting the form:
4047+
* <pre>{@code
4048+
* Locator locator = page.getByLabel("Password");
4049+
* locator.pressSequentially("my password");
4050+
* locator.press("Enter");
4051+
* }</pre>
4052+
*
4053+
* @param text String of characters to sequentially press into a focused element.
4054+
* @since v1.38
4055+
*/
4056+
void pressSequentially(String text, PressSequentiallyOptions options);
39594057
/**
39604058
* Take a screenshot of the element matching the locator.
39614059
*
@@ -4865,26 +4963,9 @@ default String textContent() {
48654963
*/
48664964
String textContent(TextContentOptions options);
48674965
/**
4868-
* <strong>NOTE:</strong> In most cases, you should use {@link Locator#fill Locator.fill()} instead. You only need to type characters if there is
4869-
* special keyboard handling on the page.
4870-
*
4871-
* <p> Focuses the element, and then sends a {@code keydown}, {@code keypress}/{@code input}, and {@code keyup} event for each
4872-
* character in the text.
4873-
*
4874-
* <p> To press a special key, like {@code Control} or {@code ArrowDown}, use {@link Locator#press Locator.press()}.
4875-
*
4876-
* <p> **Usage**
4877-
* <pre>{@code
4878-
* element.type("Hello"); // Types instantly
4879-
* element.type("World", new Locator.TypeOptions().setDelay(100)); // Types slower, like a user
4880-
* }</pre>
4881-
*
4882-
* <p> An example of typing into a text field and then submitting the form:
4883-
* <pre>{@code
4884-
* Locator element = page.getByLabel("Password");
4885-
* element.type("my password");
4886-
* element.press("Enter");
4887-
* }</pre>
4966+
* @deprecated In most cases, you should use {@link Locator#fill Locator.fill()} instead. You only need to press keys one by one if
4967+
* there is special keyboard handling on the page - in this case use {@link Locator#pressSequentially
4968+
* Locator.pressSequentially()}.
48884969
*
48894970
* @param text A text to type into a focused element.
48904971
* @since v1.14
@@ -4893,26 +4974,9 @@ default void type(String text) {
48934974
type(text, null);
48944975
}
48954976
/**
4896-
* <strong>NOTE:</strong> In most cases, you should use {@link Locator#fill Locator.fill()} instead. You only need to type characters if there is
4897-
* special keyboard handling on the page.
4898-
*
4899-
* <p> Focuses the element, and then sends a {@code keydown}, {@code keypress}/{@code input}, and {@code keyup} event for each
4900-
* character in the text.
4901-
*
4902-
* <p> To press a special key, like {@code Control} or {@code ArrowDown}, use {@link Locator#press Locator.press()}.
4903-
*
4904-
* <p> **Usage**
4905-
* <pre>{@code
4906-
* element.type("Hello"); // Types instantly
4907-
* element.type("World", new Locator.TypeOptions().setDelay(100)); // Types slower, like a user
4908-
* }</pre>
4909-
*
4910-
* <p> An example of typing into a text field and then submitting the form:
4911-
* <pre>{@code
4912-
* Locator element = page.getByLabel("Password");
4913-
* element.type("my password");
4914-
* element.press("Enter");
4915-
* }</pre>
4977+
* @deprecated In most cases, you should use {@link Locator#fill Locator.fill()} instead. You only need to press keys one by one if
4978+
* there is special keyboard handling on the page - in this case use {@link Locator#pressSequentially
4979+
* Locator.pressSequentially()}.
49164980
*
49174981
* @param text A text to type into a focused element.
49184982
* @since v1.14

0 commit comments

Comments
 (0)