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 <noreply@anthropic.com>
This commit is contained in:
ff
2026-06-07 00:33:15 -04:00
parent 730c41f9b0
commit cb1c6cef3b

View File

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