from playwright.sync_api import sync_playwright import os OUT = os.path.abspath("shots"); os.makedirs(OUT, exist_ok=True) with sync_playwright() as p: b = p.chromium.launch(headless=True) pg = b.new_context(viewport={"width":1440,"height":900}).new_page() pg.goto("http://localhost:4321/", wait_until="networkidle", timeout=60000) for y in range(0, pg.evaluate("document.body.scrollHeight"), 400): pg.evaluate(f"window.scrollTo(0,{y})"); pg.wait_for_timeout(70) pg.evaluate("window.scrollTo(0,0)"); pg.wait_for_timeout(700) pg.screenshot(path=os.path.join(OUT,"b2-full.png"), full_page=True); print("OK b2-full") el = pg.query_selector(".flow"); el.scroll_into_view_if_needed(); pg.wait_for_timeout(500) el.screenshot(path=os.path.join(OUT,"b2-flow.png")); print("OK b2-flow") b.close()