Skip to content

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

docs: fix async locator handlers (#36926)

Max Schmitt6ce216b669ad
diff --git a/docs/src/api/class-page.md b/docs/src/api/class-page.md
index a69ac2446e..9bf2840085 100644
--- a/docs/src/api/class-page.md
+++ b/docs/src/api/class-page.md
@@ -3183,7 +3183,7 @@ page.get_by_role("button", name="Start here").click()
```python async
# Setup the handler.
-def handler():
+async def handler():
await page.get_by_role("button", name="No thanks").click()
await page.add_locator_handler(page.get_by_text("Sign up to the newsletter"), handler)
@@ -3240,7 +3240,7 @@ page.get_by_role("button", name="Start here").click()
```python async
# Setup the handler.
-def handler():
+async def handler():
await page.get_by_role("button", name="Remind me later").click()
await page.add_locator_handler(page.get_by_text("Confirm your security details"), handler)
@@ -3297,7 +3297,7 @@ page.get_by_role("button", name="Start here").click()
```python async
# Setup the handler.
-def handler():
+async def handler():
await page.evaluate("window.removeObstructionsForTestIfNeeded()")
await page.add_locator_handler(page.locator("body"), handler, no_wait_after=True)
@@ -3338,7 +3338,7 @@ page.add_locator_handler(page.get_by_label("Close"), handler, times=1)
```
```python async
-def handler(locator):
+async def handler(locator):
await locator.click()
await page.add_locator_handler(page.get_by_label("Close"), handler, times=1)
```