feat: Playwright browser wrapper with compact snapshot

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-06-01 00:11:47 +08:00
parent cf022c5096
commit 9161f623a7
2 changed files with 90 additions and 0 deletions
+23
View File
@@ -0,0 +1,23 @@
import pytest
playwright = pytest.importorskip("playwright.sync_api")
from auto_reverse.browser import Browser # noqa: E402
@pytest.fixture
def browser():
try:
b = Browser(proxy_port=None, headless=True)
b.start()
except Exception as exc: # browser binary missing, etc.
pytest.skip(f"browser unavailable: {exc}")
yield b
b.stop()
def test_navigate_and_snapshot(browser, fixture_site):
browser.navigate(fixture_site + "/")
snap = browser.snapshot()
assert snap["url"].endswith("/")
assert "title" in snap