Welcome to the new Parasoft forums! We hope you will enjoy the site and try out some of the new features, like sharing an idea you may have for one of our products or following a category.

Verify PDF Document is Created

Speedy993
Speedy993 Posts: 72

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

  • jakubiak
    jakubiak Posts: 813 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.

  • Speedy993
    Speedy993 Posts: 72

    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!

  • Speedy993
    Speedy993 Posts: 72

    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.

  • jakubiak
    jakubiak Posts: 813 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";
    }