Update WEHAGO comparison data and tools
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
import json
|
||||
import os
|
||||
import time
|
||||
|
||||
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)
|
||||
|
||||
for typ in ["mouseMoved", "mousePressed", "mouseReleased"]:
|
||||
driver.execute_cdp_cmd(
|
||||
"Input.dispatchMouseEvent",
|
||||
{"type": typ, "x": 130, "y": 188, "button": "left" if typ != "mouseMoved" else "none", "clickCount": 1},
|
||||
)
|
||||
time.sleep(0.8)
|
||||
items = driver.execute_script(
|
||||
r"""
|
||||
return Array.from(document.querySelectorAll('input,button,[role=button],a,div')).map(el=>{
|
||||
const r=el.getBoundingClientRect(); const st=getComputedStyle(el);
|
||||
return {tag:el.tagName,id:el.id||'',cls:String(el.className||'').slice(0,80),text:(el.textContent||'').trim().slice(0,80),value:el.value||'',placeholder:el.getAttribute('placeholder')||'',title:el.getAttribute('title')||'',left:Math.round(r.left),top:Math.round(r.top),width:Math.round(r.width),height:Math.round(r.height),display:st.display,vis:st.visibility};
|
||||
}).filter(x=>x.width>0&&x.height>0&&x.display!=='none'&&x.vis!=='hidden'&&x.top<400&&x.left<700).sort((a,b)=>(a.top-b.top)||(a.left-b.left)).slice(0,200);
|
||||
"""
|
||||
)
|
||||
print(json.dumps(items, ensure_ascii=False, indent=2))
|
||||
driver.quit()
|
||||
Reference in New Issue
Block a user