diff --git a/apps/SeleniumService/selenium_TuftsSCO_claimSubmitWorker.py b/apps/SeleniumService/selenium_TuftsSCO_claimSubmitWorker.py index 5f50f21a..70a93a9f 100644 --- a/apps/SeleniumService/selenium_TuftsSCO_claimSubmitWorker.py +++ b/apps/SeleniumService/selenium_TuftsSCO_claimSubmitWorker.py @@ -752,27 +752,20 @@ class AutomationTuftsSCOClaimSubmit: print(f"[TuftsSCO Claim step5] Attaching: {abs_path}") try: - add_file_btn = WebDriverWait(self.driver, 10).until( - EC.element_to_be_clickable((By.XPATH, - "//button[.//span[contains(text(),'Add a file')]] | " - "//button[contains(normalize-space(text()),'Add a file')] | " - "//*[contains(text(),'Add a file') and (@role='button' or self::label)]" - )) - ) - self.driver.execute_script("arguments[0].scrollIntoView({block:'center'});", add_file_btn) - ActionChains(self.driver).move_to_element(add_file_btn).click().perform() - time.sleep(1) - - file_input = WebDriverWait(self.driver, 8).until( + # Don't click the "Add a file" button: it's wired to the hidden + # below, and clicking it triggers the OS-native + # file picker, which WebDriver cannot control. Send the path + # directly to the input instead (chromedriver allows send_keys on + # file inputs even while display:none). + file_input = WebDriverWait(self.driver, 10).until( EC.presence_of_element_located((By.XPATH, "//input[@type='file']")) ) - self.driver.execute_script("arguments[0].style.display='block';", file_input) file_input.send_keys(abs_path) time.sleep(1.5) print(f"[TuftsSCO Claim step5] Attached: {os.path.basename(abs_path)}") attached += 1 except Exception as e: - print(f"[TuftsSCO Claim step5] Could not attach {abs_path}: {e}") + print(f"[TuftsSCO Claim step5] Could not attach {abs_path}: {type(e).__name__}: {e}") print(f"[TuftsSCO Claim step5] Attached {attached}/{len(self.claimFiles)} file(s)") return "SUCCESS"