Verify PDF Document is Created

Speedy993Speedy993 Posts: 22

I have an application that can created a PDF report of the data displayed on the screen. Is there some way for SOATest to verify that the report is created when the button is clicked? I only need to make sure that the PDF document is created. I don't need to examine the contents of the document. Would the Extension Tool allow me to do that? Can I use a script (Java, Python, etc) that would query the Download folder of the browser for the PDF document? I would also like to delete the document after the test is done.
Thanks!

Comments

  • jakubiakjakubiak Posts: 684 admin

    Yes, you could do that with an Extension Tool. If the location of the file on the server is in the HTML page somewhere, you could also extract that value using a data bank tool and then use a Write File tool to download the file to disk. In that case you'd probably still use an Extension Tool to do any validation or delete the file.

  • Speedy993Speedy993 Posts: 22

    I am trying to put together a javascript (or Groovy or Python) to read the Windows file system looking for the report file. The report is generated by calling Jaspersoft report which calls a stored procedure to create the PDF. The generated report is saved in the browser's default download folder but the path will not be in the HTML. My java skills are lacking so while I may be able to pull that information from the browser, I currently am not sure how to do that.
    Thanks for your assistance!

  • Speedy993Speedy993 Posts: 22

    I seem to be stuck. This report is created by clicking a button on the screen and is then saved to the browser's download folder. How can I confirm it is there? Is the Extension Tool the best way to do this? What sort of script would this be? Would it work better to have another test after the button click and run some Groovy script? My attempts at either of these are just giving me errors about the methods like this: "No signature of method: org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.$() is applicable for argument types:".
    Here is my simple test script:
    import com.parasoft.api.*;
    import java.io.File;

    public String verifyReport(ScriptingContext context)
    {
    File file = new File("C:/SoATest/Downloads/reportTab.pdf");
    Application.showMessage("The file " + ${file.absolutePath} + " has " + ${file.length()} + " bytes");
    file.delete();
    return "true";
    }
    Thanks for any suggestions.

  • jakubiakjakubiak Posts: 684 admin

    Try this instead:

    import com.parasoft.api.*;
    import java.io.*;
    
    public String verifyReport()
    {
        File file = new File("C:/SoATest/Downloads/reportTab.pdf");
        Application.showMessage("The file " + file.getAbsolutePath() + " has " + file.length() + " bytes");
        file.delete();
        return "true";
    }
    
Sign In or Register to comment.