diff --git a/apps/SeleniumService/selenium_UnitedDH_claimSubmitWorker.py b/apps/SeleniumService/selenium_UnitedDH_claimSubmitWorker.py index 21d4125f..c69d23d0 100644 --- a/apps/SeleniumService/selenium_UnitedDH_claimSubmitWorker.py +++ b/apps/SeleniumService/selenium_UnitedDH_claimSubmitWorker.py @@ -1096,11 +1096,16 @@ class AutomationUnitedDHClaimSubmit: print(f"[UnitedDH Claim] step7: Could not click caret (section may already be open): {e}") attached = 0 + seen_paths = set() for cf in self.claimFiles: relative_path = cf.get("filePath") or "" if not relative_path: print(f"[UnitedDH Claim] step7: Skipping file with no filePath: {cf}") continue + if relative_path in seen_paths: + print(f"[UnitedDH Claim] step7: Skipping duplicate file: {relative_path}") + continue + seen_paths.add(relative_path) abs_path = os.path.normpath(os.path.join(_BACKEND_CWD, relative_path.lstrip("/"))) if not os.path.isfile(abs_path): @@ -1113,6 +1118,10 @@ class AutomationUnitedDHClaimSubmit: EC.presence_of_element_located((By.XPATH, "//input[@type='file']")) ) self.driver.execute_script("arguments[0].removeAttribute('class');", file_input) + # The input is a multi-file input and chromedriver APPENDS on send_keys, + # so a leftover selection from the previous iteration re-uploads the + # earlier file (2 attachments became 3). Clear it first. + self.driver.execute_script("arguments[0].value = '';", file_input) file_input.send_keys(abs_path) WebDriverWait(self.driver, 60).until( EC.element_to_be_clickable((By.XPATH, diff --git a/apps/SeleniumService/selenium_UnitedDH_preAuthWorker.py b/apps/SeleniumService/selenium_UnitedDH_preAuthWorker.py index 5eb2092c..76e40f73 100644 --- a/apps/SeleniumService/selenium_UnitedDH_preAuthWorker.py +++ b/apps/SeleniumService/selenium_UnitedDH_preAuthWorker.py @@ -1035,11 +1035,16 @@ class AutomationUnitedDHPreAuth: print(f"[UnitedDH PreAuth] step7: Could not click caret (section may already be open): {e}") attached = 0 + seen_paths = set() for cf in self.claimFiles: relative_path = cf.get("filePath") or "" if not relative_path: print(f"[UnitedDH PreAuth] step7: Skipping file with no filePath: {cf}") continue + if relative_path in seen_paths: + print(f"[UnitedDH PreAuth] step7: Skipping duplicate file: {relative_path}") + continue + seen_paths.add(relative_path) abs_path = os.path.normpath(os.path.join(_BACKEND_CWD, relative_path.lstrip("/"))) if not os.path.isfile(abs_path): @@ -1052,6 +1057,10 @@ class AutomationUnitedDHPreAuth: EC.presence_of_element_located((By.XPATH, "//input[@type='file']")) ) self.driver.execute_script("arguments[0].removeAttribute('class');", file_input) + # The input is a multi-file input and chromedriver APPENDS on send_keys, + # so a leftover selection from the previous iteration re-uploads the + # earlier file (2 attachments became 3). Clear it first. + self.driver.execute_script("arguments[0].value = '';", file_input) file_input.send_keys(abs_path) WebDriverWait(self.driver, 60).until( EC.element_to_be_clickable((By.XPATH,