Unable to download PDF file | Selenium Forum
M
Posted on 02/12/2015
Hi Ashish,
I have tried to download PDF with the following code.

FirefoxProfile profile = new FirefoxProfile();
profile.setPreference("browser.download.folderList", 2);

profile.setPreference("browser.download.dir","C:\\workspace\\downloads");
profile.setPreference("browser.helperApps.neverAsk.saveToDisk", "application/msword,application/x-rar-compressed,application/octet-stream,application/csv,text/csv,application/xml,application/pdfss,application/x-pdf,application/acrobat,applications/vnd.pdf,text/pdf,text/x-pdf,application/pdf,application/octet-stream,application/application/pdf");

WebDriver driver = new FirefoxDriver(profile);
driver.get("https://thegazette.co.uk/");
driver.manage().window().maximize();

but still get the save to disk pop up and need to manually click on the ok button to download file.
Can you please help.

Regards
Shashikant

M
Replied on 02/12/2015

Hi,
I have added new line to the code and now its working.

profile.setPreference( "pdfjs.disabled", true );

Regards
Shashikant


M
Replied on 02/12/2015

Is there a way to perform similar sort of action using IE Driver?


M
Replied on 02/12/2015

not with ie driver.

for ie driver you have to use robot framework or auto it