TestProject Forum
Powered by leading experts in the test automation community

Upload files with selenium webdriver

Is it possible to upload files in the process of an automated test ?

Yes it is possible.

If the file is on a local machine (or a mapped network drive), just type the path to the file into the file upload control.
For example:

driver = webdriver.Firefox() element = driver.find_element_by_id("Upload") element.send_keys("C:\file.txt")

For RemoteWebDriver,
In order to enable the transfer of the file from your local machine to the remote machine so it can be uploaded, you need to set a File Detector:

driver.setFileDetector(new LocalFileDetector()); WebElement upload = driver.findElement(By.id("myfile")); upload.sendKeys("/Users/sso/path/file.txt");