35 lines
1.4 KiB
Python
35 lines
1.4 KiB
Python
import time, json
|
|
from pathlib import Path
|
|
from playwright.sync_api import sync_playwright
|
|
TS = time.strftime("%Y%m%d-%H%M%S")
|
|
OUT = Path(f"/var/www/html/test-report/hub-906-{TS}")
|
|
OUT.mkdir(parents=True, exist_ok=True)
|
|
try:
|
|
with sync_playwright() as p:
|
|
browser = p.chromium.launch(headless=True, args=["--no-sandbox"])
|
|
ctx = browser.new_context(
|
|
viewport={"width":1600,"height":1400},
|
|
ignore_https_errors=True,
|
|
record_video_dir=str(OUT),
|
|
record_video_size={"width":1600,"height":1400}
|
|
)
|
|
page = ctx.new_page()
|
|
# Force cache miss
|
|
page.goto(f"https://weval-consulting.com/wevia-unified-hub.html?v906={TS}", wait_until="networkidle", timeout=25000)
|
|
time.sleep(10)
|
|
# Agents view
|
|
page.evaluate("show && show('agents')")
|
|
time.sleep(5)
|
|
page.screenshot(path=str(OUT/"1-agents-906.png"), full_page=True)
|
|
# Summary view
|
|
page.evaluate("show && show('summary')")
|
|
time.sleep(3)
|
|
page.screenshot(path=str(OUT/"2-summary-906.png"), full_page=True)
|
|
kpis = page.evaluate("[...document.querySelectorAll('.kpi .v')].map(e => e.innerText)")
|
|
print(f"KPIs now: {kpis}")
|
|
ctx.close(); browser.close()
|
|
videos = list(OUT.glob("*.webm"))
|
|
print(f"video: {videos[0].name if videos else None}")
|
|
except Exception as e:
|
|
print(f"err: {e}")
|