Friday, July 1, 2011

How to Upload a file using Web Driver

Here we will be using webdriver to upload a file which is the easiest.

Example:


 @Test
    public void opentest() throws Throwable{
   
        // uploading the file from 2shared.
        driver.get("http://www.2shared.com/");
        driver.findElement(By.xpath("//input[@id='upField']")).sendKeys("C:\\Documents and Settings\\saik\\Desktop\\5-16-2011 11-02-21 AM.png");
        driver.findElement(By.xpath("//input[@type='image']")).click();


No comments:

Post a Comment