diff --git a/docs/src/test-runners-python.md b/docs/src/test-runners-python.md index d07fa2e53f..0dd4bbeca3 100644 --- a/docs/src/test-runners-python.md +++ b/docs/src/test-runners-python.md @@ -111,16 +111,21 @@ def test_visit_admin_dashboard(page: Page): If you're using VSCode with Pylance, these types can be inferred by enabling the `python.testing.pytestEnabled` setting so you don't need the type annotation. -### Configure slow mo +### Using multiple contexts -Run tests with slow mo with the `--slowmo` argument. +In order to simulate multiple users, you can create multiple [`BrowserContext`](./browser-contexts) instances. -```bash -pytest --slowmo 100 +```py title="test_my_application.py" +from playwright.sync_api import Page, BrowserContext +from pytest_playwright.pytest_playwright import CreateContextCallback + +def test_foo(page: Page, new_context: CreateContextCallback) -> None: + page.goto("https://example.com") + context = new_context() + page2 = context.new_page() + # page and page2 are in different contexts ``` -Slows down Playwright operations by 100 milliseconds. - ### Skip test by browser ```py title="test_my_application.py" @@ -198,7 +203,7 @@ def browser_context_args(browser_context_args): } ``` -### Device emulation +### Device emulation / BrowserContext option overrides ```py title="conftest.py" import pytest