From 9db2c96e14e3b05684f89236f8ec4ce022505abf Mon Sep 17 00:00:00 2001 From: Max Schmitt Date: Tue, 5 Mar 2024 12:35:27 +0100 Subject: [PATCH 1/2] chore(roll): roll Playwright to v1.42.1 --- README.md | 4 ++-- setup.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index be1ab9fb8..611573b16 100644 --- a/README.md +++ b/README.md @@ -4,9 +4,9 @@ Playwright is a Python library to automate [Chromium](https://www.chromium.org/H | | Linux | macOS | Windows | | :--- | :---: | :---: | :---: | -| Chromium 122.0.6261.39 | ✅ | ✅ | ✅ | +| Chromium 123.0.6312.4 | ✅ | ✅ | ✅ | | WebKit 17.4 | ✅ | ✅ | ✅ | -| Firefox 122.0 | ✅ | ✅ | ✅ | +| Firefox 123.0 | ✅ | ✅ | ✅ | ## Documentation diff --git a/setup.py b/setup.py index c190f3794..6e7f816cc 100644 --- a/setup.py +++ b/setup.py @@ -30,7 +30,7 @@ InWheel = None from wheel.bdist_wheel import bdist_wheel as BDistWheelCommand -driver_version = "1.42.0-alpha-2024-02-19" +driver_version = "1.42.1" def extractall(zip: zipfile.ZipFile, path: str) -> None: From 0d4bbb984a5ec779536e6e2f73be881b0fdc27a5 Mon Sep 17 00:00:00 2001 From: Max Schmitt Date: Tue, 5 Mar 2024 17:32:24 +0100 Subject: [PATCH 2/2] re-generate api --- playwright/async_api/_generated.py | 46 ++++++++++++++++-------------- playwright/sync_api/_generated.py | 46 ++++++++++++++++-------------- 2 files changed, 48 insertions(+), 44 deletions(-) diff --git a/playwright/async_api/_generated.py b/playwright/async_api/_generated.py index e484baa09..3e266ccf0 100644 --- a/playwright/async_api/_generated.py +++ b/playwright/async_api/_generated.py @@ -11669,35 +11669,37 @@ async def add_locator_handler( ) -> None: """Page.add_locator_handler - Sometimes, the web page can show an overlay that obstructs elements behind it and prevents certain actions, like - click, from completing. When such an overlay is shown predictably, we recommend dismissing it as a part of your - test flow. However, sometimes such an overlay may appear non-deterministically, for example certain cookies consent - dialogs behave this way. In this case, `page.add_locator_handler()` allows handling an overlay during an - action that it would block. - - This method registers a handler for an overlay that is executed once the locator is visible on the page. The - handler should get rid of the overlay so that actions blocked by it can proceed. This is useful for - nondeterministic interstitial pages or dialogs, like a cookie consent dialog. - - Note that execution time of the handler counts towards the timeout of the action/assertion that executed the - handler. - - You can register multiple handlers. However, only a single handler will be running at a time. Any actions inside a - handler must not require another handler to run. - - **NOTE** Running the interceptor will alter your page state mid-test. For example it will change the currently - focused element and move the mouse. Make sure that the actions that run after the interceptor are self-contained - and do not rely on the focus and mouse state.

For example, consider a test that calls + When testing a web page, sometimes unexpected overlays like a coookie consent dialog appear and block actions you + want to automate, e.g. clicking a button. These overlays don't always show up in the same way or at the same time, + making them tricky to handle in automated tests. + + This method lets you set up a special function, called a handler, that activates when it detects that overlay is + visible. The handler's job is to remove the overlay, allowing your test to continue as if the overlay wasn't there. + + Things to keep in mind: + - When an overlay is shown predictably, we recommend explicitly waiting for it in your test and dismissing it as + a part of your normal test flow, instead of using `page.add_locator_handler()`. + - Playwright checks for the overlay every time before executing or retrying an action that requires an + [actionability check](https://playwright.dev/python/docs/actionability), or before performing an auto-waiting assertion check. When overlay + is visible, Playwright calls the handler first, and then proceeds with the action/assertion. + - The execution time of the handler counts towards the timeout of the action/assertion that executed the handler. + If your handler takes too long, it might cause timeouts. + - You can register multiple handlers. However, only a single handler will be running at a time. Make sure the + actions within a handler don't depend on another handler. + + **NOTE** Running the handler will alter your page state mid-test. For example it will change the currently focused + element and move the mouse. Make sure that actions that run after the handler are self-contained and do not rely on + the focus and mouse state being unchanged.

For example, consider a test that calls `locator.focus()` followed by `keyboard.press()`. If your handler clicks a button between these two actions, the focused element most likely will be wrong, and key press will happen on the unexpected element. Use `locator.press()` instead to avoid this problem.

Another example is a series of mouse actions, where `mouse.move()` is followed by `mouse.down()`. Again, when the handler runs between - these two actions, the mouse position will be wrong during the mouse down. Prefer methods like - `locator.click()` that are self-contained. + these two actions, the mouse position will be wrong during the mouse down. Prefer self-contained actions like + `locator.click()` that do not rely on the state being unchanged by a handler. **Usage** - An example that closes a cookie dialog when it appears: + An example that closes a cookie consent dialog when it appears: ```py # Setup the handler. diff --git a/playwright/sync_api/_generated.py b/playwright/sync_api/_generated.py index a861367be..d6ecf78ad 100644 --- a/playwright/sync_api/_generated.py +++ b/playwright/sync_api/_generated.py @@ -11752,35 +11752,37 @@ def set_checked( def add_locator_handler(self, locator: "Locator", handler: typing.Callable) -> None: """Page.add_locator_handler - Sometimes, the web page can show an overlay that obstructs elements behind it and prevents certain actions, like - click, from completing. When such an overlay is shown predictably, we recommend dismissing it as a part of your - test flow. However, sometimes such an overlay may appear non-deterministically, for example certain cookies consent - dialogs behave this way. In this case, `page.add_locator_handler()` allows handling an overlay during an - action that it would block. - - This method registers a handler for an overlay that is executed once the locator is visible on the page. The - handler should get rid of the overlay so that actions blocked by it can proceed. This is useful for - nondeterministic interstitial pages or dialogs, like a cookie consent dialog. - - Note that execution time of the handler counts towards the timeout of the action/assertion that executed the - handler. - - You can register multiple handlers. However, only a single handler will be running at a time. Any actions inside a - handler must not require another handler to run. - - **NOTE** Running the interceptor will alter your page state mid-test. For example it will change the currently - focused element and move the mouse. Make sure that the actions that run after the interceptor are self-contained - and do not rely on the focus and mouse state.

For example, consider a test that calls + When testing a web page, sometimes unexpected overlays like a coookie consent dialog appear and block actions you + want to automate, e.g. clicking a button. These overlays don't always show up in the same way or at the same time, + making them tricky to handle in automated tests. + + This method lets you set up a special function, called a handler, that activates when it detects that overlay is + visible. The handler's job is to remove the overlay, allowing your test to continue as if the overlay wasn't there. + + Things to keep in mind: + - When an overlay is shown predictably, we recommend explicitly waiting for it in your test and dismissing it as + a part of your normal test flow, instead of using `page.add_locator_handler()`. + - Playwright checks for the overlay every time before executing or retrying an action that requires an + [actionability check](https://playwright.dev/python/docs/actionability), or before performing an auto-waiting assertion check. When overlay + is visible, Playwright calls the handler first, and then proceeds with the action/assertion. + - The execution time of the handler counts towards the timeout of the action/assertion that executed the handler. + If your handler takes too long, it might cause timeouts. + - You can register multiple handlers. However, only a single handler will be running at a time. Make sure the + actions within a handler don't depend on another handler. + + **NOTE** Running the handler will alter your page state mid-test. For example it will change the currently focused + element and move the mouse. Make sure that actions that run after the handler are self-contained and do not rely on + the focus and mouse state being unchanged.

For example, consider a test that calls `locator.focus()` followed by `keyboard.press()`. If your handler clicks a button between these two actions, the focused element most likely will be wrong, and key press will happen on the unexpected element. Use `locator.press()` instead to avoid this problem.

Another example is a series of mouse actions, where `mouse.move()` is followed by `mouse.down()`. Again, when the handler runs between - these two actions, the mouse position will be wrong during the mouse down. Prefer methods like - `locator.click()` that are self-contained. + these two actions, the mouse position will be wrong during the mouse down. Prefer self-contained actions like + `locator.click()` that do not rely on the state being unchanged by a handler. **Usage** - An example that closes a cookie dialog when it appears: + An example that closes a cookie consent dialog when it appears: ```py # Setup the handler.