fix: Tufts SCO claim combobox selects matching option instead of first

_fill_combobox typed the value then used a single unioned XPath
(match-by-text | option[1]) to pick the dropdown option. Selenium's
find_element on a multi-match XPath returns the first node in
document order, not the first union alternative, so option[1] (e.g.
tooth "1") was always clicked regardless of what was typed (e.g. "22").
Split into a value-match wait with a separate fallback wait for
option[1] only when no match is found.
This commit is contained in:
2026-07-29 23:19:18 -04:00
parent 6d0838446b
commit 44c6d2f833

View File

@@ -552,18 +552,18 @@ class AutomationTuftsSCOClaimSubmit:
inp.send_keys(str(value))
time.sleep(0.5)
listbox_id = inp.get_attribute("aria-controls") or ""
scope = f"//*[@id='{listbox_id}']" if listbox_id else "//*[@role='listbox']"
try:
if listbox_id:
try:
option = WebDriverWait(self.driver, 4).until(
EC.element_to_be_clickable((By.XPATH,
f"//*[@id='{listbox_id}']//*[@role='option'][1]"
f"{scope}//*[@role='option' and contains(normalize-space(.),'{value}')]"
))
)
else:
option = WebDriverWait(self.driver, 4).until(
except TimeoutException:
option = WebDriverWait(self.driver, 2).until(
EC.element_to_be_clickable((By.XPATH,
f"//*[@role='listbox']//*[@role='option' and contains(normalize-space(.),'{value}')]"
f" | //*[@role='listbox']//*[@role='option'][1]"
f"{scope}//*[@role='option'][1]"
))
)
option.click()