22 lines
1.4 KiB
Python
22 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(70)
|
|
pg.evaluate("window.scrollTo(0,0)"); pg.wait_for_timeout(700)
|
|
el = pg.query_selector(".svcmenu"); el.scroll_into_view_if_needed(); pg.wait_for_timeout(400)
|
|
el.screenshot(path=os.path.join(OUT,"m-svc.png")); print("OK m-svc")
|
|
rows = pg.query_selector_all(".svcrow__link")
|
|
if len(rows)>=2:
|
|
rows[1].hover(); pg.wait_for_timeout(700); el.screenshot(path=os.path.join(OUT,"m-svc-hover.png")); print("OK m-svc-hover")
|
|
pg.screenshot(path=os.path.join(OUT,"m-full.png"), full_page=True); print("OK m-full")
|
|
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(1500)
|
|
ms = mp.query_selector(".svcmenu"); ms.scroll_into_view_if_needed(); mp.wait_for_timeout(400)
|
|
ms.screenshot(path=os.path.join(OUT,"m-svc-mobile.png")); print("OK m-svc-mobile")
|
|
b.close()
|