Files
weval-l99/pw-public.py
2026-04-19 18:05:32 +02:00

83 lines
3.9 KiB
Python

"""Playwright public pages only + video full test"""
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/consolidation-final-{TS}")
OUT.mkdir(parents=True, exist_ok=True)
results = {"ts": TS, "pages": [], "video": None}
try:
with sync_playwright() as p:
browser = p.chromium.launch(headless=True, args=["--no-sandbox"])
ctx = browser.new_context(
viewport={"width":1500,"height":1100},
ignore_https_errors=True,
record_video_dir=str(OUT),
record_video_size={"width":1500,"height":1100}
)
page = ctx.new_page()
# Page 1: Autonomy dashboard (public)
page.goto("https://weval-consulting.com/wevia-autonomy-dashboard.html", wait_until="networkidle", timeout=25000)
time.sleep(6)
page.screenshot(path=str(OUT/"01-autonomy-dashboard.png"), full_page=True)
kpis = page.evaluate("[...document.querySelectorAll('.kpi .v,.kpi-value,[class*=value]')].map(e => e.innerText).slice(0,20)")
results["pages"].append({"page":"autonomy-dashboard", "kpis":kpis})
print(f" ✓ autonomy-dashboard kpis: {kpis[:10]}")
# Page 2: Unified Hub v2 (public)
page.goto("https://weval-consulting.com/wevia-unified-hub.html", wait_until="networkidle", timeout=20000)
time.sleep(6)
page.screenshot(path=str(OUT/"02-unified-hub-summary.png"), full_page=True)
hub_kpis = page.evaluate("[...document.querySelectorAll('.kpi .v, .source-box .c')].map(e => e.innerText)")
results["pages"].append({"page":"unified-hub", "kpis":hub_kpis})
print(f" ✓ unified-hub kpis: {hub_kpis[:15]}")
# Click Agents tab
try:
page.evaluate("show && show('agents')")
time.sleep(4)
page.screenshot(path=str(OUT/"03-hub-agents.png"), full_page=True)
agents_count = page.evaluate("document.getElementById('ag-total')?.innerText || document.getElementById('agents-count')?.innerText")
results["pages"].append({"page":"hub-agents-view", "agents_count":agents_count})
print(f" ✓ hub agents view: count={agents_count}")
except Exception as e:
results["pages"].append({"page":"hub-agents-view", "err":str(e)})
# Page 3: Skills Explorer
page.goto("https://weval-consulting.com/skills/", wait_until="networkidle", timeout=15000)
time.sleep(5)
page.screenshot(path=str(OUT/"04-skills-explorer.png"), full_page=True)
skills_total = page.evaluate("document.getElementById('total')?.innerText")
results["pages"].append({"page":"skills-explorer", "total":skills_total})
print(f" ✓ skills-explorer total: {skills_total}")
# Page 4: Truth Registry JSON (raw)
page.goto("https://weval-consulting.com/api/wevia-truth-registry.json", wait_until="networkidle", timeout=15000)
time.sleep(2)
page.screenshot(path=str(OUT/"05-truth-registry-json.png"), full_page=False)
# Page 5: NL API status query
page.goto("https://weval-consulting.com/api/wevia.php?q=status&format=text", wait_until="networkidle", timeout=15000)
time.sleep(2)
page.screenshot(path=str(OUT/"06-nl-status.png"), full_page=False)
ctx.close()
browser.close()
videos = list(OUT.glob("*.webm"))
results["video"] = videos[0].name if videos else None
pngs = list(OUT.glob("*.png"))
results["screenshots"] = {p.name: p.stat().st_size for p in pngs}
results["total_screenshots_size"] = sum(p.stat().st_size for p in pngs)
print(f"\n ✓ video={results['video']}")
print(f" ✓ screenshots={len(pngs)} total={results['total_screenshots_size']}b")
with open(OUT/"results.json","w") as f:
json.dump(results, f, indent=2, default=str)
except Exception as e:
print(f"ERR: {e}")