Skip to main content

Extract and Validate PDF Content

Extract and Validate PDF Content

FromUse AppvancePDF IQcontent itextraction when a Scenario Editor test needs to confirm that a generated PDF contains expected text or values. This is possiblemost touseful readfor ainvoices, pdfstatements, documentconfirmations, reports, and isother possibledocuments toproduced assertby the application under test.

  1. Generate or download the PDF during the test run.
  2. Extract the relevant text from the PDF output.
  3. Validate only the stable business values needed for athe stringtest objective.
  4. Record enough evidence in the wholeexecution documentoutput orto youdiagnose canfailures.
also

Good mentionpractices

asserting
  • Avoid forvalidating contentfull ondocuments when a specificsmall pageset of fields proves the document.behavior.
  • Normalize Allwhitespace, fromdates, Scenarioand Builderdynamic Assertions.values

    Thebefore belowcomparison examplewhen showsneeded.

  • Keep anexpected examplevalues in approved test data sources instead of howhard-coding thisthem caninto bemultiple achieved.

    A simple java file was created which browses the pdf document and a jar file was created out of the java file.

    Go to Scenario Builder and create a functional scenario with the script type being 'Java' and provide the Class and the method name as desired and browse the jar file.

    Save the scenario and Play the scenario.

    Once the scenario is played back successfully, go to the Validation Suite tab and select the required assertions from the drop-down available.

    You can choose the test-case, from the drop-down and also choose the step / Request

    And provide the expected Value (Expected text that we are looking for from the PDF), Format can be chosen as PDF and the target can be a

    • Page number

      scenarios.

    A regular expression

    or the full document itself.

    Once those entries and made, from the Scenario Builder, refresh the scenario to have those assertions added. Check the below screenshots for reference.

    Save the scenario again and playback the scenario to check the results of the pdf validations.


    Last updated: JuneSeptember 26,18, 20232026

    If you have any feedback on this topic, please contact us at documentation@appvance.ai