top of page

 Change chrome setting to download File / Pdf 

         ChromeOptions options = new ChromeOptions();
         HashMap<String, Object> chromeOptionsMap = new HashMap<String, Object>();
         chromeOptionsMap.put("plugins.plugins_disabled", new String[] {
                   "Chrome PDF Viewer"
               });
         chromeOptionsMap.put("plugins.always_open_pdf_externally", true);
         options.setExperimentalOption("prefs", chromeOptionsMap);
         String downloadFilepath = "C:\\Users\\\" + user_name +\"\\Downloads";
         chromeOptionsMap.put("download.default_directory", downloadFilepath);
         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);

       1  Download Apache PDFBox  Jars

           https://pdfbox.apache.org/download.cgi#20x

      2  Creat object

       PDFManager pdfManager = new PDFManager();

     3  Code

       pdfManager.setFilePath(LastFile);
 
       String text = pdfManager.ToText();
       System.out.println("The pdf contain the BL number: " + text.contains(doc_to_select));

 Reading pdf 

Selenium - izselenium aoutomation tool

054-8059589

  • White Facebook Icon
  • White Twitter Icon
  • White Google+ Icon
  • White YouTube Icon

© 2017 by izselenium

bottom of page