Software Quality Assurance & Testing Stack Exchange is a question and answer site for software quality control experts, automation engineers, and software testers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

This question already has an answer here:

Using Selenium webdriver with chrome browser for automation - Junit or java programming - how to upload a file from desktop(or any folder in pc) to application

share|improve this question

marked as duplicate by user246, Suchit Parikh, testerab Feb 2 '14 at 15:32

This question was marked as an exact duplicate of an existing question.

A sample program for it:

public class FileUpload {

    public static void main (String args[])
        WebDriver driver = new FirefoxDriver();

        driver.findElement(By.xpath("//input[@title='Upload file']")).click();

share|improve this answer
Hi, Sathis D, perhaps you could make your answer more useful by adding some explanation of your code. As it stands, an experienced coder would have no issues working out what to replace (such as using a Chrome driver rather than Firefox, since the OP specifically mentioned Chrome) – Kate Paulk Jan 30 '14 at 12:07
I already did that, it did not work. For that to work the upload field should also accept url or path. The button I am working with is not accepting url or path only can click and it opens finder, from there should select desired file. Using Selenium I am unable to type path in Finder also after opening. I asked our Javascript dev to change that button to support path/url button he could not to do it. So, I used sikuli .. as sikuli is not reliable, I used Auto IT but when running as a batch its problematic. – user6859 Feb 6 '14 at 19:08

Not the answer you're looking for? Browse other questions tagged or ask your own question.