I want to check file uploads using Selenium WebDriver and Java. PDF file to download. When WebDriver clicks on the “Download” link in AUT, Firefox opens the following download confirmation window:

I want Firefox to download the file automatically without showing the confirmation window above, so I used the following code:
FirefoxProfile firefoxProfile=new FirefoxProfile(); firefoxProfile.setPreference("browser.download.folderList",2); firefoxProfile.setPreference("browser.download.manager.showWhenStarting",false); firefoxProfile.setPreference("browser.download.dir",downloadPath); firefoxProfile.setPreference("browser.helperApps.neverAsk.saveToDisk","application/pdf"); WebDriver driver=new FirefoxDriver(firefoxProfile);
but Firefox still displays the same window. How do I set up a Firefox profile so that PDF files load automatically without showing a confirmation dialog?
java selenium-webdriver
stackoverflow
source share