Files
weval-l99/v112_debug_blade.py
2026-04-24 04:38:58 +02:00

96 lines
3.8 KiB
Python

#!/usr/bin/env python3
"""V112 - Debug blade push via Playwright avec console log capture"""
import asyncio, json, os
from playwright.async_api import async_playwright
OUT = "/var/www/html/api/blade-tasks/v112-debug-blade-push"
os.makedirs(OUT, exist_ok=True)
async def main():
async with async_playwright() as p:
browser = await p.chromium.launch(headless=True, args=['--no-sandbox'])
context = await browser.new_context(viewport={'width':1920,'height':1080})
page = await context.new_page()
# Capture console
console_msgs = []
page.on('console', lambda msg: console_msgs.append(f"[{msg.type}] {msg.text}"))
page.on('pageerror', lambda err: console_msgs.append(f"[pageerror] {err}"))
await page.goto("https://weval-consulting.com/all-ia-hub.html?v=v112dbg", wait_until='load', timeout=30000)
await page.wait_for_timeout(2000)
await page.click('[data-view="capabilities"]')
await page.wait_for_timeout(3000)
# Direct call pushBladeTask via evaluate to bypass click issues
direct_result = await page.evaluate("""async () => {
try {
// Manually call fetch to blade-task-create
const fd = new FormData();
fd.append('k','WEVADS2026');
fd.append('action','create');
fd.append('goal','v112_direct_test');
fd.append('params','{}');
const r = await fetch('/api/blade-task-create.php', {method:'POST', body:fd});
const d = await r.json();
return {status: r.status, ok: r.ok, body: d};
} catch(e) {
return {error: e.message};
}
}""")
print("Direct fetch result:", json.dumps(direct_result, indent=2))
# Now test the function
fn_result = await page.evaluate("""async () => {
try {
if (typeof pushBladeTask !== 'function') return {error: 'pushBladeTask not defined'};
await pushBladeTask('v112_via_fn', {});
await new Promise(r => setTimeout(r, 2000));
const log = document.getElementById('blade-log');
return {
log_exists: !!log,
log_display: log ? log.style.display : null,
log_text: log ? log.textContent.trim() : null
};
} catch(e) {
return {error: e.message};
}
}""")
print("\npushBladeTask() result:", json.dumps(fn_result, indent=2))
# Click a button
office_btn = await page.query_selector('button[onclick*="office_create"]')
if office_btn:
await office_btn.click()
await page.wait_for_timeout(2500)
after_click = await page.evaluate("""() => {
const log = document.getElementById('blade-log');
return {
log_display: log ? log.style.display : null,
log_html: log ? log.innerHTML.substring(0,300) : null,
log_text: log ? log.textContent.substring(0,300) : null
};
}""")
print("\nAfter Office Create click:", json.dumps(after_click, indent=2))
await page.screenshot(path=f"{OUT}/debug.png", full_page=True)
await context.close()
await browser.close()
print("\n=== Console messages:")
for m in console_msgs[:20]:
print(" ", m)
report = {
'direct_fetch': direct_result,
'fn_call': fn_result,
'after_click': after_click,
'console': console_msgs
}
with open(f"{OUT}/debug.json",'w') as f:
json.dump(report, f, indent=2)
asyncio.run(main())