From cb1c6cef3b6aeb16a99e5e64853eeb481be90379 Mon Sep 17 00:00:00 2001 From: ff Date: Sun, 7 Jun 2026 00:33:15 -0400 Subject: [PATCH] fix: click tooth dropdown chevron button to open 1-32 listbox, then select by number Instead of typing into the combobox, find the toggle button ("^" icon) in the same container as the tooth input and click it via JS to open the dropdown. Tries progressively wider ancestor scopes (1-5 levels up) to locate the button, falls back to JS focus if none found. Then selects the exact tooth number from the listbox options. Co-Authored-By: Claude Sonnet 4.6 --- .../selenium_DDMA_claimSubmitWorker.py | 35 ++++++++++++++++--- 1 file changed, 30 insertions(+), 5 deletions(-) diff --git a/apps/SeleniumService/selenium_DDMA_claimSubmitWorker.py b/apps/SeleniumService/selenium_DDMA_claimSubmitWorker.py index c136140a..931bbce4 100644 --- a/apps/SeleniumService/selenium_DDMA_claimSubmitWorker.py +++ b/apps/SeleniumService/selenium_DDMA_claimSubmitWorker.py @@ -702,11 +702,36 @@ class AutomationDDMAClaimSubmit: ti = tooth_inputs[idx] self.driver.execute_script("arguments[0].scrollIntoView({block:'center'});", ti) time.sleep(0.3) - # Open the dropdown via JS focus (avoids element-not-interactable on click) - self.driver.execute_script("arguments[0].focus();", ti) - time.sleep(0.5) - # Select the option matching the tooth number from the 1-32 dropdown listbox_id = ti.get_attribute("aria-controls") or "" + + # Click the "^" chevron toggle button to open the dropdown. + # It lives in the same container as the tooth input — + # try progressively wider ancestor scopes. + toggle_clicked = False + for ancestor_steps in range(1, 6): + ancestor_axis = "/".join([".."] * ancestor_steps) + toggle_xpath = ( + f"//input[@aria-label='Tooth'][{idx+1}]" + f"/{ancestor_axis}//button" + ) + toggles = self.driver.find_elements(By.XPATH, toggle_xpath) + if toggles: + try: + self.driver.execute_script("arguments[0].click();", toggles[0]) + print(f"[DDMA Claim step4] tooth[{idx}]: clicked toggle btn (ancestor depth {ancestor_steps})") + toggle_clicked = True + break + except Exception: + continue + + if not toggle_clicked: + # Fallback: JS focus the input to open the combobox + self.driver.execute_script("arguments[0].focus();", ti) + print(f"[DDMA Claim step4] tooth[{idx}]: no toggle btn found, used JS focus") + + time.sleep(0.5) + + # Select the matching tooth number from the 1-32 listbox try: if listbox_id: option = WebDriverWait(self.driver, 5).until( @@ -723,7 +748,7 @@ class AutomationDDMAClaimSubmit: option.click() print(f"[DDMA Claim step4] tooth[{idx}]: selected '{tooth}' from dropdown") except TimeoutException: - print(f"[DDMA Claim step4] tooth[{idx}]: dropdown not found, skipping") + print(f"[DDMA Claim step4] tooth[{idx}]: option '{tooth}' not found in dropdown") time.sleep(0.3) except Exception as e: print(f"[DDMA Claim step4] Could not fill tooth: {e}")