@@ -5441,6 +5441,45 @@ default Locator locator(String selector) {
54415441 * @since v1.8
54425442 */
54435443 Mouse mouse ();
5444+ /**
5445+ * Adds one-off {@code Dialog} handler. The handler will be removed immediately after next {@code Dialog} is created.
5446+ * <pre>{@code
5447+ * page.onceDialog(dialog -> {
5448+ * dialog.accept("foo");
5449+ * });
5450+ *
5451+ * // prints 'foo'
5452+ * System.out.println(page.evaluate("prompt('Enter string:')"));
5453+ *
5454+ * // prints 'null' as the dialog will be auto-dismissed because there are no handlers.
5455+ * System.out.println(page.evaluate("prompt('Enter string:')"));
5456+ * }</pre>
5457+ *
5458+ * <p> This code above is equivalent to:
5459+ * <pre>{@code
5460+ * Consumer<Dialog> handler = new Consumer<Dialog>() {
5461+ * @Override
5462+ * public void accept(Dialog dialog) {
5463+ * dialog.accept("foo");
5464+ * page.offDialog(this);
5465+ * }
5466+ * };
5467+ * page.onDialog(handler);
5468+ *
5469+ * // prints 'foo'
5470+ * System.out.println(page.evaluate("prompt('Enter string:')"));
5471+ *
5472+ * // prints 'null' as the dialog will be auto-dismissed because there are no handlers.
5473+ * System.out.println(page.evaluate("prompt('Enter string:')"));
5474+ * }</pre>
5475+ *
5476+ * @param handler Receives the {@code Dialog} object, it **must** either {@link Dialog#accept Dialog.accept()} or {@link Dialog#dismiss
5477+ * Dialog.dismiss()} the dialog - otherwise the page will <a
5478+ * href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/EventLoop#never_blocking">freeze</a> waiting for the
5479+ * dialog, and actions like click will never finish.
5480+ * @since v1.10
5481+ */
5482+ void onceDialog (Consumer <Dialog > handler );
54445483 /**
54455484 * Returns the opener for popup pages and {@code null} for others. If the opener has been closed already the returns {@code
54465485 * null}.
@@ -6727,7 +6766,7 @@ default void setInputFiles(String selector, FilePayload[] files) {
67276766 * <p> When all steps combined have not finished during the specified {@code timeout}, this method throws a {@code
67286767 * TimeoutError}. Passing zero timeout disables this.
67296768 *
6730- * <p> <strong>NOTE:</strong> {@link Page#tap Page.tap()} requires that the {@code hasTouch} option of the browser context be set to true .
6769+ * <p> <strong>NOTE:</strong> {@link Page#tap Page.tap()} the method will throw if {@code hasTouch} option of the browser context is false .
67316770 *
67326771 * @param selector A selector to search for an element. If there are multiple elements satisfying the selector, the first will be used.
67336772 * @since v1.8
@@ -6749,7 +6788,7 @@ default void tap(String selector) {
67496788 * <p> When all steps combined have not finished during the specified {@code timeout}, this method throws a {@code
67506789 * TimeoutError}. Passing zero timeout disables this.
67516790 *
6752- * <p> <strong>NOTE:</strong> {@link Page#tap Page.tap()} requires that the {@code hasTouch} option of the browser context be set to true .
6791+ * <p> <strong>NOTE:</strong> {@link Page#tap Page.tap()} the method will throw if {@code hasTouch} option of the browser context is false .
67536792 *
67546793 * @param selector A selector to search for an element. If there are multiple elements satisfying the selector, the first will be used.
67556794 * @since v1.8
@@ -7838,44 +7877,5 @@ default Worker waitForWorker(Runnable callback) {
78387877 * @since v1.8
78397878 */
78407879 List <Worker > workers ();
7841- /**
7842- * Adds one-off {@code Dialog} handler. The handler will be removed immediately after next {@code Dialog} is created.
7843- * <pre>{@code
7844- * page.onceDialog(dialog -> {
7845- * dialog.accept("foo");
7846- * });
7847- *
7848- * // prints 'foo'
7849- * System.out.println(page.evaluate("prompt('Enter string:')"));
7850- *
7851- * // prints 'null' as the dialog will be auto-dismissed because there are no handlers.
7852- * System.out.println(page.evaluate("prompt('Enter string:')"));
7853- * }</pre>
7854- *
7855- * <p> This code above is equivalent to:
7856- * <pre>{@code
7857- * Consumer<Dialog> handler = new Consumer<Dialog>() {
7858- * @Override
7859- * public void accept(Dialog dialog) {
7860- * dialog.accept("foo");
7861- * page.offDialog(this);
7862- * }
7863- * };
7864- * page.onDialog(handler);
7865- *
7866- * // prints 'foo'
7867- * System.out.println(page.evaluate("prompt('Enter string:')"));
7868- *
7869- * // prints 'null' as the dialog will be auto-dismissed because there are no handlers.
7870- * System.out.println(page.evaluate("prompt('Enter string:')"));
7871- * }</pre>
7872- *
7873- * @param handler Receives the {@code Dialog} object, it **must** either {@link Dialog#accept Dialog.accept()} or {@link Dialog#dismiss
7874- * Dialog.dismiss()} the dialog - otherwise the page will <a
7875- * href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/EventLoop#never_blocking">freeze</a> waiting for the
7876- * dialog, and actions like click will never finish.
7877- * @since v1.10
7878- */
7879- void onceDialog (Consumer <Dialog > handler );
78807880}
78817881
0 commit comments