I am trying to download a pdf from Chrome browser in Jenkins. However, I am seeing an error as "File not found" exception in Jenkins. When I ran the same code locally it was working fine. I don't see any exceptions. Below is the code that I am using to download the pdf.
WebDriverManager.chromedriver().setup();
ChromeOptions options = new ChromeOptions();
options.addArguments("--no-sandbox");
options.addArguments("--disable-dev-shm-usage");
if (DriverManager.headlessAutomationFlag.get().equalsIgnoreCase("Yes")) {
options.addArguments("headless");
}
HashMap<String, Object> prefs = new HashMap<>();
prefs.put("plugins.always_open_pdf_externally", true);
prefs.put("download.default_directory", System.getProperty("user.dir") +
ConfigReader.properties("DownloadPath"));
options.setExperimentalOption("prefs", prefs);
driver.set(new ChromeDriver(options));
The Download path is inside the same project folder.