How to upload files when testing using Selenium Webdriver

You can use the following code to set a file path to the file upload control.

WebElement file = driver.findElement("control_id"));

You need to pass full path to the sendKeys() for it to work. Otherwise sendKeys() fails silently.

comments powered by Disqus