'How to Uplod a File using Selenium Webdriver using pycharm

enter image description hereWhen I am uploading a file in pycharm I'm getting the below error

here is my code line for uploading the file

upload_file = WebDriverWait(driver, 5).until(EC.element_to_be_clickable((By.XPATH, "//a[normalize-space()='browse']")))
upload_file.send_keys("C:\artifact\EWV100_1.27.0-rc1.download")

Here I am getting this error

[selenium.common.exceptions.ElementNotInteractableException: Message: element not interactable]


Solution 1:[1]

to upload a file using Selenium webdriver, if your web page has at least one web element with xpath //input[@type='file'] you can directly send the keys.

upload_file = WebDriverWait(driver, 5).until(EC.element_to_be_clickable((By.XPATH, "//input[@type='file']")))
upload_file.send_keys("C:\artifact\EWV100_1.27.0-rc1.download")

should get the job done.

PS: You shouldn't write a code to click on an upload button, the above code does upload the file without having a launched OS prompt.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 cruisepandey