From 98ece6206eba056098f5e376a2d575f68044845a Mon Sep 17 00:00:00 2001 From: Nick Shirokov Date: Mon, 2 Mar 2026 19:03:34 +0300 Subject: [PATCH] fix(web-test): add startsWith matching to findClickTargetScript MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The button/link search in findClickTargetScript jumped from exact to includes matching, causing "Поступление" to match "Поступление билетов" instead of "Поступление (акты, накладные, УПД)" when the shorter name appeared first in DOM order. Add startsWith step for both name and label between exact and includes matching. Co-Authored-By: Claude Opus 4.6 --- .claude/skills/web-test/scripts/dom.mjs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.claude/skills/web-test/scripts/dom.mjs b/.claude/skills/web-test/scripts/dom.mjs index c7ce3908..dfb34376 100644 --- a/.claude/skills/web-test/scripts/dom.mjs +++ b/.claude/skills/web-test/scripts/dom.mjs @@ -561,9 +561,11 @@ export function findClickTargetScript(formNum, text) { items.push({ id: el.id, name: el.dataset.content, label: '', kind: 'tab' }); }); - // Fuzzy match: exact name -> exact label -> includes name -> includes label + // Fuzzy match: exact name -> exact label -> startsWith name -> startsWith label -> includes name -> includes label let found = items.find(i => i.name.toLowerCase() === target); if (!found) found = items.find(i => i.label && i.label.toLowerCase() === target); + if (!found) found = items.find(i => i.name.toLowerCase().startsWith(target)); + if (!found) found = items.find(i => i.label && i.label.toLowerCase().startsWith(target)); if (!found) found = items.find(i => i.name.toLowerCase().includes(target)); if (!found) found = items.find(i => i.label && i.label.toLowerCase().includes(target));