@@ -5918,34 +5918,40 @@ default ElementHandle querySelector(String selector) {
59185918 */
59195919 List <ElementHandle > querySelectorAll (String selector );
59205920 /**
5921- * Sometimes, the web page can show an overlay that obstructs elements behind it and prevents certain actions, like click,
5922- * from completing. When such an overlay is shown predictably, we recommend dismissing it as a part of your test flow.
5923- * However, sometimes such an overlay may appear non-deterministically, for example certain cookies consent dialogs behave
5924- * this way. In this case, {@link Page#addLocatorHandler Page.addLocatorHandler()} allows handling an overlay during an
5925- * action that it would block.
5921+ * When testing a web page, sometimes unexpected overlays like a coookie consent dialog appear and block actions you want
5922+ * to automate, e.g. clicking a button. These overlays don't always show up in the same way or at the same time, making
5923+ * them tricky to handle in automated tests.
59265924 *
5927- * <p> This method registers a handler for an overlay that is executed once the locator is visible on the page. The handler
5928- * should get rid of the overlay so that actions blocked by it can proceed. This is useful for nondeterministic
5929- * interstitial pages or dialogs, like a cookie consent dialog.
5925+ * <p> This method lets you set up a special function, called a handler, that activates when it detects that overlay is
5926+ * visible. The handler's job is to remove the overlay, allowing your test to continue as if the overlay wasn't there.
59305927 *
5931- * <p> Note that execution time of the handler counts towards the timeout of the action/assertion that executed the handler.
5932- *
5933- * <p> You can register multiple handlers. However, only a single handler will be running at a time. Any actions inside a
5934- * handler must not require another handler to run.
5928+ * <p> Things to keep in mind:
5929+ * <ul>
5930+ * <li> When an overlay is shown predictably, we recommend explicitly waiting for it in your test and dismissing it as a part of
5931+ * your normal test flow, instead of using {@link Page#addLocatorHandler Page.addLocatorHandler()}.</li>
5932+ * <li> Playwright checks for the overlay every time before executing or retrying an action that requires an <a
5933+ * href="https://playwright.dev/java/docs/actionability">actionability check</a>, or before performing an auto-waiting
5934+ * assertion check. When overlay is visible, Playwright calls the handler first, and then proceeds with the
5935+ * action/assertion.</li>
5936+ * <li> The execution time of the handler counts towards the timeout of the action/assertion that executed the handler. If your
5937+ * handler takes too long, it might cause timeouts.</li>
5938+ * <li> You can register multiple handlers. However, only a single handler will be running at a time. Make sure the actions
5939+ * within a handler don't depend on another handler.</li>
5940+ * </ul>
59355941 *
5936- * <p> <strong>NOTE:</strong> Running the interceptor will alter your page state mid-test. For example it will change the currently focused element
5937- * and move the mouse. Make sure that the actions that run after the interceptor are self-contained and do not rely on the
5938- * focus and mouse state. <br /> <br /> For example, consider a test that calls {@link Locator#focus Locator.focus()}
5942+ * <p> <strong>NOTE:</strong> Running the handler will alter your page state mid-test. For example it will change the currently focused element and
5943+ * move the mouse. Make sure that actions that run after the handler are self-contained and do not rely on the focus and
5944+ * mouse state being unchanged . <br /> <br /> For example, consider a test that calls {@link Locator#focus Locator.focus()}
59395945 * followed by {@link Keyboard#press Keyboard.press()}. If your handler clicks a button between these two actions, the
59405946 * focused element most likely will be wrong, and key press will happen on the unexpected element. Use {@link Locator#press
59415947 * Locator.press()} instead to avoid this problem. <br /> <br /> Another example is a series of mouse actions, where {@link
59425948 * Mouse#move Mouse.move()} is followed by {@link Mouse#down Mouse.down()}. Again, when the handler runs between these two
5943- * actions, the mouse position will be wrong during the mouse down. Prefer methods like {@link Locator#click
5944- * Locator.click()} that are self-contained .
5949+ * actions, the mouse position will be wrong during the mouse down. Prefer self-contained actions like {@link Locator#click
5950+ * Locator.click()} that do not rely on the state being unchanged by a handler .
59455951 *
59465952 * <p> **Usage**
59475953 *
5948- * <p> An example that closes a cookie dialog when it appears:
5954+ * <p> An example that closes a cookie consent dialog when it appears:
59495955 * <pre>{@code
59505956 * // Setup the handler.
59515957 * page.addLocatorHandler(page.getByRole(AriaRole.BUTTON, new Page.GetByRoleOptions().setName("Accept all cookies")), () => {
0 commit comments