33 lines
1.9 KiB
Python
Executable File
33 lines
1.9 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-dashboard-{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) # wait full refresh() cycle
|
|
result["kpis"] = page.evaluate("document.querySelectorAll('.kpi').length")
|
|
result["skills"] = page.evaluate("document.querySelectorAll('.skill-card').length")
|
|
result["gaps"] = page.evaluate("document.querySelectorAll('.gap-card').length")
|
|
result["cols"] = page.evaluate("document.querySelectorAll('#cols-tbody tr').length")
|
|
result["score_text"] = page.evaluate("document.querySelector('.autonomy-score-box .score')?.innerText?.slice(0,10)")
|
|
page.screenshot(path=str(OUT / "autonomy-fullpage.png"), full_page=True)
|
|
page.evaluate("window.scrollTo(0, 800)"); time.sleep(2)
|
|
page.evaluate("window.scrollTo(0, 0)"); time.sleep(1)
|
|
ctx.close(); browser.close()
|
|
print(f"[autonomy] http={result['http']} kpis={result['kpis']} skills={result['skills']} gaps={result['gaps']} cols={result['cols']} score={result['score_text']}")
|
|
except Exception as e:
|
|
result["error"] = str(e)
|
|
with open(OUT/"result.json","w") as f: json.dump(result, f, indent=2)
|
|
videos = list(OUT.glob("*.webm"))
|
|
for v in videos: print(f"[VIDEO] {v.name}: {v.stat().st_size} bytes")
|