74 lines
2.9 KiB
Python
Executable File
74 lines
2.9 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
"""
|
|
Playwright VIDEO TOUR v2 · Opus Yacine 18avr
|
|
Handles auth pages, shorter timeouts, saves even if pages fail
|
|
"""
|
|
import os, sys, time, json, traceback
|
|
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)
|
|
|
|
# Public endpoints (no auth) first, then gated
|
|
PAGES = [
|
|
("01_home", "https://weval-consulting.com/"),
|
|
("02_wevia_master_chat", "https://weval-consulting.com/wevia-master.html"),
|
|
("03_stripe_bridge_api", "https://weval-consulting.com/api/stripe-live-bridge.php"),
|
|
("04_release_check_api", "https://weval-consulting.com/api/release-check.php?window=30"),
|
|
("05_dsh_predict_api", "https://weval-consulting.com/api/dsh-predict-api.php"),
|
|
("06_business_kpi_dash", "https://weval-consulting.com/business-kpi-dashboard.php"),
|
|
("07_products_kpi_dash", "https://weval-consulting.com/products-kpi-dashboard.php"),
|
|
]
|
|
|
|
results = {"ts": TS, "out": str(OUT), "pages": []}
|
|
|
|
try:
|
|
with sync_playwright() as p:
|
|
browser = p.chromium.launch(headless=True, args=["--no-sandbox", "--disable-dev-shm-usage"])
|
|
context = browser.new_context(
|
|
viewport={"width": 1440, "height": 900},
|
|
record_video_dir=str(OUT),
|
|
record_video_size={"width": 1440, "height": 900},
|
|
ignore_https_errors=True,
|
|
)
|
|
page = context.new_page()
|
|
|
|
for slug, url in PAGES:
|
|
print(f"[tour] {slug} → {url}", flush=True)
|
|
t0 = time.time()
|
|
entry = {"slug": slug, "url": url}
|
|
try:
|
|
resp = page.goto(url, wait_until="domcontentloaded", timeout=15000)
|
|
entry["status"] = resp.status if resp else None
|
|
time.sleep(1.2)
|
|
page.screenshot(path=str(OUT / f"{slug}.png"), full_page=False)
|
|
entry["title"] = page.title()[:100]
|
|
entry["body_len"] = page.evaluate("document.body ? document.body.innerText.length : 0")
|
|
entry["elapsed_ms"] = round((time.time() - t0) * 1000, 0)
|
|
print(f" OK status={entry['status']} body={entry['body_len']}", flush=True)
|
|
except Exception as e:
|
|
entry["error"] = str(e)[:150]
|
|
print(f" FAIL: {e}", flush=True)
|
|
results["pages"].append(entry)
|
|
|
|
context.close()
|
|
browser.close()
|
|
except Exception as e:
|
|
results["fatal"] = str(e)
|
|
traceback.print_exc()
|
|
|
|
# Save regardless
|
|
with open(OUT / "tour-results.json", "w") as f:
|
|
json.dump(results, f, indent=2)
|
|
|
|
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")
|
|
|
|
videos = list(Path(OUT).glob("*.webm"))
|
|
for v in videos:
|
|
sz = v.stat().st_size
|
|
print(f"[VIDEO] {v.name}: {sz} bytes ({sz//1024}KB)")
|