I am trying to automate file download functionality using Selenium WebDriver. I am using Google Chrome and the type of the file to download is of PDF format. When WebDriver clicks on the download (or Print) link, browser shows the preview of the pdf file instead of downloading it directly. How can I make the chrome driver to download pdf files directly?. I tried the below code, but no luck
ChromeOptions options = new ChromeOptions();
Map<String,Object> preferences = new HashMap<>();
preferences.put("pdfjs.disabled", true);
options.setExperimentalOption("prefs", preferences);
System.setProperty("webdriver.chrome.driver", chromeDriverPath);
WebDriver driver=new ChromeDriver(options);
I know this question has already asked on StackOverflow, including this, but none of these solutions work for me.
I am using - Google Chrome v54.0.2840.99, Chromedriver v2.25 and Selenium v3.0.1
HTML of the Download/Print link is shown below