@@ -258,7 +258,8 @@ public interface Page extends AutoCloseable {
258258 *
259259 * <p> <strong>NOTE:</strong> HTTP Error responses, such as 404 or 503, are still successful responses from HTTP standpoint, so request will complete
260260 * with {@link Page#onRequestFinished Page.onRequestFinished()} event and not with {@link Page#onRequestFailed
261- * Page.onRequestFailed()}.
261+ * Page.onRequestFailed()}. A request will only be considered failed when the client cannot get an HTTP response from the
262+ * server, e.g. due to network error net::ERR_FAILED.
262263 */
263264 void onRequestFailed (Consumer <Request > handler );
264265 /**
@@ -626,6 +627,11 @@ class EmulateMediaOptions {
626627 * disables CSS media emulation.
627628 */
628629 public Optional <Media > media ;
630+ /**
631+ * Emulates {@code "prefers-reduced-motion"} media feature, supported values are {@code "reduce"}, {@code "no-preference"}. Passing {@code null}
632+ * disables reduced motion emulation.
633+ */
634+ public Optional <ReducedMotion > reducedMotion ;
629635
630636 public EmulateMediaOptions setColorScheme (ColorScheme colorScheme ) {
631637 this .colorScheme = Optional .ofNullable (colorScheme );
@@ -635,6 +641,10 @@ public EmulateMediaOptions setMedia(Media media) {
635641 this .media = Optional .ofNullable (media );
636642 return this ;
637643 }
644+ public EmulateMediaOptions setReducedMotion (ReducedMotion reducedMotion ) {
645+ this .reducedMotion = Optional .ofNullable (reducedMotion );
646+ return this ;
647+ }
638648 }
639649 class ExposeBindingOptions {
640650 /**
@@ -1603,6 +1613,26 @@ public WaitForRequestOptions setTimeout(double timeout) {
16031613 return this ;
16041614 }
16051615 }
1616+ class WaitForRequestFinishedOptions {
1617+ /**
1618+ * Receives the {@code Request} object and resolves to truthy value when the waiting should resolve.
1619+ */
1620+ public Predicate <Request > predicate ;
1621+ /**
1622+ * Maximum time to wait for in milliseconds. Defaults to {@code 30000} (30 seconds). Pass {@code 0} to disable timeout. The default
1623+ * value can be changed by using the {@link BrowserContext#setDefaultTimeout BrowserContext.setDefaultTimeout()}.
1624+ */
1625+ public Double timeout ;
1626+
1627+ public WaitForRequestFinishedOptions setPredicate (Predicate <Request > predicate ) {
1628+ this .predicate = predicate ;
1629+ return this ;
1630+ }
1631+ public WaitForRequestFinishedOptions setTimeout (double timeout ) {
1632+ this .timeout = timeout ;
1633+ return this ;
1634+ }
1635+ }
16061636 class WaitForResponseOptions {
16071637 /**
16081638 * Maximum wait time in milliseconds, defaults to 30 seconds, pass {@code 0} to disable the timeout. The default value can be
@@ -2508,7 +2538,7 @@ default void exposeBinding(String name, BindingCallback callback) {
25082538 *
25092539 * <p> <strong>NOTE:</strong> Functions installed via {@link Page#exposeFunction Page.exposeFunction()} survive navigations.
25102540 *
2511- * <p> An example of adding an {@code sha1 } function to the page:
2541+ * <p> An example of adding a {@code sha256 } function to the page:
25122542 * <pre>{@code
25132543 * import com.microsoft.playwright.*;
25142544 *
@@ -2523,11 +2553,11 @@ default void exposeBinding(String name, BindingCallback callback) {
25232553 * BrowserType webkit = playwright.webkit();
25242554 * Browser browser = webkit.launch({ headless: false });
25252555 * Page page = browser.newPage();
2526- * page.exposeFunction("sha1 ", args -> {
2556+ * page.exposeFunction("sha256 ", args -> {
25272557 * String text = (String) args[0];
25282558 * MessageDigest crypto;
25292559 * try {
2530- * crypto = MessageDigest.getInstance("SHA-1 ");
2560+ * crypto = MessageDigest.getInstance("SHA-256 ");
25312561 * } catch (NoSuchAlgorithmException e) {
25322562 * return null;
25332563 * }
@@ -2536,7 +2566,7 @@ default void exposeBinding(String name, BindingCallback callback) {
25362566 * });
25372567 * page.setContent("<script>\n" +
25382568 * " async function onClick() {\n" +
2539- * " document.querySelector('div').textContent = await window.sha1 ('PLAYWRIGHT');\n" +
2569+ * " document.querySelector('div').textContent = await window.sha256 ('PLAYWRIGHT');\n" +
25402570 * " }\n" +
25412571 * "</script>\n" +
25422572 * "<button onclick=\"onClick()\">Click me</button>\n" +
@@ -4095,7 +4125,7 @@ default Page waitForClose(Runnable callback) {
40954125 /**
40964126 * Performs action and waits for a {@code ConsoleMessage} to be logged by in the page. If predicate is provided, it passes
40974127 * {@code ConsoleMessage} value into the {@code predicate} function and waits for {@code predicate(message)} to return a truthy value. Will
4098- * throw an error if the page is closed before the console event is fired.
4128+ * throw an error if the page is closed before the {@link Page#onConsole Page.onConsole()} event is fired.
40994129 *
41004130 * @param callback Callback that performs the action triggering the event.
41014131 */
@@ -4105,7 +4135,7 @@ default ConsoleMessage waitForConsoleMessage(Runnable callback) {
41054135 /**
41064136 * Performs action and waits for a {@code ConsoleMessage} to be logged by in the page. If predicate is provided, it passes
41074137 * {@code ConsoleMessage} value into the {@code predicate} function and waits for {@code predicate(message)} to return a truthy value. Will
4108- * throw an error if the page is closed before the console event is fired.
4138+ * throw an error if the page is closed before the {@link Page#onConsole Page.onConsole()} event is fired.
41094139 *
41104140 * @param callback Callback that performs the action triggering the event.
41114141 */
@@ -4401,7 +4431,7 @@ default Page waitForPopup(Runnable callback) {
44014431 * Waits for the matching request and returns it. See <a
44024432 * href="https://playwright.dev/java/docs/events/#waiting-for-event">waiting for event</a> for more details about events.
44034433 * <pre>{@code
4404- * // Waits for the next response with the specified url
4434+ * // Waits for the next request with the specified url
44054435 * Request request = page.waitForRequest("https://example.com/resource", () -> {
44064436 * // Triggers the request
44074437 * page.click("button.triggers-request");
@@ -4424,7 +4454,7 @@ default Request waitForRequest(String urlOrPredicate, Runnable callback) {
44244454 * Waits for the matching request and returns it. See <a
44254455 * href="https://playwright.dev/java/docs/events/#waiting-for-event">waiting for event</a> for more details about events.
44264456 * <pre>{@code
4427- * // Waits for the next response with the specified url
4457+ * // Waits for the next request with the specified url
44284458 * Request request = page.waitForRequest("https://example.com/resource", () -> {
44294459 * // Triggers the request
44304460 * page.click("button.triggers-request");
@@ -4445,7 +4475,7 @@ default Request waitForRequest(String urlOrPredicate, Runnable callback) {
44454475 * Waits for the matching request and returns it. See <a
44464476 * href="https://playwright.dev/java/docs/events/#waiting-for-event">waiting for event</a> for more details about events.
44474477 * <pre>{@code
4448- * // Waits for the next response with the specified url
4478+ * // Waits for the next request with the specified url
44494479 * Request request = page.waitForRequest("https://example.com/resource", () -> {
44504480 * // Triggers the request
44514481 * page.click("button.triggers-request");
@@ -4468,7 +4498,7 @@ default Request waitForRequest(Pattern urlOrPredicate, Runnable callback) {
44684498 * Waits for the matching request and returns it. See <a
44694499 * href="https://playwright.dev/java/docs/events/#waiting-for-event">waiting for event</a> for more details about events.
44704500 * <pre>{@code
4471- * // Waits for the next response with the specified url
4501+ * // Waits for the next request with the specified url
44724502 * Request request = page.waitForRequest("https://example.com/resource", () -> {
44734503 * // Triggers the request
44744504 * page.click("button.triggers-request");
@@ -4489,7 +4519,7 @@ default Request waitForRequest(Pattern urlOrPredicate, Runnable callback) {
44894519 * Waits for the matching request and returns it. See <a
44904520 * href="https://playwright.dev/java/docs/events/#waiting-for-event">waiting for event</a> for more details about events.
44914521 * <pre>{@code
4492- * // Waits for the next response with the specified url
4522+ * // Waits for the next request with the specified url
44934523 * Request request = page.waitForRequest("https://example.com/resource", () -> {
44944524 * // Triggers the request
44954525 * page.click("button.triggers-request");
@@ -4512,7 +4542,7 @@ default Request waitForRequest(Predicate<Request> urlOrPredicate, Runnable callb
45124542 * Waits for the matching request and returns it. See <a
45134543 * href="https://playwright.dev/java/docs/events/#waiting-for-event">waiting for event</a> for more details about events.
45144544 * <pre>{@code
4515- * // Waits for the next response with the specified url
4545+ * // Waits for the next request with the specified url
45164546 * Request request = page.waitForRequest("https://example.com/resource", () -> {
45174547 * // Triggers the request
45184548 * page.click("button.triggers-request");
@@ -4529,6 +4559,24 @@ default Request waitForRequest(Predicate<Request> urlOrPredicate, Runnable callb
45294559 * @param callback Callback that performs the action triggering the event.
45304560 */
45314561 Request waitForRequest (Predicate <Request > urlOrPredicate , WaitForRequestOptions options , Runnable callback );
4562+ /**
4563+ * Performs action and waits for a {@code Request} to finish loading. If predicate is provided, it passes {@code Request} value into
4564+ * the {@code predicate} function and waits for {@code predicate(request)} to return a truthy value. Will throw an error if the page is
4565+ * closed before the {@link Page#onRequestFinished Page.onRequestFinished()} event is fired.
4566+ *
4567+ * @param callback Callback that performs the action triggering the event.
4568+ */
4569+ default Request waitForRequestFinished (Runnable callback ) {
4570+ return waitForRequestFinished (null , callback );
4571+ }
4572+ /**
4573+ * Performs action and waits for a {@code Request} to finish loading. If predicate is provided, it passes {@code Request} value into
4574+ * the {@code predicate} function and waits for {@code predicate(request)} to return a truthy value. Will throw an error if the page is
4575+ * closed before the {@link Page#onRequestFinished Page.onRequestFinished()} event is fired.
4576+ *
4577+ * @param callback Callback that performs the action triggering the event.
4578+ */
4579+ Request waitForRequestFinished (WaitForRequestFinishedOptions options , Runnable callback );
45324580 /**
45334581 * Returns the matched response. See <a href="https://playwright.dev/java/docs/events/#waiting-for-event">waiting for
45344582 * event</a> for more details about events.
0 commit comments