Upload files with selenium webdriver

  • 1 Replies
Upload files with selenium webdriver
« on: April 03, 2016, 18:08:33 pm »
Is it possible to upload files in the process of an automated test ?

Re: Upload files with selenium webdriver
« Reply #1 on: April 04, 2016, 15:45:57 pm »
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")

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"));


Sitemap 1 2 3 4 5 6 7 8