From b1ab6484da111ba6e5a29b707a186c0bf67b5845 Mon Sep 17 00:00:00 2001 From: Max Schmitt Date: Mon, 24 Jul 2023 20:09:09 +0200 Subject: [PATCH] docs(test-runner): add new playwright-features (#24368) https://github.com/microsoft/playwright-pytest/pull/148 https://github.com/microsoft/playwright-pytest/pull/146 --- docs/src/test-runners-python.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/docs/src/test-runners-python.md b/docs/src/test-runners-python.md index 59327bc6f1c6b..e3cd41cdf87c8 100644 --- a/docs/src/test-runners-python.md +++ b/docs/src/test-runners-python.md @@ -33,6 +33,7 @@ addopts = --headed --browser firefox - `--tracing` Whether to record a [trace](./trace-viewer.md) for each test. `on`, `off`, or `retain-on-failure` (default: `off`). - `--video` Whether to record video for each test. `on`, `off`, or `retain-on-failure` (default: `off`). - `--screenshot` Whether to automatically capture a screenshot after each test. `on`, `off`, or `only-on-failure` (default: `off`). +- `--full-page-screenshot` Whether to take a full page screenshot on failure. By default, only the viewport is captured. Requires `--screenshot` to be enabled (default: `off`). ## Fixtures @@ -64,6 +65,17 @@ def test_my_app_is_working(fixture_name): - `browser_type_launch_args`: Override launch arguments for [`method: BrowserType.launch`]. It should return a Dict. - `browser_context_args`: Override the options for [`method: Browser.newContext`]. It should return a Dict. +Its also possible to override the context options ([`method: Browser.newContext`]) for a single test by using the `browser_context_args` marker: + +```python +import pytest + +@pytest.mark.browser_context_args(timezone_id="Europe/Berlin", locale="en-GB") +def test_browser_context_args(page): + assert page.evaluate("window.navigator.userAgent") == "Europe/Berlin" + assert page.evaluate("window.navigator.languages") == ["de-DE"] +``` + ## Parallelism: Running Multiple Tests at Once If your tests are running on a machine with a lot of CPUs, you can speed up the overall execution time of your test suite by using [`pytest-xdist`](https://pypi.org/project/pytest-xdist/) to run multiple tests at once: