admin管理员组

文章数量:1403493

I am trying to automate a file upload using selenium module in Python, I am able to click the "Attach" button and upload file from absolute path but getting error as file upload is not finished yet. Here is code example and errors , though same code is working fine when I am running in debug mode.

Code Snippet :

file_input = WebDriverWait(driver, 10).until(
                ec.presence_of_element_located((By.ID, "fileToUpload"))
            )
# Path to the file you want to upload
file_path = "C:/user/file.pdf"
print(file_path)
# Send the file path to the input element
file_input.send_keys(file_path)

time.sleep(10)

Attach Button :

Error :

Failing while loading this progress bar : 

Is there any way I can put a wait in send_keys itself rather than later on while file is getting uploaded ?

本文标签: Python Selenium sendkeys is not waiting for file to be uploadedStack Overflow