Click here to Skip to main content
15,438,920 members
Home / Discussions / Java
   

Java

 
QuestionHow to compare two similar xml documents ignoring node text values by using XMLUnit? Pin
mr.pakapun1-Mar-21 17:32
Membermr.pakapun1-Mar-21 17:32 
SuggestionRe: How to compare two similar xml documents ignoring node text values by using XMLUnit? Pin
Richard MacCutchan1-Mar-21 21:22
mveRichard MacCutchan1-Mar-21 21:22 
QuestionLicense key generator Pin
keznet lisimati27-Feb-21 0:27
Memberkeznet lisimati27-Feb-21 0:27 
QuestionDefault My program does not find the file MyFriends.txt Pin
zorapulo11-Feb-21 16:25
Memberzorapulo11-Feb-21 16:25 
AnswerRe: Default My program does not find the file MyFriends.txt Pin
Richard MacCutchan11-Feb-21 21:24
mveRichard MacCutchan11-Feb-21 21:24 
Questionhow to write result in excel using java selenium. Pin
Member 1393850211-Feb-21 2:46
MemberMember 1393850211-Feb-21 2:46 
AnswerRe: how to write result in excel using java selenium. Pin
Richard MacCutchan11-Feb-21 3:01
mveRichard MacCutchan11-Feb-21 3:01 
Generalhow to write result in excel using java selenium. Pin
Member 1393850211-Feb-21 2:32
MemberMember 1393850211-Feb-21 2:32 
I am tryin to write the result of the pdf validation in to an excel but it is not working can anyon help below is the code i wrote

Java
<pre>public static void PDF_File_Validation(String object, String data) throws IOException{
       try{
       Log.info("PDF Documents has been Verified");
       List<String> outputs = new ArrayList<String>();
       
     

       
    System.setProperty("webdriver.chrome.driver", Constants.Path_driver);

    WebDriver driver = new ChromeDriver();
       
    File[] files = new File(object).listFiles(File::isFile);
    
        for (File file: files) {
       
    String fileExtension = file.getName().split("\\.")[file.getName().split("\\.").length - 1];
       
       if (fileExtension.toLowerCase().equals("pdf")) {
               
    String fileUrl = "file:///" + file.getAbsolutePath();
       
    driver.get(fileUrl);
       

    URL url = new URL(driver.getCurrentUrl());
   
    InputStream is = url.openStream();
   
    BufferedInputStream fileToParse = new BufferedInputStream(is);

    PDDocument document = null;
   
    String output;
       

    try {
         document = PDDocument.load(fileToParse);
         output = new PDFTextStripper().getText(document);
                
         } finally {
                if (document != null) {
                    document.close();
                }
                fileToParse.close();
                is.close();
                }
            
                outputs.add(output);
                Thread.sleep(2500);
                boolean test = output.contains(data);
                String test1=Boolean.toString(test);
                FileInputStream file1 = new FileInputStream(Constants.Path_Result+DriverScript.s+"\\PDFResults.xlsx");
                @SuppressWarnings("resource")
                    XSSFWorkbook workbook = new XSSFWorkbook(file1);
                XSSFSheet sheet = workbook.getSheetAt(0);
                Row row1 = sheet.createRow( 0 );
                if (test1.contains("false")){
                    Log.info("The "+file.getName()+" File does not Contain "+ data+"="+"Failed");
               // System.out.println ("The ["+file.getName()+" File Containes "+ data+"="+output.contains("data"));
                }else{
                    Log.info("The "+file.getName()+" File Containes "+ data+"="+"Passed");
                }
                for ( int cellIndex = 0; cellIndex < output.length(); cellIndex++ ) {
                        Cell cell = row1.createCell( cellIndex );
                        if (test1.contains("false")){
                          cell.setCellValue("The "+file.getName()+" File does not Contain "+ data+"="+"Failed");
                }else{
                   cell.setCellValue("The "+file.getName()+" File Containes "+ data+"="+"Passed");
                    }
                       // System.out.println ("The ["+file.getName()+" File Containes "+ data+"="+output.contains("data"));
                        
                        //System.out.println(cell.getStringCellValue());
                    }
                

                file1.close();


                FileOutputStream outFile =new FileOutputStream(Constants.Path_Result+DriverScript.s+"\\PDFResults.xlsx");
                workbook.write(outFile);
                outFile.close();
    
                    
        }}
       
   driver.quit();
   return;
       
   }catch(Exception e){
              
   Log.error("PDF Documents was not Verified --- " + e.getMessage());
   DriverScript.bResult = false;
       }
       }


modified 11-Feb-21 11:41am.

GeneralRe: how to write result in excel using java selenium. Pin
OriginalGriff11-Feb-21 2:50
mveOriginalGriff11-Feb-21 2:50 
GeneralRe: how to write result in excel using java selenium. Pin
Cp-Coder11-Feb-21 2:51
MemberCp-Coder11-Feb-21 2:51 
JokeRe: how to write result in excel using java selenium. Pin
Slacker00711-Feb-21 3:14
professionalSlacker00711-Feb-21 3:14 
GeneralRe: how to write result in excel using java selenium. Pin
Richard MacCutchan11-Feb-21 3:34
mveRichard MacCutchan11-Feb-21 3:34 
GeneralRe: how to write result in excel using java selenium. Pin
Marc Clifton11-Feb-21 3:49
mvaMarc Clifton11-Feb-21 3:49 
QuestionJAVA PROGRAMMING Pin
Member 150686089-Feb-21 2:02
MemberMember 150686089-Feb-21 2:02 
AnswerRe: JAVA PROGRAMMING Pin
Richard MacCutchan9-Feb-21 2:49
mveRichard MacCutchan9-Feb-21 2:49 
QuestionBarrons Ap Computer Science A / question on compound boolean Pin
Ap_noob12-Jan-21 11:45
MemberAp_noob12-Jan-21 11:45 
AnswerRe: Barrons Ap Computer Science A / question on compound boolean Pin
Richard MacCutchan12-Jan-21 21:40
mveRichard MacCutchan12-Jan-21 21:40 
QuestionConvert string array to integer without using loop? Thanks Azbilegt Chuluunbat Pin
Azbilegt Chuluunbat30-Dec-20 6:48
MemberAzbilegt Chuluunbat30-Dec-20 6:48 
AnswerRe: Convert string array to integer without using loop? Thanks Azbilegt Chuluunbat Pin
Victor Nijegorodov30-Dec-20 7:20
MemberVictor Nijegorodov30-Dec-20 7:20 
AnswerRe: Convert string array to integer without using loop? Thanks Azbilegt Chuluunbat Pin
Richard MacCutchan30-Dec-20 21:26
mveRichard MacCutchan30-Dec-20 21:26 
AnswerRe: Convert string array to integer without using loop? Thanks Azbilegt Chuluunbat Pin
Randor 31-Dec-20 0:30
professional Randor 31-Dec-20 0:30 
QuestionDon't understand the error Pin
rorilila25-Dec-20 23:13
Memberrorilila25-Dec-20 23:13 
AnswerRe: Don't understand the error Pin
Sandeep Mewara25-Dec-20 23:26
mveSandeep Mewara25-Dec-20 23:26 
AnswerRe: Don't understand the error Pin
Richard MacCutchan25-Dec-20 23:31
mveRichard MacCutchan25-Dec-20 23:31 
QuestionIs truncating a table faster than dropping and re-creating it in SQL? Thanks Azbilegt Chuluunbat Pin
Azbilegt Chuluunbat20-Dec-20 13:54
MemberAzbilegt Chuluunbat20-Dec-20 13:54 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.