use this code for firefox.
[code:1emy3nvd] FirefoxProfile profile = new FirefoxProfile();
profile.setPreference("browser.download.folderList", 2);
profile.setPreference("browser.download.manager.showWhenStarting",
false);
profile.setPreference("browser.download.dir", "C:\\temp");
// profile.setPreference("browser.helperApps.neverAsk.openFile",
// "text/csv,application/x-msexcel,application/excel,application/x-excel,application/vnd.ms-excel,image/png,image/jpeg,text/html,text/plain,application/msword,application/xml,application/vnd.openxmlformats-officedocument.wordprocessingml.document,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet ");
profile.setPreference(
"browser.helperApps.neverAsk.saveToDisk",
"application/pdf,text/csv,application/x-msexcel,application/excel,application/x-excel,application/vnd.ms-excel,image/png,image/jpeg,text/html,text/plain,application/msword,application/xml,application/vnd.openxmlformats-officedocument.wordprocessingml.document,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet ");
profile.setPreference("browser.helperApps.alwaysAsk.force", false);
profile.setPreference("browser.download.manager.alertOnEXEOpen", false);
profile.setPreference("browser.download.manager.focusWhenStarting",
false);
profile.setPreference("browser.download.manager.useWindow", false);
profile.setPreference("browser.download.manager.showAlertOnComplete",
false);
profile.setPreference("browser.download.manager.closeWhenDone", true);
profile.setPreference("plugin.scan.Acrobat", false);
profile.setPreference("plugin.scan.plid.all", "99.0");
profile.setPreference("pdfjs.disabled", true);
WebDriver driver = new FirefoxDriver(profile);
driver.get("https://go.berniesanders.com/page/-/8.5x11_LitPiece%20(1).pdf");[/code:1emy3nvd]
reference(but its in ruby and not in java):"http://yizeng.me/2014/05/23/download-pdf-files-automatically-in-firefox-using-selenium-webdriver/"
Thanks for reply. I need to rename pdf file within this method once it download in local drive with test case name . This very important in this project.
Thanks
Sankara