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}")