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

49 lines
2.1 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/unified-hub-{TS}")
OUT.mkdir(parents=True, exist_ok=True)
results = {"ts": TS}
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)
page = ctx.new_page()
page.goto(f"https://weval-consulting.com/wevia-unified-hub.html?t={TS}", wait_until="networkidle", timeout=25000)
time.sleep(8)
# Summary view (default)
page.screenshot(path=str(OUT/"1-summary.png"), full_page=True)
results["summary_kpis"] = page.evaluate("[...document.querySelectorAll('.kpi .v')].map(e => e.innerText)")
# Agents view
page.evaluate("show('agents')")
time.sleep(2)
page.screenshot(path=str(OUT/"2-agents.png"), full_page=True)
results["agents_count"] = page.evaluate("document.getElementById('agents-count')?.innerText")
# Intents view
page.evaluate("show('intents')")
time.sleep(2)
page.screenshot(path=str(OUT/"3-intents.png"), full_page=True)
results["intents_count"] = page.evaluate("document.getElementById('intents-count')?.innerText")
# Skills view
page.evaluate("show('skills')")
time.sleep(2)
page.screenshot(path=str(OUT/"4-skills.png"), full_page=True)
results["skills_count"] = page.evaluate("document.getElementById('skills-count')?.innerText")
# Dashboards view
page.evaluate("show('dashboards')")
time.sleep(2)
page.screenshot(path=str(OUT/"5-dashboards.png"), full_page=True)
results["dashboards_count"] = page.evaluate("document.getElementById('dashboards-count')?.innerText")
ctx.close(); browser.close()
print(json.dumps(results, indent=2))
with open(OUT/"result.json","w") as f: json.dump(results, f, indent=2)
except Exception as e:
print(f"err: {e}")