Friday 26 July 2013

Upload Files in Selenium Webdriver

Please go through below code ......


package Sample;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.*;
import org.openqa.selenium.firefox.FirefoxDriver;
public class uploadfile {
public static void main(String[] args) {
WebDriver driver = new FirefoxDriver();
driver.get("http://www.files.com/");
driver.manage().window().maximize();
WebElement uploadElement = driver.findElement(By.xpath(".//*[@id='uploadFields']/input"));
//WebElement uploadElement = driver.findElement(By.id("uploadfile_0"));
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
uploadElement.sendKeys("C:\\Users\\shivap\\Desktop\\24-1374658179-13.jpg");
driver.close();

}
}

Happy Testing 

No comments:

Post a Comment