Update WEHAGO comparison data and tools
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
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)
|
||||
driver.set_script_timeout(10)
|
||||
|
||||
script = r"""
|
||||
const g = window.Grids && window.Grids.realgrid;
|
||||
const safe = (fn) => {
|
||||
try { return fn(); } catch (e) { return {error: String(e)}; }
|
||||
};
|
||||
const out = {};
|
||||
out.current = safe(() => g && g.getCurrent && g.getCurrent());
|
||||
out.fullItemCount = safe(() => g && g.fullItemCount && g.fullItemCount());
|
||||
out.columns = safe(() => g && g.getColumns && g.getColumns().map(c => ({
|
||||
name: c.name || c.fieldName || c.field,
|
||||
fieldName: c.fieldName,
|
||||
header: c.header && (c.header.text || c.header)
|
||||
})).slice(0, 80));
|
||||
out.rows = [];
|
||||
if (g) {
|
||||
const n = Math.min(30, Number(out.fullItemCount) || 30);
|
||||
for (let i = 0; i < n; i += 1) {
|
||||
out.rows.push({
|
||||
item: i,
|
||||
dataRow: safe(() => g.getDataRow(i)),
|
||||
values: safe(() => g.getValues(i)),
|
||||
display: safe(() => g.getDisplayValuesOfRow ? g.getDisplayValuesOfRow(i) : g.getDisplayValues(i))
|
||||
});
|
||||
}
|
||||
}
|
||||
out.visibleText = Array.from(document.querySelectorAll('.rg-data-cell, td[class*=rg-data-cell], [class*=rg-data-cell], td'))
|
||||
.map(el => {
|
||||
const r = el.getBoundingClientRect();
|
||||
return {text: (el.textContent || '').trim(), left: Math.round(r.left), top: Math.round(r.top), width: Math.round(r.width), height: Math.round(r.height)};
|
||||
})
|
||||
.filter(x => x.text && x.width > 0 && x.height > 0 && x.top > 120)
|
||||
.slice(0, 120);
|
||||
return out;
|
||||
"""
|
||||
|
||||
print(json.dumps(driver.execute_script(script), ensure_ascii=False, indent=2)[:60000])
|
||||
driver.quit()
|
||||
Reference in New Issue
Block a user