import pytest import pytest_asyncio import asyncio from playwright.async_api import async_playwright @pytest.fixture(scope="session") def event_loop(): loop = asyncio.get_event_loop_policy().new_event_loop() yield loop loop.close() @pytest_asyncio.fixture(scope="function") async def browser(): async with async_playwright() as p: browser = await p.chromium.launch(headless=False, slow_mo=500) yield browser await browser.close() @pytest_asyncio.fixture(scope="function") async def context(browser): context = await browser.new_context( viewport={"width": 1920, "height": 1080}, user_agent="Mozilla/5.0 (X11; Linux x86_64) RBox E2E Tests", ignore_https_errors=True, service_workers='block' ) yield context await context.close() @pytest_asyncio.fixture(scope="function") async def page(context): page = await context.new_page() yield page await page.close() @pytest.fixture def base_url(): return "http://localhost:8000"