[Python] Python Selenium send_keys is not waiting for file to be uploaded

Discussão em 'Python' iniciado por Stack, Março 21, 2025.

  1. Stack

    Stack Membro Participativo

    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 ?

    Continue reading...

Compartilhe esta Página