Handle download confirmation popup/dialog in Firefox
<p>I have a test to upload ,compress and download pdf files. Everything is working fine except the download part. I am not able to get how to handle the confirmation popup/Save or Open file dialog in Firefox when we click on download.  I tried modifying firefox config but still not able to solve it. Can anyone please help?</p>

<pre><code>FirefoxProfile profile = new FirefoxProfile();
        profile.setPreference("browser.download.folderList", 2);
        profile.setPreference("browser.download.manager.showWhenStarting", false);
        profile.setPreference("browser.download.dir", "C:\\Users\\Sahil\\Downloads\\");
        profile.setPreference("browser.helperApps.neverAsk.openFile","application/pdf");
        profile.setPreference("browser.helperApps.neverAsk.saveToDisk","application/pdf");
        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", false);

        profile.setPreference("browser.download.manager.useWindow", false);
        profile.setPreference("browser.download.manager.showWhenStarting", false);
        profile.setPreference("services.sync.prefs.sync.browser.download.manager.showWhenStarting", false);
      , 0  profile.setPreference("pdfjs.disabled", true);
     WebDriver driver=new FirefoxDriver(profile);   
    driver.get("http://www.ilovepdf.com/compress_pdf");
    driver.findElement(By.id("pickfiles")).click();
    Runtime.getRuntime().exec("C:\\Users\\Sahil\\Documents\\Au\\Second.exe");
    WebDriverWait wait=new WebDriverWait(driver, 100);
    WebElement element1=wait.until(ExpectedConditions.elementToBeClickable(By.id("uploadfiles")));
    element1.click();

    WebElement element=wait.until(ExpectedConditions.presenceOfElementLocated(By.cssSelector("a#download")));
    element.click();
</code></pre>