diff --git a/README.md b/README.md index 60b65951..11eb90c7 100644 --- a/README.md +++ b/README.md @@ -11,9 +11,9 @@ Playwright is a Java library to automate [Chromium](https://www.chromium.org/Hom | | Linux | macOS | Windows | | :--- | :---: | :---: | :---: | -| Chromium 125.0.6422.26 | :white_check_mark: | :white_check_mark: | :white_check_mark: | +| Chromium 127.0.6533.5 | :white_check_mark: | :white_check_mark: | :white_check_mark: | | WebKit 17.4 | ✅ | ✅ | ✅ | -| Firefox 125.0.1 | :white_check_mark: | :white_check_mark: | :white_check_mark: | +| Firefox 127.0 | :white_check_mark: | :white_check_mark: | :white_check_mark: | 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. diff --git a/playwright/src/main/java/com/microsoft/playwright/APIRequestContext.java b/playwright/src/main/java/com/microsoft/playwright/APIRequestContext.java index b617be8a..b8774c0a 100644 --- a/playwright/src/main/java/com/microsoft/playwright/APIRequestContext.java +++ b/playwright/src/main/java/com/microsoft/playwright/APIRequestContext.java @@ -43,6 +43,20 @@ import java.nio.file.Path; * object will have its own isolated cookie storage. */ public interface APIRequestContext { + class DisposeOptions { + /** + * The reason to be reported to the operations interrupted by the context disposal. + */ + public String reason; + + /** + * The reason to be reported to the operations interrupted by the context disposal. + */ + public DisposeOptions setReason(String reason) { + this.reason = reason; + return this; + } + } class StorageStateOptions { /** * The file path to save the storage state to. If {@code path} is a relative path, then it is resolved relative to current @@ -88,7 +102,18 @@ public interface APIRequestContext { * * @since v1.16 */ - void dispose(); + default void dispose() { + dispose(null); + } + /** + * All responses returned by {@link com.microsoft.playwright.APIRequestContext#get APIRequestContext.get()} and similar + * methods are stored in the memory, so that you can later call {@link com.microsoft.playwright.APIResponse#body + * APIResponse.body()}.This method discards all its resources, calling any method on disposed {@code APIRequestContext} + * will throw an exception. + * + * @since v1.16 + */ + void dispose(DisposeOptions options); /** * Sends HTTP(S) request and returns its response. The method will populate request cookies from the context and update * context cookies from the response. The method will automatically follow redirects. diff --git a/playwright/src/main/java/com/microsoft/playwright/BrowserContext.java b/playwright/src/main/java/com/microsoft/playwright/BrowserContext.java index 6d4f0693..fc2d28db 100644 --- a/playwright/src/main/java/com/microsoft/playwright/BrowserContext.java +++ b/playwright/src/main/java/com/microsoft/playwright/BrowserContext.java @@ -501,6 +501,12 @@ public interface BrowserContext extends AutoCloseable { return this; } } + /** + * Playwright has ability to mock clock and passage of time. + * + * @since v1.45 + */ + Clock clock(); /** * Adds cookies into this browser context. All pages within this context will have these cookies installed. Cookies can be * obtained via {@link com.microsoft.playwright.BrowserContext#cookies BrowserContext.cookies()}. @@ -863,21 +869,22 @@ public interface BrowserContext extends AutoCloseable { * * @param permissions A permission or an array of permissions to grant. Permissions can be one of the following values: *
Note that clock is installed for the entire {@code BrowserContext}, so the time in all the pages and iframes is + * controlled by the same clock. + */ +public interface Clock { + class InstallOptions { + /** + * Time to initialize with, current system time by default. + */ + public Object time; + + /** + * Time to initialize with, current system time by default. + */ + public InstallOptions setTime(long time) { + this.time = time; + return this; + } + /** + * Time to initialize with, current system time by default. + */ + public InstallOptions setTime(String time) { + this.time = time; + return this; + } + /** + * Time to initialize with, current system time by default. + */ + public InstallOptions setTime(Date time) { + this.time = time; + return this; + } + } + /** + * Advance the clock by jumping forward in time. Only fires due timers at most once. This is equivalent to user closing the + * laptop lid for a while and reopening it later, after given time. + * + *
Usage + *
{@code
+ * page.clock().fastForward(1000);
+ * page.clock().fastForward("30:00");
+ * }
+ *
+ * @param ticks Time may be the number of milliseconds to advance the clock by or a human-readable string. Valid string formats are "08"
+ * for eight seconds, "01:00" for one minute and "02:34:10" for two hours, 34 minutes and ten seconds.
+ * @since v1.45
+ */
+ void fastForward(long ticks);
+ /**
+ * Advance the clock by jumping forward in time. Only fires due timers at most once. This is equivalent to user closing the
+ * laptop lid for a while and reopening it later, after given time.
+ *
+ * Usage + *
{@code
+ * page.clock().fastForward(1000);
+ * page.clock().fastForward("30:00");
+ * }
+ *
+ * @param ticks Time may be the number of milliseconds to advance the clock by or a human-readable string. Valid string formats are "08"
+ * for eight seconds, "01:00" for one minute and "02:34:10" for two hours, 34 minutes and ten seconds.
+ * @since v1.45
+ */
+ void fastForward(String ticks);
+ /**
+ * Install fake implementations for the following time-related functions:
+ * Fake timers are used to manually control the flow of time in tests. They allow you to advance time, fire timers, and + * control the behavior of time-dependent functions. See {@link com.microsoft.playwright.Clock#runFor Clock.runFor()} and + * {@link com.microsoft.playwright.Clock#fastForward Clock.fastForward()} for more information. + * + * @since v1.45 + */ + default void install() { + install(null); + } + /** + * Install fake implementations for the following time-related functions: + *
Fake timers are used to manually control the flow of time in tests. They allow you to advance time, fire timers, and + * control the behavior of time-dependent functions. See {@link com.microsoft.playwright.Clock#runFor Clock.runFor()} and + * {@link com.microsoft.playwright.Clock#fastForward Clock.fastForward()} for more information. + * + * @since v1.45 + */ + void install(InstallOptions options); + /** + * Advance the clock, firing all the time-related callbacks. + * + *
Usage + *
{@code
+ * page.clock().runFor(1000);
+ * page.clock().runFor("30:00");
+ * }
+ *
+ * @param ticks Time may be the number of milliseconds to advance the clock by or a human-readable string. Valid string formats are "08"
+ * for eight seconds, "01:00" for one minute and "02:34:10" for two hours, 34 minutes and ten seconds.
+ * @since v1.45
+ */
+ void runFor(long ticks);
+ /**
+ * Advance the clock, firing all the time-related callbacks.
+ *
+ * Usage + *
{@code
+ * page.clock().runFor(1000);
+ * page.clock().runFor("30:00");
+ * }
+ *
+ * @param ticks Time may be the number of milliseconds to advance the clock by or a human-readable string. Valid string formats are "08"
+ * for eight seconds, "01:00" for one minute and "02:34:10" for two hours, 34 minutes and ten seconds.
+ * @since v1.45
+ */
+ void runFor(String ticks);
+ /**
+ * Advance the clock by jumping forward in time and pause the time. Once this method is called, no timers are fired unless
+ * {@link com.microsoft.playwright.Clock#runFor Clock.runFor()}, {@link com.microsoft.playwright.Clock#fastForward
+ * Clock.fastForward()}, {@link com.microsoft.playwright.Clock#pauseAt Clock.pauseAt()} or {@link
+ * com.microsoft.playwright.Clock#resume Clock.resume()} is called.
+ *
+ * Only fires due timers at most once. This is equivalent to user closing the laptop lid for a while and reopening it at + * the specified time and pausing. + * + *
Usage + *
{@code
+ * page.clock().pauseAt(Instant.parse("2020-02-02"));
+ * page.clock().pauseAt("2020-02-02");
+ * }
+ *
+ * @since v1.45
+ */
+ void pauseAt(long time);
+ /**
+ * Advance the clock by jumping forward in time and pause the time. Once this method is called, no timers are fired unless
+ * {@link com.microsoft.playwright.Clock#runFor Clock.runFor()}, {@link com.microsoft.playwright.Clock#fastForward
+ * Clock.fastForward()}, {@link com.microsoft.playwright.Clock#pauseAt Clock.pauseAt()} or {@link
+ * com.microsoft.playwright.Clock#resume Clock.resume()} is called.
+ *
+ * Only fires due timers at most once. This is equivalent to user closing the laptop lid for a while and reopening it at + * the specified time and pausing. + * + *
Usage + *
{@code
+ * page.clock().pauseAt(Instant.parse("2020-02-02"));
+ * page.clock().pauseAt("2020-02-02");
+ * }
+ *
+ * @since v1.45
+ */
+ void pauseAt(String time);
+ /**
+ * Advance the clock by jumping forward in time and pause the time. Once this method is called, no timers are fired unless
+ * {@link com.microsoft.playwright.Clock#runFor Clock.runFor()}, {@link com.microsoft.playwright.Clock#fastForward
+ * Clock.fastForward()}, {@link com.microsoft.playwright.Clock#pauseAt Clock.pauseAt()} or {@link
+ * com.microsoft.playwright.Clock#resume Clock.resume()} is called.
+ *
+ * Only fires due timers at most once. This is equivalent to user closing the laptop lid for a while and reopening it at + * the specified time and pausing. + * + *
Usage + *
{@code
+ * page.clock().pauseAt(Instant.parse("2020-02-02"));
+ * page.clock().pauseAt("2020-02-02");
+ * }
+ *
+ * @since v1.45
+ */
+ void pauseAt(Date time);
+ /**
+ * Resumes timers. Once this method is called, time resumes flowing, timers are fired as usual.
+ *
+ * @since v1.45
+ */
+ void resume();
+ /**
+ * Makes {@code Date.now} and {@code new Date()} return fixed fake time at all times, keeps all the timers running.
+ *
+ * Usage + *
{@code
+ * page.clock().setFixedTime(Instant.now());
+ * page.clock().setFixedTime(Instant.parse("2020-02-02"));
+ * page.clock().setFixedTime("2020-02-02");
+ * }
+ *
+ * @param time Time to be set.
+ * @since v1.45
+ */
+ void setFixedTime(long time);
+ /**
+ * Makes {@code Date.now} and {@code new Date()} return fixed fake time at all times, keeps all the timers running.
+ *
+ * Usage + *
{@code
+ * page.clock().setFixedTime(Instant.now());
+ * page.clock().setFixedTime(Instant.parse("2020-02-02"));
+ * page.clock().setFixedTime("2020-02-02");
+ * }
+ *
+ * @param time Time to be set.
+ * @since v1.45
+ */
+ void setFixedTime(String time);
+ /**
+ * Makes {@code Date.now} and {@code new Date()} return fixed fake time at all times, keeps all the timers running.
+ *
+ * Usage + *
{@code
+ * page.clock().setFixedTime(Instant.now());
+ * page.clock().setFixedTime(Instant.parse("2020-02-02"));
+ * page.clock().setFixedTime("2020-02-02");
+ * }
+ *
+ * @param time Time to be set.
+ * @since v1.45
+ */
+ void setFixedTime(Date time);
+ /**
+ * Sets current system time but does not trigger any timers.
+ *
+ * Usage + *
{@code
+ * page.clock().setSystemTime(Instant.now());
+ * page.clock().setSystemTime(Instant.parse("2020-02-02"));
+ * page.clock().setSystemTime("2020-02-02");
+ * }
+ *
+ * @since v1.45
+ */
+ void setSystemTime(long time);
+ /**
+ * Sets current system time but does not trigger any timers.
+ *
+ * Usage + *
{@code
+ * page.clock().setSystemTime(Instant.now());
+ * page.clock().setSystemTime(Instant.parse("2020-02-02"));
+ * page.clock().setSystemTime("2020-02-02");
+ * }
+ *
+ * @since v1.45
+ */
+ void setSystemTime(String time);
+ /**
+ * Sets current system time but does not trigger any timers.
+ *
+ * Usage + *
{@code
+ * page.clock().setSystemTime(Instant.now());
+ * page.clock().setSystemTime(Instant.parse("2020-02-02"));
+ * page.clock().setSystemTime("2020-02-02");
+ * }
+ *
+ * @since v1.45
+ */
+ void setSystemTime(Date time);
+}
+
diff --git a/playwright/src/main/java/com/microsoft/playwright/ConsoleMessage.java b/playwright/src/main/java/com/microsoft/playwright/ConsoleMessage.java
index 74296f18..4d1aea69 100644
--- a/playwright/src/main/java/com/microsoft/playwright/ConsoleMessage.java
+++ b/playwright/src/main/java/com/microsoft/playwright/ConsoleMessage.java
@@ -20,7 +20,7 @@ import java.util.*;
/**
* {@code ConsoleMessage} objects are dispatched by page via the {@link com.microsoft.playwright.Page#onConsoleMessage
- * Page.onConsoleMessage()} event. For each console messages logged in the page there will be corresponding event in the
+ * Page.onConsoleMessage()} event. For each console message logged in the page there will be corresponding event in the
* Playwright context.
* {@code
* // Listen for all console messages and print them to the standard output.
diff --git a/playwright/src/main/java/com/microsoft/playwright/ElementHandle.java b/playwright/src/main/java/com/microsoft/playwright/ElementHandle.java
index c48518e9..026dd87d 100644
--- a/playwright/src/main/java/com/microsoft/playwright/ElementHandle.java
+++ b/playwright/src/main/java/com/microsoft/playwright/ElementHandle.java
@@ -1926,6 +1926,8 @@ public interface ElementHandle extends JSHandle {
* Throws when {@code elementHandle} does not point to an element connected to a Document or a ShadowRoot.
*
+ *
See scrolling for alternative ways to scroll.
+ *
* @since v1.8
*/
default void scrollIntoViewIfNeeded() {
@@ -1940,6 +1942,8 @@ public interface ElementHandle extends JSHandle {
*
Throws when {@code elementHandle} does not point to an element connected to a Document or a ShadowRoot.
*
+ *
See scrolling for alternative ways to scroll.
+ *
* @since v1.8
*/
void scrollIntoViewIfNeeded(ScrollIntoViewIfNeededOptions options);
@@ -2371,7 +2375,8 @@ public interface ElementHandle extends JSHandle {
void setChecked(boolean checked, SetCheckedOptions options);
/**
* Sets the value of the file input to these file paths or files. If some of the {@code filePaths} are relative paths, then
- * they are resolved relative to the current working directory. For empty array, clears the selected files.
+ * they are resolved relative to the current working directory. For empty array, clears the selected files. For inputs with
+ * a {@code [webkitdirectory]} attribute, only a single directory path is supported.
*
*
This method expects {@code ElementHandle} to point to an input element. However, if the element is
@@ -2386,7 +2391,8 @@ public interface ElementHandle extends JSHandle {
}
/**
* Sets the value of the file input to these file paths or files. If some of the {@code filePaths} are relative paths, then
- * they are resolved relative to the current working directory. For empty array, clears the selected files.
+ * they are resolved relative to the current working directory. For empty array, clears the selected files. For inputs with
+ * a {@code [webkitdirectory]} attribute, only a single directory path is supported.
*
*
This method expects {@code ElementHandle} to point to an input element. However, if the element is
@@ -2399,7 +2405,8 @@ public interface ElementHandle extends JSHandle {
void setInputFiles(Path files, SetInputFilesOptions options);
/**
* Sets the value of the file input to these file paths or files. If some of the {@code filePaths} are relative paths, then
- * they are resolved relative to the current working directory. For empty array, clears the selected files.
+ * they are resolved relative to the current working directory. For empty array, clears the selected files. For inputs with
+ * a {@code [webkitdirectory]} attribute, only a single directory path is supported.
*
*
This method expects {@code ElementHandle} to point to an input element. However, if the element is
@@ -2414,7 +2421,8 @@ public interface ElementHandle extends JSHandle {
}
/**
* Sets the value of the file input to these file paths or files. If some of the {@code filePaths} are relative paths, then
- * they are resolved relative to the current working directory. For empty array, clears the selected files.
+ * they are resolved relative to the current working directory. For empty array, clears the selected files. For inputs with
+ * a {@code [webkitdirectory]} attribute, only a single directory path is supported.
*
*
This method expects {@code ElementHandle} to point to an input element. However, if the element is
@@ -2427,7 +2435,8 @@ public interface ElementHandle extends JSHandle {
void setInputFiles(Path[] files, SetInputFilesOptions options);
/**
* Sets the value of the file input to these file paths or files. If some of the {@code filePaths} are relative paths, then
- * they are resolved relative to the current working directory. For empty array, clears the selected files.
+ * they are resolved relative to the current working directory. For empty array, clears the selected files. For inputs with
+ * a {@code [webkitdirectory]} attribute, only a single directory path is supported.
*
*
This method expects {@code ElementHandle} to point to an input element. However, if the element is
@@ -2442,7 +2451,8 @@ public interface ElementHandle extends JSHandle {
}
/**
* Sets the value of the file input to these file paths or files. If some of the {@code filePaths} are relative paths, then
- * they are resolved relative to the current working directory. For empty array, clears the selected files.
+ * they are resolved relative to the current working directory. For empty array, clears the selected files. For inputs with
+ * a {@code [webkitdirectory]} attribute, only a single directory path is supported.
*
*
This method expects {@code ElementHandle} to point to an input element. However, if the element is
@@ -2455,7 +2465,8 @@ public interface ElementHandle extends JSHandle {
void setInputFiles(FilePayload files, SetInputFilesOptions options);
/**
* Sets the value of the file input to these file paths or files. If some of the {@code filePaths} are relative paths, then
- * they are resolved relative to the current working directory. For empty array, clears the selected files.
+ * they are resolved relative to the current working directory. For empty array, clears the selected files. For inputs with
+ * a {@code [webkitdirectory]} attribute, only a single directory path is supported.
*
*
This method expects {@code ElementHandle} to point to an input element. However, if the element is
@@ -2470,7 +2481,8 @@ public interface ElementHandle extends JSHandle {
}
/**
* Sets the value of the file input to these file paths or files. If some of the {@code filePaths} are relative paths, then
- * they are resolved relative to the current working directory. For empty array, clears the selected files.
+ * they are resolved relative to the current working directory. For empty array, clears the selected files. For inputs with
+ * a {@code [webkitdirectory]} attribute, only a single directory path is supported.
*
*
This method expects {@code ElementHandle} to point to an input element. However, if the element is
diff --git a/playwright/src/main/java/com/microsoft/playwright/Locator.java b/playwright/src/main/java/com/microsoft/playwright/Locator.java
index a09fc1d5..eef4643b 100644
--- a/playwright/src/main/java/com/microsoft/playwright/Locator.java
+++ b/playwright/src/main/java/com/microsoft/playwright/Locator.java
@@ -4372,6 +4372,8 @@ public interface Locator {
* href="https://developer.mozilla.org/en-US/docs/Web/API/Intersection_Observer_API">IntersectionObserver's {@code
* ratio}.
*
+ *
See scrolling for alternative ways to scroll.
+ *
* @since v1.14
*/
default void scrollIntoViewIfNeeded() {
@@ -4383,6 +4385,8 @@ public interface Locator {
* href="https://developer.mozilla.org/en-US/docs/Web/API/Intersection_Observer_API">IntersectionObserver's {@code
* ratio}.
*
+ *
See scrolling for alternative ways to scroll.
+ *
* @since v1.14
*/
void scrollIntoViewIfNeeded(ScrollIntoViewIfNeededOptions options);
@@ -4879,7 +4883,8 @@ public interface Locator {
*/
void setChecked(boolean checked, SetCheckedOptions options);
/**
- * Upload file or multiple files into {@code }.
+ * Upload file or multiple files into {@code }. For inputs with a {@code [webkitdirectory]} attribute,
+ * only a single directory path is supported.
*
*
Usage
*
{@code
@@ -4889,6 +4894,9 @@ public interface Locator {
* // Select multiple files
* page.getByLabel("Upload files").setInputFiles(new Path[] {Paths.get("file1.txt"), Paths.get("file2.txt")});
*
+ * // Select a directory
+ * page.getByLabel("Upload directory").setInputFiles(Paths.get("mydir"));
+ *
* // Remove all the selected files
* page.getByLabel("Upload file").setInputFiles(new Path[0]);
*
@@ -4914,7 +4922,8 @@ public interface Locator {
setInputFiles(files, null);
}
/**
- * Upload file or multiple files into {@code }.
+ * Upload file or multiple files into {@code }. For inputs with a {@code [webkitdirectory]} attribute,
+ * only a single directory path is supported.
*
* Usage
*
{@code
@@ -4924,6 +4933,9 @@ public interface Locator {
* // Select multiple files
* page.getByLabel("Upload files").setInputFiles(new Path[] {Paths.get("file1.txt"), Paths.get("file2.txt")});
*
+ * // Select a directory
+ * page.getByLabel("Upload directory").setInputFiles(Paths.get("mydir"));
+ *
* // Remove all the selected files
* page.getByLabel("Upload file").setInputFiles(new Path[0]);
*
@@ -4947,7 +4959,8 @@ public interface Locator {
*/
void setInputFiles(Path files, SetInputFilesOptions options);
/**
- * Upload file or multiple files into {@code }.
+ * Upload file or multiple files into {@code }. For inputs with a {@code [webkitdirectory]} attribute,
+ * only a single directory path is supported.
*
* Usage
*
{@code
@@ -4957,6 +4970,9 @@ public interface Locator {
* // Select multiple files
* page.getByLabel("Upload files").setInputFiles(new Path[] {Paths.get("file1.txt"), Paths.get("file2.txt")});
*
+ * // Select a directory
+ * page.getByLabel("Upload directory").setInputFiles(Paths.get("mydir"));
+ *
* // Remove all the selected files
* page.getByLabel("Upload file").setInputFiles(new Path[0]);
*
@@ -4982,7 +4998,8 @@ public interface Locator {
setInputFiles(files, null);
}
/**
- * Upload file or multiple files into {@code }.
+ * Upload file or multiple files into {@code }. For inputs with a {@code [webkitdirectory]} attribute,
+ * only a single directory path is supported.
*
* Usage
*
{@code
@@ -4992,6 +5009,9 @@ public interface Locator {
* // Select multiple files
* page.getByLabel("Upload files").setInputFiles(new Path[] {Paths.get("file1.txt"), Paths.get("file2.txt")});
*
+ * // Select a directory
+ * page.getByLabel("Upload directory").setInputFiles(Paths.get("mydir"));
+ *
* // Remove all the selected files
* page.getByLabel("Upload file").setInputFiles(new Path[0]);
*
@@ -5015,7 +5035,8 @@ public interface Locator {
*/
void setInputFiles(Path[] files, SetInputFilesOptions options);
/**
- * Upload file or multiple files into {@code }.
+ * Upload file or multiple files into {@code }. For inputs with a {@code [webkitdirectory]} attribute,
+ * only a single directory path is supported.
*
* Usage
*
{@code
@@ -5025,6 +5046,9 @@ public interface Locator {
* // Select multiple files
* page.getByLabel("Upload files").setInputFiles(new Path[] {Paths.get("file1.txt"), Paths.get("file2.txt")});
*
+ * // Select a directory
+ * page.getByLabel("Upload directory").setInputFiles(Paths.get("mydir"));
+ *
* // Remove all the selected files
* page.getByLabel("Upload file").setInputFiles(new Path[0]);
*
@@ -5050,7 +5074,8 @@ public interface Locator {
setInputFiles(files, null);
}
/**
- * Upload file or multiple files into {@code }.
+ * Upload file or multiple files into {@code }. For inputs with a {@code [webkitdirectory]} attribute,
+ * only a single directory path is supported.
*
* Usage
*
{@code
@@ -5060,6 +5085,9 @@ public interface Locator {
* // Select multiple files
* page.getByLabel("Upload files").setInputFiles(new Path[] {Paths.get("file1.txt"), Paths.get("file2.txt")});
*
+ * // Select a directory
+ * page.getByLabel("Upload directory").setInputFiles(Paths.get("mydir"));
+ *
* // Remove all the selected files
* page.getByLabel("Upload file").setInputFiles(new Path[0]);
*
@@ -5083,7 +5111,8 @@ public interface Locator {
*/
void setInputFiles(FilePayload files, SetInputFilesOptions options);
/**
- * Upload file or multiple files into {@code }.
+ * Upload file or multiple files into {@code }. For inputs with a {@code [webkitdirectory]} attribute,
+ * only a single directory path is supported.
*
* Usage
*
{@code
@@ -5093,6 +5122,9 @@ public interface Locator {
* // Select multiple files
* page.getByLabel("Upload files").setInputFiles(new Path[] {Paths.get("file1.txt"), Paths.get("file2.txt")});
*
+ * // Select a directory
+ * page.getByLabel("Upload directory").setInputFiles(Paths.get("mydir"));
+ *
* // Remove all the selected files
* page.getByLabel("Upload file").setInputFiles(new Path[0]);
*
@@ -5118,7 +5150,8 @@ public interface Locator {
setInputFiles(files, null);
}
/**
- * Upload file or multiple files into {@code }.
+ * Upload file or multiple files into {@code }. For inputs with a {@code [webkitdirectory]} attribute,
+ * only a single directory path is supported.
*
* Usage
*
{@code
@@ -5128,6 +5161,9 @@ public interface Locator {
* // Select multiple files
* page.getByLabel("Upload files").setInputFiles(new Path[] {Paths.get("file1.txt"), Paths.get("file2.txt")});
*
+ * // Select a directory
+ * page.getByLabel("Upload directory").setInputFiles(Paths.get("mydir"));
+ *
* // Remove all the selected files
* page.getByLabel("Upload file").setInputFiles(new Path[0]);
*
diff --git a/playwright/src/main/java/com/microsoft/playwright/Mouse.java b/playwright/src/main/java/com/microsoft/playwright/Mouse.java
index 95272dd9..28424c15 100644
--- a/playwright/src/main/java/com/microsoft/playwright/Mouse.java
+++ b/playwright/src/main/java/com/microsoft/playwright/Mouse.java
@@ -236,7 +236,8 @@ public interface Mouse {
*/
void up(UpOptions options);
/**
- * Dispatches a {@code wheel} event.
+ * Dispatches a {@code wheel} event. This method is usually used to manually scroll the page. See scrolling for alternative ways to scroll.
*
* NOTE: Wheel events may cause scrolling if they are not handled, and this method does not wait for the scrolling to finish
* before returning.
diff --git a/playwright/src/main/java/com/microsoft/playwright/Page.java b/playwright/src/main/java/com/microsoft/playwright/Page.java
index 6d6335c0..9b08a92e 100644
--- a/playwright/src/main/java/com/microsoft/playwright/Page.java
+++ b/playwright/src/main/java/com/microsoft/playwright/Page.java
@@ -3792,6 +3792,12 @@ public interface Page extends AutoCloseable {
return this;
}
}
+ /**
+ * Playwright has ability to mock clock and passage of time.
+ *
+ * @since v1.45
+ */
+ Clock clock();
/**
* Adds a script which would be evaluated in one of the following scenarios:
*
This method expects {@code selector} to point to an input element. However, if the element is @@ -7216,7 +7223,8 @@ public interface Page extends AutoCloseable { } /** * Sets the value of the file input to these file paths or files. If some of the {@code filePaths} are relative paths, then - * they are resolved relative to the current working directory. For empty array, clears the selected files. + * they are resolved relative to the current working directory. For empty array, clears the selected files. For inputs with + * a {@code [webkitdirectory]} attribute, only a single directory path is supported. * *
This method expects {@code selector} to point to an input element. However, if the element is @@ -7230,7 +7238,8 @@ public interface Page extends AutoCloseable { void setInputFiles(String selector, Path files, SetInputFilesOptions options); /** * Sets the value of the file input to these file paths or files. If some of the {@code filePaths} are relative paths, then - * they are resolved relative to the current working directory. For empty array, clears the selected files. + * they are resolved relative to the current working directory. For empty array, clears the selected files. For inputs with + * a {@code [webkitdirectory]} attribute, only a single directory path is supported. * *
This method expects {@code selector} to point to an input element. However, if the element is @@ -7246,7 +7255,8 @@ public interface Page extends AutoCloseable { } /** * Sets the value of the file input to these file paths or files. If some of the {@code filePaths} are relative paths, then - * they are resolved relative to the current working directory. For empty array, clears the selected files. + * they are resolved relative to the current working directory. For empty array, clears the selected files. For inputs with + * a {@code [webkitdirectory]} attribute, only a single directory path is supported. * *
This method expects {@code selector} to point to an input element. However, if the element is @@ -7260,7 +7270,8 @@ public interface Page extends AutoCloseable { void setInputFiles(String selector, Path[] files, SetInputFilesOptions options); /** * Sets the value of the file input to these file paths or files. If some of the {@code filePaths} are relative paths, then - * they are resolved relative to the current working directory. For empty array, clears the selected files. + * they are resolved relative to the current working directory. For empty array, clears the selected files. For inputs with + * a {@code [webkitdirectory]} attribute, only a single directory path is supported. * *
This method expects {@code selector} to point to an input element. However, if the element is @@ -7276,7 +7287,8 @@ public interface Page extends AutoCloseable { } /** * Sets the value of the file input to these file paths or files. If some of the {@code filePaths} are relative paths, then - * they are resolved relative to the current working directory. For empty array, clears the selected files. + * they are resolved relative to the current working directory. For empty array, clears the selected files. For inputs with + * a {@code [webkitdirectory]} attribute, only a single directory path is supported. * *
This method expects {@code selector} to point to an input element. However, if the element is @@ -7290,7 +7302,8 @@ public interface Page extends AutoCloseable { void setInputFiles(String selector, FilePayload files, SetInputFilesOptions options); /** * Sets the value of the file input to these file paths or files. If some of the {@code filePaths} are relative paths, then - * they are resolved relative to the current working directory. For empty array, clears the selected files. + * they are resolved relative to the current working directory. For empty array, clears the selected files. For inputs with + * a {@code [webkitdirectory]} attribute, only a single directory path is supported. * *
This method expects {@code selector} to point to an input element. However, if the element is @@ -7306,7 +7319,8 @@ public interface Page extends AutoCloseable { } /** * Sets the value of the file input to these file paths or files. If some of the {@code filePaths} are relative paths, then - * they are resolved relative to the current working directory. For empty array, clears the selected files. + * they are resolved relative to the current working directory. For empty array, clears the selected files. For inputs with + * a {@code [webkitdirectory]} attribute, only a single directory path is supported. * *
This method expects {@code selector} to point to an input element. However, if the element is
@@ -8084,7 +8098,7 @@ public interface Page extends AutoCloseable {
* });
*
* // Waits for the next response matching some conditions
- * Response response = page.waitForResponse(response -> "https://example.com".equals(response.url()) && response.status() == 200, () -> {
+ * Response response = page.waitForResponse(response -> "https://example.com".equals(response.url()) && response.status() == 200 && "GET".equals(response.request().method()), () -> {
* // Triggers the response
* page.getByText("trigger response").click();
* });
@@ -8112,7 +8126,7 @@ public interface Page extends AutoCloseable {
* });
*
* // Waits for the next response matching some conditions
- * Response response = page.waitForResponse(response -> "https://example.com".equals(response.url()) && response.status() == 200, () -> {
+ * Response response = page.waitForResponse(response -> "https://example.com".equals(response.url()) && response.status() == 200 && "GET".equals(response.request().method()), () -> {
* // Triggers the response
* page.getByText("trigger response").click();
* });
@@ -8138,7 +8152,7 @@ public interface Page extends AutoCloseable {
* });
*
* // Waits for the next response matching some conditions
- * Response response = page.waitForResponse(response -> "https://example.com".equals(response.url()) && response.status() == 200, () -> {
+ * Response response = page.waitForResponse(response -> "https://example.com".equals(response.url()) && response.status() == 200 && "GET".equals(response.request().method()), () -> {
* // Triggers the response
* page.getByText("trigger response").click();
* });
@@ -8166,7 +8180,7 @@ public interface Page extends AutoCloseable {
* });
*
* // Waits for the next response matching some conditions
- * Response response = page.waitForResponse(response -> "https://example.com".equals(response.url()) && response.status() == 200, () -> {
+ * Response response = page.waitForResponse(response -> "https://example.com".equals(response.url()) && response.status() == 200 && "GET".equals(response.request().method()), () -> {
* // Triggers the response
* page.getByText("trigger response").click();
* });
@@ -8192,7 +8206,7 @@ public interface Page extends AutoCloseable {
* });
*
* // Waits for the next response matching some conditions
- * Response response = page.waitForResponse(response -> "https://example.com".equals(response.url()) && response.status() == 200, () -> {
+ * Response response = page.waitForResponse(response -> "https://example.com".equals(response.url()) && response.status() == 200 && "GET".equals(response.request().method()), () -> {
* // Triggers the response
* page.getByText("trigger response").click();
* });
@@ -8220,7 +8234,7 @@ public interface Page extends AutoCloseable {
* });
*
* // Waits for the next response matching some conditions
- * Response response = page.waitForResponse(response -> "https://example.com".equals(response.url()) && response.status() == 200, () -> {
+ * Response response = page.waitForResponse(response -> "https://example.com".equals(response.url()) && response.status() == 200 && "GET".equals(response.request().method()), () -> {
* // Triggers the response
* page.getByText("trigger response").click();
* });
diff --git a/playwright/src/main/java/com/microsoft/playwright/assertions/LocatorAssertions.java b/playwright/src/main/java/com/microsoft/playwright/assertions/LocatorAssertions.java
index 55f3476a..e2a81d47 100644
--- a/playwright/src/main/java/com/microsoft/playwright/assertions/LocatorAssertions.java
+++ b/playwright/src/main/java/com/microsoft/playwright/assertions/LocatorAssertions.java
@@ -752,10 +752,10 @@ public interface LocatorAssertions {
* assertThat(page.getByText("Welcome")).isVisible();
*
* // At least one item in the list is visible.
- * asserThat(page.getByTestId("todo-item").first()).isVisible();
+ * assertThat(page.getByTestId("todo-item").first()).isVisible();
*
* // At least one of the two elements is visible, possibly both.
- * asserThat(
+ * assertThat(
* page.getByRole(AriaRole.BUTTON, new Page.GetByRoleOptions().setName("Sign in"))
* .or(page.getByRole(AriaRole.BUTTON, new Page.GetByRoleOptions().setName("Sign up")))
* .first()
@@ -780,10 +780,10 @@ public interface LocatorAssertions {
* assertThat(page.getByText("Welcome")).isVisible();
*
* // At least one item in the list is visible.
- * asserThat(page.getByTestId("todo-item").first()).isVisible();
+ * assertThat(page.getByTestId("todo-item").first()).isVisible();
*
* // At least one of the two elements is visible, possibly both.
- * asserThat(
+ * assertThat(
* page.getByRole(AriaRole.BUTTON, new Page.GetByRoleOptions().setName("Sign in"))
* .or(page.getByRole(AriaRole.BUTTON, new Page.GetByRoleOptions().setName("Sign up")))
* .first()
diff --git a/playwright/src/main/java/com/microsoft/playwright/impl/APIRequestContextImpl.java b/playwright/src/main/java/com/microsoft/playwright/impl/APIRequestContextImpl.java
index 191223af..f7aca95e 100644
--- a/playwright/src/main/java/com/microsoft/playwright/impl/APIRequestContextImpl.java
+++ b/playwright/src/main/java/com/microsoft/playwright/impl/APIRequestContextImpl.java
@@ -37,6 +37,7 @@ import static com.microsoft.playwright.impl.Utils.toFilePayload;
class APIRequestContextImpl extends ChannelOwner implements APIRequestContext {
private final TracingImpl tracing;
+ private String disposeReason;
APIRequestContextImpl(ChannelOwner parent, String type, String guid, JsonObject initializer) {
super(parent, type, guid, initializer);
@@ -49,8 +50,17 @@ class APIRequestContextImpl extends ChannelOwner implements APIRequestContext {
}
@Override
- public void dispose() {
- withLogging("APIRequestContext.dispose", () -> sendMessage("dispose"));
+ public void dispose(DisposeOptions options) {
+ withLogging("APIRequestContext.dispose", () -> disposeImpl(options));
+ }
+
+ private void disposeImpl(DisposeOptions options) {
+ if (options == null) {
+ options = new DisposeOptions();
+ }
+ disposeReason = options.reason;
+ JsonObject params = gson().toJsonTree(options).getAsJsonObject();
+ sendMessage("dispose", params);
}
@Override
@@ -77,6 +87,9 @@ class APIRequestContextImpl extends ChannelOwner implements APIRequestContext {
}
private APIResponse fetchImpl(String url, RequestOptionsImpl options) {
+ if (disposeReason != null) {
+ throw new PlaywrightException(disposeReason);
+ }
if (options == null) {
options = new RequestOptionsImpl();
}
diff --git a/playwright/src/main/java/com/microsoft/playwright/impl/BrowserContextImpl.java b/playwright/src/main/java/com/microsoft/playwright/impl/BrowserContextImpl.java
index df988e8c..735fd1ba 100644
--- a/playwright/src/main/java/com/microsoft/playwright/impl/BrowserContextImpl.java
+++ b/playwright/src/main/java/com/microsoft/playwright/impl/BrowserContextImpl.java
@@ -36,8 +36,7 @@ import java.util.regex.Pattern;
import static com.microsoft.playwright.impl.Serialization.addHarUrlFilter;
import static com.microsoft.playwright.impl.Serialization.gson;
-import static com.microsoft.playwright.impl.Utils.isSafeCloseError;
-import static com.microsoft.playwright.impl.Utils.toJsRegexFlags;
+import static com.microsoft.playwright.impl.Utils.*;
import static java.nio.charset.StandardCharsets.UTF_8;
import static java.nio.file.Files.readAllBytes;
import static java.util.Arrays.asList;
@@ -46,6 +45,7 @@ class BrowserContextImpl extends ChannelOwner implements BrowserContext {
private final BrowserImpl browser;
private final TracingImpl tracing;
private final APIRequestContextImpl request;
+ private final ClockImpl clock;
final List