docs(assertions): add note for setting global python expect timeout (#23106)

Fixes https://github.com/microsoft/playwright-python/issues/1358
This commit is contained in:
Max Schmitt 2023-05-18 02:51:36 +02:00 committed by GitHub
parent f3a1058b38
commit 7b1b2dd741
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -52,3 +52,25 @@ E waiting for get_by_text("Name")
tests/test_foobar.py:22: AssertionError
```
## Setting a custom timeout
* langs: python
You can specify a custom timeout for assertions either globally or per assertion. The default timeout is 5 seconds.
### Global timeout
```python title="conftest.py"
from playwright.sync_api import expect
expect.set_options(timeout=10_000)
```
### Per assertion timeout
```python title="test_foobar.py"
from playwright.sync_api import expect
def test_foobar(page: Page) -> None:
expect(page.get_by_text("Name")).to_be_visible(timeout=10_000)
```