File download functionality can be automated by setting the browser's preferences. We set the directory in which the file will be downloaded.
FirefoxProfile profile = new FirefoxProfile();
profile.setPreference("browser.download.dir", "E:\\Automation");
profile.setPreference("browser.download.folderList", 2);
//0 for Desktop, 1 for default location and 2 for Custom location
profile.setPreference("browser.helperApps.neverAsk.saveToDisk","application/zip");
WebDriver driver = new FirefoxDriver(profile);
driver.get("http://docs.seleniumhq.org/download/");
driver.findElement(By.xpath("//*[@id='mainContent']//a[text()='Download' and contains(@href,'selenium-java-2.46.0.zip')]")).click();
0 Comment(s)