From 1b7e097b68cd76eb1a57a947305de8c59f36d85f Mon Sep 17 00:00:00 2001 From: Max Schmitt Date: Wed, 24 Apr 2024 22:40:38 +0200 Subject: [PATCH] docs(python): add docs for new_context fixture (#30522) https://github.com/microsoft/playwright-internal/issues/202 --- docs/src/test-runners-python.md | 25 +------------------------ 1 file changed, 1 insertion(+), 24 deletions(-) diff --git a/docs/src/test-runners-python.md b/docs/src/test-runners-python.md index 0e3ffde0dd..0ad4043066 100644 --- a/docs/src/test-runners-python.md +++ b/docs/src/test-runners-python.md @@ -55,6 +55,7 @@ def test_my_app_is_working(fixture_name): - `context`: New [browser context](./browser-contexts) for a test. - `page`: New [browser page](./pages) for a test. +- `new_context`: Allows creating different [browser contexts](./browser-contexts) for a test. Useful for multi-user scenarios. Accepts the same parameters as [`method: Browser.newContext`]. **Session scope**: These fixtures are created when requested in a test function and destroyed when all tests end. @@ -211,30 +212,6 @@ def browser_context_args(browser_context_args, playwright): Or via the CLI `--device="iPhone 11 Pro"` -### Persistent context - -```py title="conftest.py" -import pytest -from playwright.sync_api import BrowserType -from typing import Dict - -@pytest.fixture(scope="session") -def context( - browser_type: BrowserType, - browser_type_launch_args: Dict, - browser_context_args: Dict -): - context = browser_type.launch_persistent_context("./foobar", **{ - **browser_type_launch_args, - **browser_context_args, - "locale": "de-DE", - }) - yield context - context.close() -``` - -When using that all pages inside your test are created from the persistent context. - ### Using with `unittest.TestCase` See the following example for using it with `unittest.TestCase`. This has a limitation,