I want to run a pytest playwright test with multiple browsers - e.g. pytest --browser firefox --browser webkit
This works for function-based tests like this one:
import pytest
from playwright.sync_api import Page
@pytest.mark.playwright
def test_liveserver_with_playwright(page: Page, live_server):
page.goto(f"{live_server.url}/")
# etc.
The test is executed twice, once per browser setting.
However, I also want to use class-based tests, for which I use a fixture on a base class:
import pytest
import unittest
from playwright.sync_api import Page
@pytest.mark.playwright
class PlaywrightTestBase(unittest.TestCase):
@pytest.fixture(autouse=True)
def playwright_liveserver_init(self, page: Page, live_server):
self.page = page
# etc.
class FrontpageTest(PlaywrightTestBase):
def test_one_thing(self):
self.page.goto("...")
# etc
The test runs, but only once - the multiple browser settings are ignored.
What am I missing - is there a way to get the multiple runs in such a setup as well ?