Take the 2-minute tour ×
Software Quality Assurance & Testing Stack Exchange is a question and answer site for software quality control experts, automation engineers, and software testers. It's 100% free, no registration required.

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
add comment

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

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

1 Answer

A sample program for it:

public class FileUpload {

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

        driver.get("http://www.2shared.com/");
        driver.findElement(By.id("upField")).sendKeys("D:\\james.xls");
        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 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 at 19:08
add comment

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