Parameterizing PDF Checkpoints

Applies to TestComplete 15.73, last modified on March 04, 2025

In TestComplete, you use PDF checkpoints to verify the actual text content of the specified PDF files by comparing it with the baseline data stored in the Stores > Files collection of your project.

PDF checkpoints in TestComplete take two parameters:

  • The name (with the full path) of the PDF file you want to verify.

  • The allowed difference value (in bytes).

By default, PDF checkpoints you create use hard-coded parameter values. You may want to parameterize your PDF checkpoints, that is, to replace hard-coded values with variable values. For example, if the name of the file you want to verify changes between test runs, you can replace the hard-coded file name with a parameter that obtains the required file name before each test run.

In keyword tests

  1. Create a variable or parameter that will contain the needed variable value. It can be:

    For example, the image below shows the Param1 parameter of a keyword test:

    Creating a keyword test parameter to parameterize a PDF checkpoint

    Click the image to enlarge it.

  2. Replace the hard-coded value of the PDF Checkpoint operation with the created variable or parameter:

    Parameterizing PDF Checkpoint operation

    Click the image to enlarge it.

  3. Assign the needed value to the created variable or parameter:

    • To set a variable value, you can use the Set Variable Value operation.

    • Set a parameter value when you run your test. If you run it as part of the project’s test items sequence, set the test parameter in the Execution Plan editor of your project. If you run your test from another test, set the parameter value when calling your test.

    For example, the image below shows how to set a parameter value in the Execution Plan editor of the project:

    Setting parameter value

    Click the image to enlarge it.

  4. Run the test with the needed parameter value assigned.

In scripts

  1. Define a variable or parameter that will contain the needed variable value.

    JavaScript, JScript

    function ValidatePDF(Param1)
    {
      …
      // Validate the PDF file
      Files.sample.CheckPDFText("C:\\Users\\tester\\Documents\\sample.pdf");
      …
    }

    Python

    def ValidatePDF(Param1):
      …
      # Validate the PDF file
      Files.sample.CheckPDFText("C:\\Users\\tester\\Documents\\sample.pdf")
      …

    VBScript

    Sub ValidatePDF(Param1)
      …
      ' Validate the PDF file
      Call Files.sample.CheckPDFText("C:\Users\tester\Documents\sample.pdf")
      …
    End Sub

    DelphiScript

    procedure ValidatePDF(Param1);
    begin
      …
      // Validate the PDF file
      Files.sample.CheckPDFText('C:\Users\tester\Documents\sample.pdf');
      …
    end;

    C++Script, C#Script

    function ValidatePDF(Param1)
    {
      …
      // Validate the PDF file
      Files["sample"]["CheckPDFText"]("C:\\Users\\tester\\Documents\\sample.pdf");
      …
    }
  2. Replace the hard-coded parameter of the Files.PDF_File_Name.CheckPDFText method with the created variable or parameter:

    JavaScript, JScript

    function ValidatePDF(Param1)
    {
      …
      // Validate the PDF file
      Files.sample.CheckPDFText(Param1);
      …
    }

    Python

    def ValidatePDF(Param1):
      …
      # Validate the PDF file
      Files.sample.CheckPDFText(Param1)
      …

    VBScript

    Sub ValidatePDF(Param1)
      …
      ' Validate the PDF file
      Call Files.sample.CheckPDFText(Param1)
      …
    End Sub

    DelphiScript

    procedure ValidatePDF(Param1);
    begin
      …
      // Validate the PDF file
      Files.sample.CheckPDFText(Param1);
      …
    end;

    C++Script, C#Script

    function ValidatePDF(Param1)
    {
      …
      // Validate the PDF file
      Files["sample"]["CheckPDFText"](Param1);
      …
    }
  3. Assign the needed value to a variable or parameter and call the parameterized checkpoint:

    JavaScript, JScript

    function Main()
    {
      var path = "C:\\Users\\tester\\Documents\\sample.pdf";
      ValidatePDF(path);
      …
    }

    function ValidatePDF(Param1)
    {
      …
      // Validate the PDF file
      Files.sample.CheckPDFText(Param1);
      …
    }

    Python

    def Main():
      path = "C:\\Users\\tester\\Documents\\sample.pdf"
      ValidatePDF(path)
      …

    def ValidatePDF(Param1):
      …
      # Validate the PDF file
      Files.sample.CheckPDFText(Param1)
      …

    VBScript

    Sub Main()
      path = "C:\Users\tester\Documents\sample.pdf"
      Call ValidatePDF(path)
      …
    End Sub

    Sub ValidatePDF(Param1)
      …
      ' Validate the PDF file
      Call Files.sample.CheckPDFText(Param1)
      …
    End Sub

    DelphiScript

    procedure ValidatePDF(Param1);
    begin
      …
      // Validate the PDF file
      Files.sample.CheckPDFText(Param1);
      …
    end;

    procedure Main();
    var path;
    begin
      path := 'C:\Users\tester\Documents\sample.pdf';
      ValidatePDF(path);
      …
    end;

    C++Script, C#Script

    function Main()
    {
      var path = "C:\\Users\\tester\\Documents\\sample.pdf";
      ValidatePDF(path);
      …
    }

    function ValidatePDF(Param1)
    {
      …
      // Validate the PDF file
      Files["sample"]["CheckPDFText"](Param1);
      …
    }

See Also

PDF Checkpoints
Creating PDF Checkpoints
Parameterizing Keyword Tests
Parameterizing Script Routines

Highlight search results