33 lines
1.0 KiB
Python
33 lines
1.0 KiB
Python
"""Debug: capture all console output and errors."""
|
|
from playwright.sync_api import sync_playwright
|
|
|
|
with sync_playwright() as p:
|
|
browser = p.chromium.launch(headless=True)
|
|
page = browser.new_page(viewport={"width": 1920, "height": 1080})
|
|
|
|
logs = []
|
|
page.on("console", lambda msg: logs.append(f"[{msg.type}] {msg.text}"))
|
|
page.on("pageerror", lambda err: logs.append(f"[PAGE_ERROR] {err}"))
|
|
|
|
page.goto("http://localhost:5173/", wait_until="networkidle")
|
|
page.wait_for_timeout(5000)
|
|
|
|
print(f"URL: {page.url}")
|
|
|
|
# Get all console logs
|
|
print(f"\nAll console logs ({len(logs)}):")
|
|
for log in logs:
|
|
print(f" {log}")
|
|
|
|
# Try to get page errors from window.onerror
|
|
errors = page.evaluate("""() => {
|
|
const el = document.getElementById('root');
|
|
return {
|
|
rootContent: el ? el.innerHTML.substring(0, 500) : 'no root',
|
|
rootChildren: el ? el.children.length : 0,
|
|
}
|
|
}""")
|
|
print(f"\nRoot element: {errors}")
|
|
|
|
browser.close()
|