diff --git a/apps/SeleniumService/selenium_DDMA_claimSubmitWorker.py b/apps/SeleniumService/selenium_DDMA_claimSubmitWorker.py
index 3069c6f7..6ef89123 100644
--- a/apps/SeleniumService/selenium_DDMA_claimSubmitWorker.py
+++ b/apps/SeleniumService/selenium_DDMA_claimSubmitWorker.py
@@ -526,7 +526,7 @@ class AutomationDDMAClaimSubmit:
if listbox_id:
option = WebDriverWait(self.driver, 4).until(
EC.element_to_be_clickable((By.XPATH,
- f"//*[@id='{listbox_id}']//*[@role='option'][1]"
+ f"(//*[@id='{listbox_id}']//*[@role='option' or self::li])[1]"
))
)
else:
@@ -539,7 +539,8 @@ class AutomationDDMAClaimSubmit:
option.click()
print(f"[DDMA Claim step4] {label}: selected '{value}'")
except TimeoutException:
- # No dropdown — press Enter or Tab to confirm free text
+ # No dropdown — close any suggestion list and Tab out to confirm free text
+ inp.send_keys(Keys.ESCAPE)
inp.send_keys(Keys.TAB)
print(f"[DDMA Claim step4] {label}: typed '{value}' (no dropdown)")
except Exception as e:
@@ -557,6 +558,72 @@ class AutomationDDMAClaimSubmit:
except Exception as e:
print(f"[DDMA Claim step4] Warning: could not fill {label}: {e}")
+ def _close_open_dropdowns(self):
+ """Close any open autocomplete/listbox (e.g. procedure code suggestions)."""
+ try:
+ self.driver.switch_to.active_element.send_keys(Keys.ESCAPE)
+ except Exception:
+ pass
+ try:
+ # Click a neutral spot (the Treatment Form heading area) to blur fields
+ self.driver.execute_script("document.activeElement && document.activeElement.blur();")
+ except Exception:
+ pass
+ time.sleep(0.3)
+
+ def _select_tooth(self, idx, tooth):
+ """Select tooth number in row idx.
+
+ DOM: ->
+ """
+ inp = WebDriverWait(self.driver, 8).until(
+ EC.presence_of_element_located((By.ID, f"ToothNumber{idx}_input"))
+ )
+ listbox_id = inp.get_attribute("aria-controls") or f"ToothNumber{idx}-ul"
+ self.driver.execute_script("arguments[0].scrollIntoView({block:'center'});", inp)
+ time.sleep(0.2)
+
+ # Open the dropdown
+ try:
+ inp.click()
+ except Exception:
+ self.driver.execute_script("arguments[0].click();", inp)
+ time.sleep(0.4)
+ if (inp.get_attribute("aria-expanded") or "").lower() != "true":
+ self.driver.execute_script("arguments[0].click();", inp)
+ time.sleep(0.4)
+
+ # Find the option with exact text inside this row's listbox
+ opt_xpath = (
+ f"//*[@id='{listbox_id}']//*[(self::li or @role='option') and normalize-space(.)='{tooth}']"
+ )
+ option = None
+ end = time.time() + 5
+ while time.time() < end and option is None:
+ els = self.driver.find_elements(By.XPATH, opt_xpath)
+ if els:
+ option = els[0]
+ break
+ time.sleep(0.25)
+ if option is None:
+ self._close_open_dropdowns()
+ raise Exception(f"option '{tooth}' not found in #{listbox_id}")
+
+ # List is scrollable — bring the option into view inside it, then click
+ self.driver.execute_script("arguments[0].scrollIntoView({block:'nearest'});", option)
+ time.sleep(0.2)
+ try:
+ option.click()
+ except Exception:
+ self.driver.execute_script("arguments[0].click();", option)
+ time.sleep(0.3)
+
+ val = inp.get_attribute("value") or ""
+ if val.strip() != tooth:
+ print(f"[DDMA Claim step4] tooth[{idx}]: warning, field shows {val!r} after selecting '{tooth}'")
+ return True
+
def step4_fill_claim_form(self):
"""Fill each treatment row: service date, procedure code, tooth number, surface, amount.
@@ -624,26 +691,12 @@ class AutomationDDMAClaimSubmit:
print(f"[DDMA Claim step4] Could not fill procedure code[{idx}]: {e}")
time.sleep(0.2)
- # ── Tooth Number (custom scrollable dropdown, no native