From 9d495e21c7470f55b94719a40419d97be71c4032 Mon Sep 17 00:00:00 2001 From: techbefore07-ops Date: Tue, 15 Sep 2026 18:36:20 +0530 Subject: [PATCH] fix(page-fixture): support multi-browser runs when page fixture is overridden MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes #172 — when a test overrides the 'page' fixture, multi-browser parametrization (--browser chromium --browser firefox) was skipped because pytest_generate_tests only checked for 'browser_name' in fixturenames. Add _PLAYWRIGHT_FIXTURES set covering all known Playwright fixtures and check for any of them to trigger multi-browser parametrization. Co-authored-by: openhands --- .../pytest_playwright/pytest_playwright.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/pytest-playwright/pytest_playwright/pytest_playwright.py b/pytest-playwright/pytest_playwright/pytest_playwright.py index 7aece1a..d9b6434 100644 --- a/pytest-playwright/pytest_playwright/pytest_playwright.py +++ b/pytest-playwright/pytest_playwright/pytest_playwright.py @@ -121,8 +121,21 @@ def pytest_runtest_call(item: Any) -> Generator[None, Any, None]: raise _BaseExceptionGroup("Soft assertion failures", errors) +_PLAYWRIGHT_FIXTURES = frozenset( + { + "browser_name", + "browser", + "browser_type", + "context", + "page", + "browser_context_args", + "browser_type_launch_args", + } +) + + def pytest_generate_tests(metafunc: Any) -> None: - if "browser_name" in metafunc.fixturenames: + if _PLAYWRIGHT_FIXTURES & set(metafunc.fixturenames): browsers = metafunc.config.option.browser or ["chromium"] metafunc.parametrize("browser_name", browsers, scope="session")