Files
helvoirtgevelreiniging.nl/scripts/shoot-services.py
T

25 lines
1.4 KiB
Python

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(80)
pg.evaluate("window.scrollTo(0,0)"); pg.wait_for_timeout(700)
el = pg.query_selector(".services")
el.scroll_into_view_if_needed(); pg.wait_for_timeout(500)
el.screenshot(path=os.path.join(OUT,"sec-services.png")); print("OK sec-services")
# hover 3e dienst
rows = pg.query_selector_all(".srow")
if len(rows) >= 3:
rows[2].hover(); pg.wait_for_timeout(800)
el.screenshot(path=os.path.join(OUT,"sec-services-hover.png")); print("OK sec-services-hover")
# mobile
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)
mse = mp.query_selector(".services"); mse.scroll_into_view_if_needed(); mp.wait_for_timeout(500)
mse.screenshot(path=os.path.join(OUT,"sec-services-mobile.png")); print("OK sec-services-mobile")
b.close()