This commit is contained in:
2026-01-18 12:23:01 +01:00
parent ef3d0ed970
commit bb1263edb8
86 changed files with 90289 additions and 0 deletions

View File

@@ -0,0 +1,23 @@
from __future__ import annotations
from pathlib import Path
from playwright.async_api import async_playwright, Browser, BrowserContext
async def build_browser_context(headless: bool, viewport: dict[str, int], locale: str, timezone: str) -> BrowserContext:
playwright = await async_playwright().start()
browser: Browser = await playwright.chromium.launch(headless=headless)
context = await browser.new_context(
viewport=viewport,
locale=locale,
timezone_id=timezone,
)
context.set_default_timeout(30000)
return context
async def close_context(context: BrowserContext) -> None:
await context.close()
await context.browser.close()
await context._playwright.stop()