How to allow save option on Firefox while downloading a file with Java-TestNG?
Hi Mark- mazay,
You can use the below code snippet:
FirefoxProfile profile = new FirefoxProfile();
// profile.setPreference("browser.download.useDownloadDir", true);
This is true by default. Add it if it’s not working without it.
profile.setPreference("browser.download.folderList",2); //Use for the default download directory the last folder specified for a download
profile.setPreference("browser.download.dir", "/Path/to/directory"); //Set the last directory used for saving a file from the "What should (browser) do with this file?" dialog.
profile.setPreference("browser.helperApps.neverAsk.saveToDisk", "application/pdf"); //list of MIME types to save to disk without asking what to use to open the file
profile.setPreference("pdfjs.disabled", true); // disable the built-in PDF viewer
firefoxOptions.setProfile(profile);