From cbf2c4b80557ab2c9f3077afa80e5da65cad9cad Mon Sep 17 00:00:00 2001 From: Yury Semikhatsky Date: Wed, 23 Aug 2023 13:34:28 -0700 Subject: [PATCH] chore: roll driver to 1.38.0-alpha-aug-23 Reference https://github.com/microsoft/playwright-java/issues/1353 --- .../microsoft/playwright/BrowserContext.java | 10 ++ .../com/microsoft/playwright/Download.java | 17 +- .../microsoft/playwright/ElementHandle.java | 44 +----- .../java/com/microsoft/playwright/Frame.java | 30 +--- .../com/microsoft/playwright/Locator.java | 148 +++++++++++++----- .../java/com/microsoft/playwright/Page.java | 30 +--- .../com/microsoft/playwright/PageError.java | 47 ++++++ .../com/microsoft/playwright/Request.java | 19 +++ .../playwright/impl/BrowserContextImpl.java | 23 +++ .../playwright/impl/LocatorImpl.java | 5 + .../playwright/impl/PageErrorImpl.java | 23 +++ .../microsoft/playwright/impl/PageImpl.java | 1 + .../playwright/impl/RequestImpl.java | 8 +- .../microsoft/playwright/impl/RouteImpl.java | 4 +- .../com/microsoft/playwright/TestBase.java | 14 ++ .../playwright/TestBrowserContextEvents.java | 14 ++ .../microsoft/playwright/TestLocatorMisc.java | 7 + .../playwright/TestPageEventPopup.java | 17 ++ .../playwright/TestPageNetworkRequest.java | 22 +++ .../playwright/TestPageRequestIntercept.java | 18 +++ scripts/CLI_VERSION | 2 +- .../playwright/tools/ApiGenerator.java | 7 +- 22 files changed, 368 insertions(+), 142 deletions(-) create mode 100644 playwright/src/main/java/com/microsoft/playwright/PageError.java create mode 100644 playwright/src/main/java/com/microsoft/playwright/impl/PageErrorImpl.java create mode 100644 playwright/src/test/java/com/microsoft/playwright/TestPageEventPopup.java create mode 100644 playwright/src/test/java/com/microsoft/playwright/TestPageRequestIntercept.java diff --git a/playwright/src/main/java/com/microsoft/playwright/BrowserContext.java b/playwright/src/main/java/com/microsoft/playwright/BrowserContext.java index 35338811e..6eb2f8daf 100644 --- a/playwright/src/main/java/com/microsoft/playwright/BrowserContext.java +++ b/playwright/src/main/java/com/microsoft/playwright/BrowserContext.java @@ -127,6 +127,16 @@ public interface BrowserContext extends AutoCloseable { */ void offPage(Consumer 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 handler); + /** + * Removes handler that was previously added with {@link #onPageError onPageError(handler)}. + */ + void offPageError(Consumer 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()}. diff --git a/playwright/src/main/java/com/microsoft/playwright/Download.java b/playwright/src/main/java/com/microsoft/playwright/Download.java index ca8cbc6f7..b51051150 100644 --- a/playwright/src/main/java/com/microsoft/playwright/Download.java +++ b/playwright/src/main/java/com/microsoft/playwright/Download.java @@ -24,14 +24,16 @@ * *

All the downloaded files belonging to the browser context are deleted when the browser context is closed. * - *

Download event is emitted once the download starts. Download path becomes available once download completes: + *

Download event is emitted once the download starts. Download path becomes available once download completes. *

{@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()));
  * }
*/ public interface Download { @@ -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. * + *

**Usage** + *

{@code
+   * download.saveAs(Paths.get("/path/to/save/at/", download.suggestedFilename()));
+   * }
+ * * @param path Path where the download should be copied. * @since v1.8 */ diff --git a/playwright/src/main/java/com/microsoft/playwright/ElementHandle.java b/playwright/src/main/java/com/microsoft/playwright/ElementHandle.java index 29d9477c3..eb6828b74 100644 --- a/playwright/src/main/java/com/microsoft/playwright/ElementHandle.java +++ b/playwright/src/main/java/com/microsoft/playwright/ElementHandle.java @@ -1582,7 +1582,7 @@ default Object evalOnSelectorAll(String selector, String expression) { * href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control">control, the control will be filled * instead. * - *

To send fine-grained keyboard events, use {@link ElementHandle#type ElementHandle.type()}. + *

To send fine-grained keyboard events, use {@link Keyboard#type Keyboard.type()}. * * @param value Value to set for the {@code }, {@code