Files
weval-l99/pw-neurorag-v2.py
2026-04-19 15:48:31 +02:00

24 lines
1.2 KiB
Python
Executable File

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/autonomy-v2-{TS}")
OUT.mkdir(parents=True, exist_ok=True)
result = {"ts": TS, "url": "https://weval-consulting.com/wevia-autonomy-dashboard.html"}
try:
with sync_playwright() as p:
browser = p.chromium.launch(headless=True, args=["--no-sandbox"])
ctx = browser.new_context(viewport={"width": 1600, "height": 1400}, record_video_dir=str(OUT), record_video_size={"width": 1600, "height": 1400}, ignore_https_errors=True)
page = ctx.new_page()
resp = page.goto(result["url"], wait_until="domcontentloaded", timeout=20000)
result["http"] = resp.status
time.sleep(7)
result["score"] = page.evaluate("document.querySelector('.autonomy-score-box .score')?.innerText?.slice(0,10)")
page.screenshot(path=str(OUT / "autonomy-v2-fullpage.png"), full_page=True)
ctx.close(); browser.close()
print(f"[v2] http={result['http']} score={result['score']}")
except Exception as e:
result["error"] = str(e)
with open(OUT/"result.json","w") as f: json.dump(result, f, indent=2)