93 lines
3.5 KiB
Python
Executable File
93 lines
3.5 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
"""
|
|
Playwright VIDEO TOUR · 18 avr 2026 · Opus Yacine
|
|
Visit 7 critical pages, record video, capture screenshots
|
|
Zero code change · read-only E2E verification
|
|
"""
|
|
import os, sys, 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/video-tour-{TS}")
|
|
OUT.mkdir(parents=True, exist_ok=True)
|
|
|
|
PAGES = [
|
|
("01_home", "https://weval-consulting.com/"),
|
|
("02_wtp_platform", "https://weval-consulting.com/weval-technology-platform.html"),
|
|
("03_wevia_master_chat", "https://weval-consulting.com/wevia-master.html"),
|
|
("04_wevia_training", "https://weval-consulting.com/wevia-training.html"),
|
|
("05_business_kpi_dash", "https://weval-consulting.com/business-kpi-dashboard.php"),
|
|
("06_products_kpi_dash", "https://weval-consulting.com/products-kpi-dashboard.php"),
|
|
("07_ethica_hub", "https://weval-consulting.com/ethica-hub.html"),
|
|
]
|
|
|
|
results = {"ts": TS, "out": str(OUT), "pages": []}
|
|
|
|
with sync_playwright() as p:
|
|
browser = p.chromium.launch(headless=True, args=["--no-sandbox"])
|
|
context = browser.new_context(
|
|
viewport={"width": 1920, "height": 1080},
|
|
record_video_dir=str(OUT),
|
|
record_video_size={"width": 1920, "height": 1080},
|
|
ignore_https_errors=True,
|
|
)
|
|
page = context.new_page()
|
|
|
|
# Log console errors
|
|
console_errs = []
|
|
page.on("pageerror", lambda e: console_errs.append(str(e)))
|
|
page.on("console", lambda m: console_errs.append(m.text) if m.type == "error" else None)
|
|
|
|
for slug, url in PAGES:
|
|
print(f"[tour] {slug} → {url}", flush=True)
|
|
t0 = time.time()
|
|
status_code = None
|
|
try:
|
|
resp = page.goto(url, wait_until="domcontentloaded", timeout=25000)
|
|
if resp: status_code = resp.status
|
|
time.sleep(1.5) # let JS render
|
|
# Scroll to trigger lazy loads
|
|
page.evaluate("window.scrollTo(0, document.body.scrollHeight/2)")
|
|
time.sleep(0.8)
|
|
page.evaluate("window.scrollTo(0, 0)")
|
|
time.sleep(0.5)
|
|
sshot = str(OUT / f"{slug}.png")
|
|
page.screenshot(path=sshot, full_page=True)
|
|
|
|
# Metrics
|
|
title = page.title()
|
|
body_len = page.evaluate("document.body.innerText.length")
|
|
|
|
results["pages"].append({
|
|
"slug": slug, "url": url, "status": status_code,
|
|
"title": title, "body_len": body_len,
|
|
"screenshot": sshot, "elapsed_ms": round((time.time() - t0) * 1000, 0),
|
|
"errors": len([e for e in console_errs[-10:] if url.split("/")[-1].split(".")[0] in str(e)]),
|
|
})
|
|
print(f" ✓ status={status_code} body_len={body_len} title={title[:60]}", flush=True)
|
|
except Exception as e:
|
|
results["pages"].append({
|
|
"slug": slug, "url": url, "error": str(e)[:200]
|
|
})
|
|
print(f" ✗ FAIL: {e}", flush=True)
|
|
|
|
context.close()
|
|
browser.close()
|
|
|
|
# Save metrics JSON
|
|
with open(OUT / "tour-results.json", "w") as f:
|
|
json.dump(results, f, indent=2)
|
|
|
|
# Summary
|
|
total = len(results["pages"])
|
|
ok = sum(1 for p in results["pages"] if p.get("status") == 200)
|
|
print(f"\n[SUMMARY] {ok}/{total} pages 200 OK · output: {OUT}")
|
|
|
|
# List video files
|
|
videos = sorted(OUT.glob("*.webm"))
|
|
print(f"[VIDEO] {len(videos)} file(s) recorded:")
|
|
for v in videos:
|
|
size_mb = v.stat().st_size / (1024 * 1024)
|
|
print(f" {v.name}: {size_mb:.1f} MB")
|