Update WEHAGO comparison data and tools
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
import json
|
||||
import os
|
||||
import sys
|
||||
import time
|
||||
|
||||
from selenium import webdriver
|
||||
from selenium.webdriver.chrome.options import Options
|
||||
from selenium.webdriver.common.by import By
|
||||
from selenium.webdriver.common.action_chains import ActionChains
|
||||
|
||||
|
||||
target = sys.argv[1] if len(sys.argv) > 1 else "110"
|
||||
options = Options()
|
||||
options.add_experimental_option("debuggerAddress", os.environ.get("WEHAGO_CHROME_DEBUGGER_ADDRESS", "127.0.0.1:9225"))
|
||||
driver = webdriver.Chrome(options=options)
|
||||
|
||||
clicked = None
|
||||
for el in driver.find_elements(By.XPATH, f"//*[normalize-space(.)='{target}']"):
|
||||
if not el.is_displayed():
|
||||
continue
|
||||
r = driver.execute_script("const r=arguments[0].getBoundingClientRect(); return {left:r.left, top:r.top, width:r.width, height:r.height};", el)
|
||||
if r["left"] < 220 and r["top"] > 145 and r["width"] > 0 and r["height"] > 0:
|
||||
clicked = r
|
||||
try:
|
||||
el.click()
|
||||
except Exception:
|
||||
ActionChains(driver).move_to_element(el).click(el).perform()
|
||||
break
|
||||
|
||||
time.sleep(1.0)
|
||||
right = driver.execute_script("const b=Array.from(document.querySelectorAll('.rg-body')).find(el=>String(el.$_view)==='327'); return b ? (b.textContent||'').slice(0,500) : '';")
|
||||
print(json.dumps({"clicked": clicked, "right": right}, ensure_ascii=False, indent=2))
|
||||
driver.quit()
|
||||
Reference in New Issue
Block a user