Files
html/tests/pw-test2.py
2026-04-12 22:57:03 +02:00

40 lines
2.2 KiB
Python

import json,os
from playwright.sync_api import sync_playwright
R=[];D="/tmp/weval-ss";os.makedirs(D,exist_ok=True)
def t(n,u,pg):
try:
r=pg.goto(u,wait_until="domcontentloaded",timeout=12000)
c=r.status if r else 0;pg.screenshot(path=f"{D}/{n}.png",full_page=False)
ok=c in[200,301,302];R.append({"t":n,"s":"P" if ok else "F","c":c});print(f"{'P' if ok else 'F'} {n}:{c}")
except Exception as e:
R.append({"t":n,"s":"F","c":0});print(f"F {n}:{str(e)[:50]}")
with sync_playwright() as p:
b=p.chromium.launch(headless=True,args=["--no-sandbox"])
pg=b.new_page(ignore_https_errors=True);pg.set_default_timeout(12000)
# Chatbot test
pg.goto("https://weval-consulting.com/api/weval-ia-fast.php",wait_until="domcontentloaded")
pg.screenshot(path=f"{D}/chatbot-api.png")
# POST test
resp=pg.evaluate("""async()=>{
const r=await fetch("https://weval-consulting.com/api/weval-ia-fast.php",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({message:"Qui es-tu?"})});
return await r.json();
}""")
ok=resp.get("response","")!="" and len(resp.get("response",""))>10
prov=resp.get("provider","?")
print(f"{'P' if ok else 'F'} chatbot: {prov} ({len(resp.get('response',''))}ch)")
R.append({"t":"chatbot","s":"P" if ok else "F","c":200,"provider":prov})
# Arsenal pages
t("blade-ai","https://weval-consulting.com/blade-ai.html",pg)
t("nonreg","https://weval-consulting.com/nonreg.html",pg)
t("command","https://weval-consulting.com/command-center.html",pg)
t("agents","https://weval-consulting.com/agents-enterprise.html",pg)
t("benchmark","https://weval-consulting.com/ai-benchmark.html",pg)
t("sovereign","https://weval-consulting.com/sovereign-monitor.html",pg)
t("ethica-hcp","https://weval-consulting.com/ethica-hcp-manager.html",pg)
t("pricing","https://weval-consulting.com/pricing.html",pg)
t("methodologie","https://weval-consulting.com/methodologie.html",pg)
t("contact","https://weval-consulting.com/contact-us/",pg)
pg.close();b.close()
ps=sum(1 for r in R if r["s"]=="P");print(f"RESULT:{ps}/{len(R)}")
ss=[f for f in os.listdir(D) if f.endswith(".png")];print(f"TOTAL_SS:{len(ss)}")