From 76bd99f7ff344cbb25ffff6659c7c059f55037d9 Mon Sep 17 00:00:00 2001 From: Gitead Date: Wed, 29 Jul 2026 23:57:39 -0400 Subject: [PATCH] =?UTF-8?q?fix:=20Tufts=20SCO=20claim=20file=20attach=20?= =?UTF-8?q?=E2=80=94=20send=5Fkeys=20directly,=20skip=20button=20click?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Clicking "Add a file" triggers input.click() which opens the OS-native file picker that WebDriver can't control, causing send_keys on the underlying input to fail with a message-less exception. The input is already present in the DOM (display:none) so send_keys can target it directly without the click. --- .../selenium_TuftsSCO_claimSubmitWorker.py | 21 +++++++------------ 1 file changed, 7 insertions(+), 14 deletions(-) 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"