title: How to auto-download through Firefox browser using FirefoxProfile?
body: <p>I'm working with selenium java where I need to download pdf files, I referred <a href="https://stackoverflow.com/questions/1176348/access-to-file-download-dialog-in-firefox">this</a>, <a href="https://stackoverflow.com/questions/16746707/how-to-download-any-file-and-save-it-to-the-desired-location-using-selenium-webd">this</a> and also <a href="http://yizeng.me/2014/05/23/download-pdf-files-automatically-in-firefox-using-selenium-webdriver/" rel="nofollow noreferrer">this</a> answers here, but seems like nothing is working in my situation. 
  Is it due to setting a new firefox driver instance i.e.<code>System.setProperty("webdriver.firefox.bin", "D:\\FFF\\firefox.exe");</code> ? I'm stuck here.However when I manually click on save file on the MIME dialog it saves correctly to my custom location, also my download link code resides in another java class and below code in another class , but  I use the same driver as declared in this class,
  below is my code,</p>
  
  <pre><code>FirefoxProfile profile = new FirefoxProfile();
  //Set Location to store files after downloading.
  profile.setPreference("browser.download.folderList", 2);
  profile.setPreference( "browser.download.manager.showWhenStarting", false );
  profile.setPreference("browser.download.dir", "D:\\WebDriverDownloads");
  profile.setPreference("pdfjs.disabled", true);
  profile.setPreference("browser.helperApps.neverAsk.saveToDisk", "application/pdf"); 
  System.setProperty("webdriver.firefox.bin", "D:\\FFF\\firefox.exe");
  driver = new FirefoxDriver(profile);
  </code></pre>