1

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.

HoRn
  • 1,458
  • 5
  • 20
  • 25
  • Hey! Please share the jenkins console logs and any stack trace to understand the issue. – A P Aug 12 '22 at 15:49
  • java.lang.NullPointerException at utils.PdfReader.pdfDataStore(PdfReader.java:85) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at prod-api-i-2e09008]: Unable to validate PDF : null – Mohamed Riswan Aug 12 '22 at 17:49
  • These logs should be added to the question – HoRn Aug 13 '22 at 07:30

0 Answers0