My use case: I have to read data from a pdf than opens in chrome browser and check if some specific data is present in the pdf or not.
As I could not achieve the above I thought of downloading the file on my computer and use PDFbox for the verification. I created a chrome profile with settings to download the pdf file directly(Settings>Content settings>PDF documents). I have set it as chrome options in my selenium script. The test works but when the pdf gets opened it does not start downloading. The PDF file opens in my chrome browser. Chrome version: 62.0.3202.94
I got the chrome profile path from:
chrome://version/
I am not sure what went wrong. Please help.
@Before
public void beforeTest() throws MalformedURLException{
System.setProperty("webdriver.chrome.driver","path to chromedriver\\chromedriver.exe");
ChromeOptions options = new ChromeOptions();
String chromeProfilePath="path to custom chrome profile";
options.addArguments("user-data-dir="+chromeProfilePath);
HashMap<String, Object> chromeOptionsMap = new HashMap<String, Object>();
DesiredCapabilities cap = DesiredCapabilities.chrome();
cap.setCapability(ChromeOptions.CAPABILITY, chromeOptionsMap);
cap.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
cap.setCapability(ChromeOptions.CAPABILITY, options);
driver = new ChromeDriver(cap);
//Browser is maximized
driver.manage().window().maximize();
}