From 44c6d2f833ad4960a181d104285e3b6d5e62ff75 Mon Sep 17 00:00:00 2001 From: Gitead Date: Wed, 29 Jul 2026 23:19:18 -0400 Subject: [PATCH] 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. --- .../selenium_TuftsSCO_claimSubmitWorker.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/apps/SeleniumService/selenium_TuftsSCO_claimSubmitWorker.py b/apps/SeleniumService/selenium_TuftsSCO_claimSubmitWorker.py index 195d3799..5f50f21a 100644 --- a/apps/SeleniumService/selenium_TuftsSCO_claimSubmitWorker.py +++ b/apps/SeleniumService/selenium_TuftsSCO_claimSubmitWorker.py @@ -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()