Selenium WebDriver how to to handle input delay when automating file uploads on Firefox 115
I tried several approaches but none seem to work... I'm not sure how to approach I'm relatively new to this, so bear with me. I'm working with an scenario with Selenium WebDriver where it seems to struggle with file uploads in Firefox version 115. Specifically, when I try to upload a file using an `<input type='file'>` element, the file dialog opens, but the file path isn't being set correctly due to a delayed response from the file input. I'm using the following code snippet to handle the upload: ```python from selenium import webdriver from selenium.webdriver.common.by import By import time # Initialize WebDriver for Firefox options = webdriver.FirefoxOptions() options.add_argument('--headless') # Run headless driver = webdriver.Firefox(options=options) # Navigate to the page with the file upload driver.get('http://example.com/upload') # Find the file input element file_input = driver.find_element(By.CSS_SELECTOR, 'input[type="file"]') # Attempt to send the file path file_input.send_keys('/path/to/myfile.txt') # Wait a moment (not the best practice) time.sleep(3) # Click the submit button submit_button = driver.find_element(By.ID, 'submit') submit_button.click() ``` I've ensured that the path is correct and that the file exists, but the behavior message I receive is `InvalidArgumentException: invalid argument`. I've tried adding an explicit wait before sending the keys, but it doesn't seem to help. ```python from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support import expected_conditions as EC # Use WebDriverWait wait = WebDriverWait(driver, 10) file_input = wait.until(EC.presence_of_element_located((By.CSS_SELECTOR, 'input[type="file"]'))) file_input.send_keys('/path/to/myfile.txt') ``` Despite these attempts, the scenario continues. Could there be additional configuration needed for Firefox, or are there any known workarounds for handling file uploads more reliably in this version? Any insights would be greatly appreciated! For reference, this is a production microservice. Thanks for any help you can provide! I'm developing on CentOS with Python. How would you solve this?