85 lines
3.3 KiB
Python
85 lines
3.3 KiB
Python
"""Validate /weval-portal.html · captures all views + scroll + search 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/portal-{TS}")
|
|
OUT.mkdir(parents=True, exist_ok=True)
|
|
results = {"ts": TS, "captures": []}
|
|
|
|
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()
|
|
|
|
# 1. Open portal
|
|
page.goto(f"https://weval-consulting.com/weval-portal.html?t={TS}", wait_until="networkidle", timeout=20000)
|
|
time.sleep(5)
|
|
page.screenshot(path=str(OUT/"01-hero.png"), full_page=False)
|
|
# Extract KPIs
|
|
kpis = page.evaluate("""() => ({
|
|
agents: document.getElementById('k-agents')?.textContent,
|
|
skills: document.getElementById('k-skills')?.textContent,
|
|
intents: document.getElementById('k-intents')?.textContent,
|
|
dash: document.getElementById('k-dash')?.textContent,
|
|
doctrines: document.getElementById('k-doctrines')?.textContent,
|
|
autonomy: document.getElementById('k-autonomy')?.textContent,
|
|
level: document.getElementById('k-level')?.textContent,
|
|
h_pages: document.getElementById('h-pages')?.textContent,
|
|
})""")
|
|
results["kpis"] = kpis
|
|
print(f" ✓ hero kpis: {kpis}")
|
|
|
|
# 2. Full page
|
|
time.sleep(3)
|
|
page.screenshot(path=str(OUT/"02-full.png"), full_page=True)
|
|
|
|
# 3. Scroll to categories
|
|
page.evaluate("window.scrollTo(0, 900)")
|
|
time.sleep(3)
|
|
page.screenshot(path=str(OUT/"03-categories.png"), full_page=False)
|
|
|
|
# 4. Categories count
|
|
cats = page.evaluate("""() => [...document.querySelectorAll('.cat-section')].map(s => ({
|
|
name: s.querySelector('h3')?.textContent?.trim(),
|
|
count: s.querySelector('.meta')?.textContent
|
|
}))""")
|
|
results["categories"] = cats
|
|
print(f" ✓ categories: {len(cats)}")
|
|
for c in cats[:5]:
|
|
print(f" {c}")
|
|
|
|
# 5. Search test
|
|
page.locator("#search").fill("agents")
|
|
time.sleep(2)
|
|
page.screenshot(path=str(OUT/"04-search-agents.png"), full_page=False)
|
|
|
|
# 6. Click a pillar (WTP)
|
|
page.locator("#search").fill("")
|
|
time.sleep(1)
|
|
page.evaluate("window.scrollTo(0, 0)")
|
|
time.sleep(2)
|
|
page.screenshot(path=str(OUT/"05-back-top.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}
|
|
total = sum(p.stat().st_size for p in pngs)
|
|
print(f"\n ✓ screenshots={len(pngs)} total_size={total}b video={results['video']}")
|
|
|
|
with open(OUT/"results.json","w") as f:
|
|
json.dump(results, f, indent=2, default=str)
|
|
except Exception as e:
|
|
print(f"err: {e}")
|