import json import os from selenium import webdriver from selenium.webdriver.chrome.options import Options options = Options() options.add_experimental_option("debuggerAddress", os.environ.get("WEHAGO_CHROME_DEBUGGER_ADDRESS", "127.0.0.1:9225")) driver = webdriver.Chrome(options=options) script = r""" const items = []; for (const el of document.querySelectorAll('input, textarea, select, button, [role=button], a')) { const r = el.getBoundingClientRect(); const style = getComputedStyle(el); if (r.width <= 0 || r.height <= 0 || style.display === 'none' || style.visibility === 'hidden') continue; items.push({ tag: el.tagName, type: el.getAttribute('type'), text: (el.textContent || '').trim(), value: el.value || '', placeholder: el.getAttribute('placeholder') || '', title: el.getAttribute('title') || '', aria: el.getAttribute('aria-label') || '', name: el.getAttribute('name') || '', id: el.id || '', cls: String(el.className || '').slice(0, 120), left: Math.round(r.left), top: Math.round(r.top), width: Math.round(r.width), height: Math.round(r.height) }); } return items.sort((a,b)=>(a.top-b.top)||(a.left-b.left)); """ print(json.dumps(driver.execute_script(script), ensure_ascii=False, indent=2)[:50000]) driver.quit()