brad-did-something / tests /probe_layout.py
qFelix's picture
Brad Did Something - Gradio/FastAPI Space on HF
78c0f6e
Raw
History Blame Contribute Delete
1.24 kB
"""Scan the row to find what's painting the dark left block."""
import json
import time
from playwright.sync_api import sync_playwright
JS = """() => {
const out = [];
for (let x = 20; x < 1400; x += 120) {
const el = document.elementFromPoint(x, 450);
out.push({x, el: el ? (el.id || el.className || el.tagName) : null,
bg: el ? getComputedStyle(el).backgroundColor : null});
}
const stage = document.getElementById('stage');
const sb = stage.getBoundingClientRect();
return { scan: out,
stage: {x:Math.round(sb.x), right:Math.round(sb.right), top:Math.round(sb.top), bottom:Math.round(sb.bottom)},
frameChildren: [...document.getElementById('frame').children].map(c => {
const b = c.getBoundingClientRect();
return {id:c.id, x:Math.round(b.x), w:Math.round(b.width), bg:getComputedStyle(c).backgroundColor};
}) };
}"""
with sync_playwright() as pw:
b = pw.chromium.launch()
page = b.new_page(viewport={"width": 1911, "height": 860})
page.goto("http://localhost:7861/game", wait_until="networkidle")
page.click("#btn-start")
page.wait_for_selector("#hud", state="visible")
time.sleep(1.2)
print(json.dumps(page.evaluate(JS), indent=1))
b.close()