Skip to content

Commit e396d05

Browse files
mcherifclaude
andcommitted
Fix school combobox: use activeElement not last visible input
Using .last on input:visible picked unrelated form fields (name/email). After clicking a combobox, the browser focuses the inner search input — use document.activeElement to target it precisely, then fall through to the fallback-terms logic ("British Columbia", "Columbia", etc.). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 30bd196 commit e396d05

1 file changed

Lines changed: 8 additions & 5 deletions

File tree

utils/form_filler.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1956,13 +1956,16 @@ def _query_opts(listbox_id: str) -> str:
19561956

19571957
# Some comboboxes are div/button wrappers (is_input=False) that reveal an
19581958
# inner <input> search field when opened (e.g. Greenhouse school selector).
1959-
# When no options appeared after clicking, try to find and type into that
1960-
# inner input — then fall through to the normal fallback-terms logic.
1959+
# After clicking, focus moves to that inner input — use document.activeElement
1960+
# rather than a broad visible-input scan to avoid typing into unrelated fields.
19611961
if not opts and not is_input:
19621962
try:
1963-
inner = page.locator("input[type='search']:visible, input[type='text']:visible").last
1964-
if await inner.count() > 0 and await inner.is_visible(timeout=1000):
1965-
el = inner
1963+
active = await page.evaluate(
1964+
"() => { const a = document.activeElement; "
1965+
"return a ? {tag: a.tagName.toLowerCase(), itype: (a.type||'').toLowerCase()} : {}; }"
1966+
)
1967+
if active.get("tag") == "input" and active.get("itype", "text") in ("text", "search", ""):
1968+
el = page.locator(":focus")
19661969
is_input = True
19671970
await el.fill(value)
19681971
await asyncio.sleep(0.5)

0 commit comments

Comments
 (0)