From 72b204f33f26944f1771551819d240d2925acff9 Mon Sep 17 00:00:00 2001 From: ff Date: Fri, 29 May 2026 18:10:45 -0400 Subject: [PATCH] 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 --- .../selenium_UnitedDH_claimSubmitWorker.py | 71 +++++++++++++------ 1 file changed, 51 insertions(+), 20 deletions(-) diff --git a/apps/SeleniumService/selenium_UnitedDH_claimSubmitWorker.py b/apps/SeleniumService/selenium_UnitedDH_claimSubmitWorker.py index 0300d0b3..0c853232 100644 --- a/apps/SeleniumService/selenium_UnitedDH_claimSubmitWorker.py +++ b/apps/SeleniumService/selenium_UnitedDH_claimSubmitWorker.py @@ -640,42 +640,73 @@ class AutomationUnitedDHClaimSubmit: try: print("[UnitedDH Claim] step3: waiting for Practitioner & Location page") - # Wait for the Continue button to appear (page has loaded) - continue_btn = WebDriverWait(self.driver, 15).until( - EC.element_to_be_clickable((By.XPATH, - "//button[contains(@class,'btn-primary') and contains(normalize-space(text()),'Continue')]" - )) + # Wait for the Billing Entity label to be visible — confirms page has fully rendered + WebDriverWait(self.driver, 20).until( + EC.visibility_of_element_located((By.XPATH, "//label[@for='paymentGroupId']")) ) - # Select Treatment Location (first dropdown) — page auto-fills Billing Entity and rest + # --- Treatment Location --- print("[UnitedDH Claim] step3: Selecting Treatment Location...") location_selected = False try: - location_ng = self.driver.find_element(By.XPATH, - "//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( + location_ng = WebDriverWait(self.driver, 10).until( 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() - first_option.click() + self.driver.execute_script("arguments[0].scrollIntoView({block:'end'});", location_ng) + 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}") location_selected = True - time.sleep(1) # wait for page to auto-fill remaining fields except Exception as e: print(f"[UnitedDH Claim] step3: Treatment Location selection failed: {e}") if not location_selected: 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) continue_btn.click() print("[UnitedDH Claim] step3: Clicked Continue — waiting for Code Entry page")