Eerste commit voor Helvoirt Gevelreiniging
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
from playwright.sync_api import sync_playwright
|
||||
import os
|
||||
|
||||
OUT = os.path.abspath("shots")
|
||||
os.makedirs(OUT, exist_ok=True)
|
||||
|
||||
def set_slider(page, pct):
|
||||
page.evaluate(
|
||||
"""(p) => { const el = document.querySelector('[data-ba]'); if (el) { el.style.animation='none'; el.style.setProperty('--pos', p + '%'); } }""",
|
||||
pct,
|
||||
)
|
||||
|
||||
with sync_playwright() as p:
|
||||
browser = p.chromium.launch(headless=True)
|
||||
ctx = browser.new_context(viewport={"width": 1440, "height": 900}, device_scale_factor=1)
|
||||
page = ctx.new_page()
|
||||
page.goto("http://localhost:4321/", wait_until="networkidle", timeout=60000)
|
||||
page.wait_for_timeout(2800) # laat entrance-animatie settelen
|
||||
|
||||
set_slider(page, 50)
|
||||
page.wait_for_timeout(300)
|
||||
page.screenshot(path=os.path.join(OUT, "home-hero.png"))
|
||||
print("OK home-hero.png")
|
||||
|
||||
set_slider(page, 22)
|
||||
page.wait_for_timeout(300)
|
||||
page.screenshot(path=os.path.join(OUT, "home-hero-before.png"))
|
||||
print("OK home-hero-before.png")
|
||||
|
||||
# scroll voor lazy images + reveals, dan full page
|
||||
height = page.evaluate("document.body.scrollHeight")
|
||||
for y in range(0, height, 400):
|
||||
page.evaluate(f"window.scrollTo(0, {y})")
|
||||
page.wait_for_timeout(110)
|
||||
page.evaluate("window.scrollTo(0, 0)")
|
||||
page.wait_for_load_state("networkidle")
|
||||
page.wait_for_timeout(1000)
|
||||
page.screenshot(path=os.path.join(OUT, "home-full.png"), full_page=True)
|
||||
print("OK home-full.png")
|
||||
|
||||
# mobile
|
||||
m = browser.new_context(viewport={"width": 390, "height": 844}, device_scale_factor=2)
|
||||
mp = m.new_page()
|
||||
mp.goto("http://localhost:4321/", wait_until="networkidle", timeout=60000)
|
||||
mp.wait_for_timeout(2800)
|
||||
mp.screenshot(path=os.path.join(OUT, "home-mobile.png"))
|
||||
print("OK home-mobile.png")
|
||||
|
||||
browser.close()
|
||||
Reference in New Issue
Block a user