Skip to content

Commit

Permalink
chore: roll driver to 1.38.0-alpha-aug-23
Browse files Browse the repository at this point in the history
Reference microsoft#1353
  • Loading branch information
yury-s committed Aug 23, 2023
1 parent 7d5953c commit cbf2c4b
Show file tree
Hide file tree
Showing 22 changed files with 368 additions and 142 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,16 @@ public interface BrowserContext extends AutoCloseable {
*/
void offPage(Consumer<Page> handler);

/**
* Emitted when unhandled exceptions occur on any pages created through this context. To only listen for {@code pageError}
* events from a particular page, use {@link Page#onPageError Page.onPageError()}.
*/
void onPageError(Consumer<PageError> handler);
/**
* Removes handler that was previously added with {@link #onPageError onPageError(handler)}.
*/
void offPageError(Consumer<PageError> handler);

/**
* Emitted when a request is issued from any pages created through this context. The [request] object is read-only. To only
* listen for requests from a particular page, use {@link Page#onRequest Page.onRequest()}.
Expand Down
17 changes: 12 additions & 5 deletions playwright/src/main/java/com/microsoft/playwright/Download.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,16 @@
*
* <p> All the downloaded files belonging to the browser context are deleted when the browser context is closed.
*
* <p> Download event is emitted once the download starts. Download path becomes available once download completes:
* <p> Download event is emitted once the download starts. Download path becomes available once download completes.
* <pre>{@code
* // wait for download to start
* // Wait for the download to start
* Download download = page.waitForDownload(() -> {
* page.getByText("Download file").click();
* // Perform the action that initiates download
* page.getByText("Download file").click();
* });
* // wait for download to complete
* Path path = download.path();
*
* // Wait for the download process to complete and save the downloaded file somewhere
* download.saveAs(Paths.get("/path/to/save/at/", download.suggestedFilename()));
* }</pre>
*/
public interface Download {
Expand Down Expand Up @@ -80,6 +82,11 @@ public interface Download {
* Copy the download to a user-specified path. It is safe to call this method while the download is still in progress. Will
* wait for the download to finish if necessary.
*
* <p> **Usage**
* <pre>{@code
* download.saveAs(Paths.get("/path/to/save/at/", download.suggestedFilename()));
* }</pre>
*
* @param path Path where the download should be copied.
* @since v1.8
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1582,7 +1582,7 @@ default Object evalOnSelectorAll(String selector, String expression) {
* href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control">control</a>, the control will be filled
* instead.
*
* <p> To send fine-grained keyboard events, use {@link ElementHandle#type ElementHandle.type()}.
* <p> To send fine-grained keyboard events, use {@link Keyboard#type Keyboard.type()}.
*
* @param value Value to set for the {@code <input>}, {@code <textarea>} or {@code [contenteditable]} element.
* @since v1.8
Expand All @@ -1600,7 +1600,7 @@ default void fill(String value) {
* href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control">control</a>, the control will be filled
* instead.
*
* <p> To send fine-grained keyboard events, use {@link ElementHandle#type ElementHandle.type()}.
* <p> To send fine-grained keyboard events, use {@link Keyboard#type Keyboard.type()}.
*
* @param value Value to set for the {@code <input>}, {@code <textarea>} or {@code [contenteditable]} element.
* @since v1.8
Expand Down Expand Up @@ -2450,24 +2450,8 @@ default void tap() {
*/
String textContent();
/**
* Focuses the element, and then sends a {@code keydown}, {@code keypress}/{@code input}, and {@code keyup} event for each
* character in the text.
*
* <p> To press a special key, like {@code Control} or {@code ArrowDown}, use {@link ElementHandle#press
* ElementHandle.press()}.
*
* <p> **Usage**
* <pre>{@code
* elementHandle.type("Hello"); // Types instantly
* elementHandle.type("World", new ElementHandle.TypeOptions().setDelay(100)); // Types slower, like a user
* }</pre>
*
* <p> An example of typing into a text field and then submitting the form:
* <pre>{@code
* ElementHandle elementHandle = page.querySelector("input");
* elementHandle.type("some text");
* elementHandle.press("Enter");
* }</pre>
* @deprecated Use locator-based {@link Locator#pressSequentially Locator.pressSequentially()} instead. Read more about <a
* href="https://playwright.dev/java/docs/locators">locators</a>.
*
* @param text A text to type into a focused element.
* @since v1.8
Expand All @@ -2476,24 +2460,8 @@ default void type(String text) {
type(text, null);
}
/**
* Focuses the element, and then sends a {@code keydown}, {@code keypress}/{@code input}, and {@code keyup} event for each
* character in the text.
*
* <p> To press a special key, like {@code Control} or {@code ArrowDown}, use {@link ElementHandle#press
* ElementHandle.press()}.
*
* <p> **Usage**
* <pre>{@code
* elementHandle.type("Hello"); // Types instantly
* elementHandle.type("World", new ElementHandle.TypeOptions().setDelay(100)); // Types slower, like a user
* }</pre>
*
* <p> An example of typing into a text field and then submitting the form:
* <pre>{@code
* ElementHandle elementHandle = page.querySelector("input");
* elementHandle.type("some text");
* elementHandle.press("Enter");
* }</pre>
* @deprecated Use locator-based {@link Locator#pressSequentially Locator.pressSequentially()} instead. Read more about <a
* href="https://playwright.dev/java/docs/locators">locators</a>.
*
* @param text A text to type into a focused element.
* @since v1.8
Expand Down
30 changes: 4 additions & 26 deletions playwright/src/main/java/com/microsoft/playwright/Frame.java
Original file line number Diff line number Diff line change
Expand Up @@ -4677,19 +4677,8 @@ default String textContent(String selector) {
*/
String title();
/**
* Sends a {@code keydown}, {@code keypress}/{@code input}, and {@code keyup} event for each character in the text. {@code
* frame.type} can be used to send fine-grained keyboard events. To fill values in form fields, use {@link Frame#fill
* Frame.fill()}.
*
* <p> To press a special key, like {@code Control} or {@code ArrowDown}, use {@link Keyboard#press Keyboard.press()}.
*
* <p> **Usage**
* <pre>{@code
* // Types instantly
* frame.type("#mytextarea", "Hello");
* // Types slower, like a user
* frame.type("#mytextarea", "World", new Frame.TypeOptions().setDelay(100));
* }</pre>
* @deprecated Use locator-based {@link Locator#pressSequentially Locator.pressSequentially()} instead. Read more about <a
* href="https://playwright.dev/java/docs/locators">locators</a>.
*
* @param selector A selector to search for an element. If there are multiple elements satisfying the selector, the first will be used.
* @param text A text to type into a focused element.
Expand All @@ -4699,19 +4688,8 @@ default void type(String selector, String text) {
type(selector, text, null);
}
/**
* Sends a {@code keydown}, {@code keypress}/{@code input}, and {@code keyup} event for each character in the text. {@code
* frame.type} can be used to send fine-grained keyboard events. To fill values in form fields, use {@link Frame#fill
* Frame.fill()}.
*
* <p> To press a special key, like {@code Control} or {@code ArrowDown}, use {@link Keyboard#press Keyboard.press()}.
*
* <p> **Usage**
* <pre>{@code
* // Types instantly
* frame.type("#mytextarea", "Hello");
* // Types slower, like a user
* frame.type("#mytextarea", "World", new Frame.TypeOptions().setDelay(100));
* }</pre>
* @deprecated Use locator-based {@link Locator#pressSequentially Locator.pressSequentially()} instead. Read more about <a
* href="https://playwright.dev/java/docs/locators">locators</a>.
*
* @param selector A selector to search for an element. If there are multiple elements satisfying the selector, the first will be used.
* @param text A text to type into a focused element.
Expand Down
148 changes: 106 additions & 42 deletions playwright/src/main/java/com/microsoft/playwright/Locator.java
Original file line number Diff line number Diff line change
Expand Up @@ -1388,6 +1388,50 @@ public PressOptions setTimeout(double timeout) {
return this;
}
}
class PressSequentiallyOptions {
/**
* Time to wait between key presses in milliseconds. Defaults to 0.
*/
public Double delay;
/**
* Actions that initiate navigations are waiting for these navigations to happen and for pages to start loading. You can
* opt out of waiting via setting this flag. You would only need this option in the exceptional cases such as navigating to
* inaccessible pages. Defaults to {@code false}.
*/
public Boolean noWaitAfter;
/**
* Maximum time in milliseconds. Defaults to {@code 30000} (30 seconds). Pass {@code 0} to disable timeout. The default
* value can be changed by using the {@link BrowserContext#setDefaultTimeout BrowserContext.setDefaultTimeout()} or {@link
* Page#setDefaultTimeout Page.setDefaultTimeout()} methods.
*/
public Double timeout;

/**
* Time to wait between key presses in milliseconds. Defaults to 0.
*/
public PressSequentiallyOptions setDelay(double delay) {
this.delay = delay;
return this;
}
/**
* Actions that initiate navigations are waiting for these navigations to happen and for pages to start loading. You can
* opt out of waiting via setting this flag. You would only need this option in the exceptional cases such as navigating to
* inaccessible pages. Defaults to {@code false}.
*/
public PressSequentiallyOptions setNoWaitAfter(boolean noWaitAfter) {
this.noWaitAfter = noWaitAfter;
return this;
}
/**
* Maximum time in milliseconds. Defaults to {@code 30000} (30 seconds). Pass {@code 0} to disable timeout. The default
* value can be changed by using the {@link BrowserContext#setDefaultTimeout BrowserContext.setDefaultTimeout()} or {@link
* Page#setDefaultTimeout Page.setDefaultTimeout()} methods.
*/
public PressSequentiallyOptions setTimeout(double timeout) {
this.timeout = timeout;
return this;
}
}
class ScreenshotOptions {
/**
* When set to {@code "disabled"}, stops CSS animations, CSS transitions and Web Animations. Animations get different
Expand Down Expand Up @@ -2832,7 +2876,7 @@ default JSHandle evaluateHandle(String expression) {
* href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control">control</a>, the control will be filled
* instead.
*
* <p> To send fine-grained keyboard events, use {@link Locator#type Locator.type()}.
* <p> To send fine-grained keyboard events, use {@link Locator#pressSequentially Locator.pressSequentially()}.
*
* @param value Value to set for the {@code <input>}, {@code <textarea>} or {@code [contenteditable]} element.
* @since v1.14
Expand All @@ -2859,7 +2903,7 @@ default void fill(String value) {
* href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control">control</a>, the control will be filled
* instead.
*
* <p> To send fine-grained keyboard events, use {@link Locator#type Locator.type()}.
* <p> To send fine-grained keyboard events, use {@link Locator#pressSequentially Locator.pressSequentially()}.
*
* @param value Value to set for the {@code <input>}, {@code <textarea>} or {@code [contenteditable]} element.
* @since v1.14
Expand Down Expand Up @@ -3956,6 +4000,60 @@ default void press(String key) {
* @since v1.14
*/
void press(String key, PressOptions options);
/**
* <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
* there is special keyboard handling on the page.
*
* <p> Focuses the element, and then sends a {@code keydown}, {@code keypress}/{@code input}, and {@code keyup} event for each
* character in the text.
*
* <p> To press a special key, like {@code Control} or {@code ArrowDown}, use {@link Locator#press Locator.press()}.
*
* <p> **Usage**
* <pre>{@code
* locator.pressSequentially("Hello"); // Types instantly
* locator.pressSequentially("World", new Locator.pressSequentiallyOptions().setDelay(100)); // Types slower, like a user
* }</pre>
*
* <p> An example of typing into a text field and then submitting the form:
* <pre>{@code
* Locator locator = page.getByLabel("Password");
* locator.pressSequentially("my password");
* locator.press("Enter");
* }</pre>
*
* @param text String of characters to sequentially press into a focused element.
* @since v1.38
*/
default void pressSequentially(String text) {
pressSequentially(text, null);
}
/**
* <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
* there is special keyboard handling on the page.
*
* <p> Focuses the element, and then sends a {@code keydown}, {@code keypress}/{@code input}, and {@code keyup} event for each
* character in the text.
*
* <p> To press a special key, like {@code Control} or {@code ArrowDown}, use {@link Locator#press Locator.press()}.
*
* <p> **Usage**
* <pre>{@code
* locator.pressSequentially("Hello"); // Types instantly
* locator.pressSequentially("World", new Locator.pressSequentiallyOptions().setDelay(100)); // Types slower, like a user
* }</pre>
*
* <p> An example of typing into a text field and then submitting the form:
* <pre>{@code
* Locator locator = page.getByLabel("Password");
* locator.pressSequentially("my password");
* locator.press("Enter");
* }</pre>
*
* @param text String of characters to sequentially press into a focused element.
* @since v1.38
*/
void pressSequentially(String text, PressSequentiallyOptions options);
/**
* Take a screenshot of the element matching the locator.
*
Expand Down Expand Up @@ -4865,26 +4963,9 @@ default String textContent() {
*/
String textContent(TextContentOptions options);
/**
* <strong>NOTE:</strong> In most cases, you should use {@link Locator#fill Locator.fill()} instead. You only need to type characters if there is
* special keyboard handling on the page.
*
* <p> Focuses the element, and then sends a {@code keydown}, {@code keypress}/{@code input}, and {@code keyup} event for each
* character in the text.
*
* <p> To press a special key, like {@code Control} or {@code ArrowDown}, use {@link Locator#press Locator.press()}.
*
* <p> **Usage**
* <pre>{@code
* element.type("Hello"); // Types instantly
* element.type("World", new Locator.TypeOptions().setDelay(100)); // Types slower, like a user
* }</pre>
*
* <p> An example of typing into a text field and then submitting the form:
* <pre>{@code
* Locator element = page.getByLabel("Password");
* element.type("my password");
* element.press("Enter");
* }</pre>
* @deprecated In most cases, you should use {@link Locator#fill Locator.fill()} instead. You only need to press keys one by one if
* there is special keyboard handling on the page - in this case use {@link Locator#pressSequentially
* Locator.pressSequentially()}.
*
* @param text A text to type into a focused element.
* @since v1.14
Expand All @@ -4893,26 +4974,9 @@ default void type(String text) {
type(text, null);
}
/**
* <strong>NOTE:</strong> In most cases, you should use {@link Locator#fill Locator.fill()} instead. You only need to type characters if there is
* special keyboard handling on the page.
*
* <p> Focuses the element, and then sends a {@code keydown}, {@code keypress}/{@code input}, and {@code keyup} event for each
* character in the text.
*
* <p> To press a special key, like {@code Control} or {@code ArrowDown}, use {@link Locator#press Locator.press()}.
*
* <p> **Usage**
* <pre>{@code
* element.type("Hello"); // Types instantly
* element.type("World", new Locator.TypeOptions().setDelay(100)); // Types slower, like a user
* }</pre>
*
* <p> An example of typing into a text field and then submitting the form:
* <pre>{@code
* Locator element = page.getByLabel("Password");
* element.type("my password");
* element.press("Enter");
* }</pre>
* @deprecated In most cases, you should use {@link Locator#fill Locator.fill()} instead. You only need to press keys one by one if
* there is special keyboard handling on the page - in this case use {@link Locator#pressSequentially
* Locator.pressSequentially()}.
*
* @param text A text to type into a focused element.
* @since v1.14
Expand Down
Loading

0 comments on commit cbf2c4b

Please sign in to comment.