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":950}).new_page() pg.goto("http://localhost:4321/", wait_until="networkidle", timeout=60000); pg.wait_for_timeout(2600) pg.screenshot(path=os.path.join(OUT,"cur-hero.png")); for y in range(0, pg.evaluate("document.body.scrollHeight"), 380): pg.evaluate(f"window.scrollTo(0,{y})"); pg.wait_for_timeout(70) pg.evaluate("window.scrollTo(0,0)"); pg.wait_for_timeout(800) pg.screenshot(path=os.path.join(OUT,"cur-full.png"), full_page=True) mp=b.new_context(viewport={"width":390,"height":844}, device_scale_factor=2).new_page() mp.goto("http://localhost:4321/", wait_until="networkidle", timeout=60000); mp.wait_for_timeout(2200) for y in range(0, mp.evaluate("document.body.scrollHeight"), 380): mp.evaluate(f"window.scrollTo(0,{y})"); mp.wait_for_timeout(60) mp.evaluate("window.scrollTo(0,0)"); mp.wait_for_timeout(600) mp.screenshot(path=os.path.join(OUT,"cur-mobile-full.png"), full_page=True) print("OK shots") b.close()