fix: apply Treatment Location + Billing Entity selection to United SCO claim worker

Mirrors the same Provider & Location page pattern from the eligibility worker:
- wait for paymentGroupId label visibility before interacting
- Treatment Location: ng-arrow-wrapper click + ARROW_DOWN/ENTER
- Billing Entity: ng-arrow-wrapper click + ARROW_DOWN/ENTER
- re-find Continue button after selections to avoid stale element

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
ff
2026-05-29 18:10:45 -04:00
parent c952f79853
commit 72b204f33f

View File

@@ -640,42 +640,73 @@ class AutomationUnitedDHClaimSubmit:
try: try:
print("[UnitedDH Claim] step3: waiting for Practitioner & Location page") print("[UnitedDH Claim] step3: waiting for Practitioner & Location page")
# Wait for the Continue button to appear (page has loaded) # Wait for the Billing Entity label to be visible — confirms page has fully rendered
continue_btn = WebDriverWait(self.driver, 15).until( WebDriverWait(self.driver, 20).until(
EC.element_to_be_clickable((By.XPATH, EC.visibility_of_element_located((By.XPATH, "//label[@for='paymentGroupId']"))
"//button[contains(@class,'btn-primary') and contains(normalize-space(text()),'Continue')]"
))
) )
# Select Treatment Location (first dropdown) — page auto-fills Billing Entity and rest # --- Treatment Location ---
print("[UnitedDH Claim] step3: Selecting Treatment Location...") print("[UnitedDH Claim] step3: Selecting Treatment Location...")
location_selected = False location_selected = False
try: try:
location_ng = self.driver.find_element(By.XPATH, location_ng = WebDriverWait(self.driver, 10).until(
"//label[contains(text(),'Treatment Location') or contains(text(),'treatment location')]"
"/..//ng-select | "
"(//ng-select)[1]"
)
self.driver.execute_script("arguments[0].scrollIntoView({block:'center'});", location_ng)
time.sleep(0.3)
location_ng.click()
time.sleep(1)
first_option = WebDriverWait(self.driver, 5).until(
EC.element_to_be_clickable((By.XPATH, EC.element_to_be_clickable((By.XPATH,
"//ng-dropdown-panel//div[contains(@class,'ng-option') and not(contains(@class,'disabled'))]" "//label[@for='treatmentLocation']/following-sibling::ng-select | "
"//label[@for='treatmentLocation']/..//ng-select"
)) ))
) )
option_text = first_option.text.strip() self.driver.execute_script("arguments[0].scrollIntoView({block:'end'});", location_ng)
first_option.click() arrow = location_ng.find_element(By.XPATH, ".//span[contains(@class,'ng-arrow-wrapper')]")
ActionChains(self.driver).move_to_element(arrow).click().perform()
WebDriverWait(self.driver, 10).until(
EC.presence_of_element_located((By.XPATH, "//ng-dropdown-panel"))
)
option_text = self.driver.find_element(By.XPATH,
"//ng-dropdown-panel//div[contains(@class,'ng-option') and not(contains(@class,'disabled'))]"
).text.strip()
ActionChains(self.driver).send_keys(Keys.ARROW_DOWN).send_keys(Keys.ENTER).perform()
print(f"[UnitedDH Claim] step3: Selected Treatment Location: {option_text}") print(f"[UnitedDH Claim] step3: Selected Treatment Location: {option_text}")
location_selected = True location_selected = True
time.sleep(1) # wait for page to auto-fill remaining fields
except Exception as e: except Exception as e:
print(f"[UnitedDH Claim] step3: Treatment Location selection failed: {e}") print(f"[UnitedDH Claim] step3: Treatment Location selection failed: {e}")
if not location_selected: if not location_selected:
print("[UnitedDH Claim] step3: WARNING: Could not select Treatment Location — continuing anyway") print("[UnitedDH Claim] step3: WARNING: Could not select Treatment Location — continuing anyway")
# --- Billing Entity ---
print("[UnitedDH Claim] step3: Selecting Billing Entity...")
billing_selected = False
try:
billing_ng = WebDriverWait(self.driver, 10).until(
EC.element_to_be_clickable((By.XPATH,
"//label[@for='paymentGroupId']/following-sibling::ng-select | "
"//label[@for='paymentGroupId']/..//ng-select"
))
)
self.driver.execute_script("arguments[0].scrollIntoView({block:'end'});", billing_ng)
arrow = billing_ng.find_element(By.XPATH, ".//span[contains(@class,'ng-arrow-wrapper')]")
ActionChains(self.driver).move_to_element(arrow).click().perform()
WebDriverWait(self.driver, 10).until(
EC.presence_of_element_located((By.XPATH, "//ng-dropdown-panel"))
)
option_text = self.driver.find_element(By.XPATH,
"//ng-dropdown-panel//div[contains(@class,'ng-option') and not(contains(@class,'disabled'))]"
).text.strip()
ActionChains(self.driver).send_keys(Keys.ARROW_DOWN).send_keys(Keys.ENTER).perform()
print(f"[UnitedDH Claim] step3: Selected Billing Entity: {option_text}")
billing_selected = True
except Exception as e:
print(f"[UnitedDH Claim] step3: Billing Entity selection failed: {e}")
if not billing_selected:
print("[UnitedDH Claim] step3: WARNING: Could not select Billing Entity — continuing anyway")
# Re-find Continue button after selections to avoid stale element reference
continue_btn = WebDriverWait(self.driver, 10).until(
EC.element_to_be_clickable((By.XPATH,
"//button[contains(@class,'btn-primary') and contains(normalize-space(text()),'Continue')]"
))
)
self.driver.execute_script("arguments[0].scrollIntoView({block:'center'});", continue_btn) self.driver.execute_script("arguments[0].scrollIntoView({block:'center'});", continue_btn)
continue_btn.click() continue_btn.click()
print("[UnitedDH Claim] step3: Clicked Continue — waiting for Code Entry page") print("[UnitedDH Claim] step3: Clicked Continue — waiting for Code Entry page")