feat(adaptive): relocate stale @refs by AX fingerprint similarity
Borrow Scrapling's adaptive element finding, adapted to this project's in-session AX-ref model. When a saved @ref's node is gone (or its identity no longer matches) and the role/name/nth re-query also fails, score the current page's candidate elements against an AX fingerprint captured at snapshot time and relocate to the best match. - New `adaptive` module: pure, browser-free scoring (role, accessible name via Levenshtein, AX properties, ancestor-role LCS, parent/sibling) plus pick_best with a high absolute threshold (0.70) AND a clear margin (0.15) over the runner-up — so ambiguous twins are refused rather than mis-clicked, matching the existing "fail loudly over wrong click" posture. - Fingerprint captured during the existing AX-tree snapshot walk — no extra CDP round-trips. TreeNode is AX-only (no DOM tag/attrs), so we use AX role as the type and a few discriminating AX properties (value/url/level/checked); DOM id/class would have cost an N×describeNode storm per snapshot. - Wired into both resolve_element_center and resolve_element_object_id: on a verify-identity mismatch or a stale-node fallback miss, relocation is tried before erroring. A confident match overrides the identity guard; otherwise the original error is surfaced. Opt out with AGENT_BROWSER_ADAPTIVE_REF=0. README documents the new tuning knobs. Adds 9 unit tests; full suite 760 passed.
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
#[allow(dead_code)]
|
||||
pub mod actions;
|
||||
#[allow(dead_code)]
|
||||
pub mod adaptive;
|
||||
#[allow(dead_code)]
|
||||
pub mod auth;
|
||||
#[allow(dead_code)]
|
||||
pub mod browser;
|
||||
|
||||
Reference in New Issue
Block a user