From 328cb60f18ba3f8fca75005f34e8ecb942c936d6 Mon Sep 17 00:00:00 2001 From: Nick Shirokov Date: Sat, 28 Feb 2026 11:46:10 +0300 Subject: [PATCH] fix(web-test): strict search input detection in selection forms MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Selection forms without a search field (e.g. ERP Соглашения) have only filter fields like ТипСоглашения. The old code fell back to inputs[0], typing the search text into the filter field and breaking the form. Now pickFromSelectionForm only uses inputs whose ID matches known search field patterns (поиск/search/строкапоиска/SearchString/find). When no search input is found, it skips text entry and matches rows directly in the grid — which works because the target value is visible among the rows. Co-Authored-By: Claude Opus 4.6 --- .claude/skills/web-test/scripts/browser.mjs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/.claude/skills/web-test/scripts/browser.mjs b/.claude/skills/web-test/scripts/browser.mjs index 6987e762..457acd23 100644 --- a/.claude/skills/web-test/scripts/browser.mjs +++ b/.claude/skills/web-test/scripts/browser.mjs @@ -348,15 +348,14 @@ export async function readTable({ maxRows = 20, offset = 0 } = {}) { * @returns {{ field, ok, method }} or {{ field, error, message }} */ async function pickFromSelectionForm(selFormNum, fieldName, text, origFormNum) { - // 1. Find search input in the selection form + // 1. Find search input in the selection form (strict — only named search fields, + // do NOT fall back to first input — it may be a filter field like ТипСоглашения) const searchInputId = await page.evaluate(`(() => { const p = 'form${selFormNum}_'; const inputs = [...document.querySelectorAll('input.editInput[id^="' + p + '"]')].filter(el => el.offsetWidth > 0); - // Prefer field with "search"/"поиск" in its ID - let searchInput = inputs.find(el => /поиск|search|строкапоиска|find/i.test(el.id)); - if (!searchInput && inputs.length > 0) searchInput = inputs[0]; + const searchInput = inputs.find(el => /поиск|search|строкапоиска|SearchString|find/i.test(el.id)); return searchInput ? searchInput.id : null; - })()`); + })()`) // 2. Fill search field via clipboard paste (more reliable than page.fill for 1C) if (searchInputId && text) {