Update WEHAGO comparison data and tools
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
import json
|
||||
import os
|
||||
import sys
|
||||
import time
|
||||
|
||||
from selenium import webdriver
|
||||
from selenium.webdriver.chrome.options import Options
|
||||
|
||||
|
||||
target = sys.argv[1] if len(sys.argv) > 1 else "110"
|
||||
mode = sys.argv[2] if len(sys.argv) > 2 else "name-double"
|
||||
options = Options()
|
||||
options.add_experimental_option("debuggerAddress", os.environ.get("WEHAGO_CHROME_DEBUGGER_ADDRESS", "127.0.0.1:9225"))
|
||||
driver = webdriver.Chrome(options=options)
|
||||
|
||||
result = driver.execute_script(
|
||||
r"""
|
||||
const code = arguments[0], mode = arguments[1];
|
||||
const cells = Array.from(document.querySelectorAll('.rg-data-cell, td[class*=rg-data-cell], [class*=rg-data-cell], td'));
|
||||
const codeCell = cells.find(cell => {
|
||||
const r = cell.getBoundingClientRect();
|
||||
return (cell.textContent || '').trim() === code && r.left < 220 && r.top > 145 && r.width > 0 && r.height > 0;
|
||||
});
|
||||
if (!codeCell) return {error:'code not visible'};
|
||||
const cr = codeCell.getBoundingClientRect();
|
||||
const nameCell = cells.find(cell => {
|
||||
const r = cell.getBoundingClientRect();
|
||||
return Math.abs(r.top - cr.top) < 3 && r.left > 180 && r.left < 360 && r.width > 0 && r.height > 0;
|
||||
});
|
||||
const targetEl = mode.includes('name') && nameCell ? nameCell : codeCell;
|
||||
const r = targetEl.getBoundingClientRect();
|
||||
const x = r.left + (mode.includes('left') ? 8 : r.width / 2);
|
||||
const y = r.top + r.height / 2;
|
||||
const send = (type, detail=1) => {
|
||||
targetEl.dispatchEvent(new MouseEvent(type, {bubbles:true,cancelable:true,view:window,clientX:x,clientY:y,button:0,detail}));
|
||||
};
|
||||
const seq = ['mouseover','mousemove','mousedown','mouseup','click'];
|
||||
for (const type of seq) send(type, 1);
|
||||
if (mode.includes('double')) {
|
||||
for (const type of ['mousedown','mouseup','click','dblclick']) send(type, 2);
|
||||
}
|
||||
return {clicked: code, mode, x, y, codeTop: cr.top, nameText: nameCell && nameCell.textContent};
|
||||
""",
|
||||
target,
|
||||
mode,
|
||||
)
|
||||
time.sleep(1.0)
|
||||
right = driver.execute_script(
|
||||
r"""
|
||||
const body = Array.from(document.querySelectorAll('.rg-body')).find(el => String(el.$_view) === '327');
|
||||
return body ? (body.textContent || '').slice(0, 500) : '';
|
||||
"""
|
||||
)
|
||||
print(json.dumps({"result": result, "right": right}, ensure_ascii=False, indent=2))
|
||||
driver.quit()
|
||||
Reference in New Issue
Block a user