PDF Checkpoints

Applies to TestComplete 14.70, last modified on April 22, 2021

A PDF checkpoint is a test operation that recognizes text content of a PDF document using optical character recognition and verifies that the recognized text matches the expected text. This can be helpful when testing an application that provides its output as a PDF file. You can use PDF checkpoints to make sure the application provides the expected output and therefore, works correctly.

In keyword tests, you perform PDF checkpoints with the PDF Checkpoint operation:

PDF Checkpoint in a keyword test

In scripts — by using the Files.PDF_File_Name.CheckPDFText method:

JavaScript, JScript

Files.baseline_pdf.CheckPDFText("C:\\Work\\report.pdf");

Python

Files.baseline_pdf.CheckPDFText("C:\\Work\\report.pdf")

VBScript

Call Files.baseline_pdf.CheckPDFText("C:\Work\report.pdf")

DelphiScript

Files.baseline_pdf.CheckPDFText('C:\Work\report.pdf')

C++Script, C#Script

Files["baseline_pdf"]["CheckPDFText"]("C:\\Work\\report.pdf");

Requirements

  • Your TestComplete version must be 14.20 or later.

  • Your computer must have access to the ocr.api.dev.smartbear.com web service.

    If you have firewalls or proxies running in your network, they should allow your computer to access the web service. This web service is used to recognize the text content of PDF files.

  • Your firewall must allow traffic through port 443.

  • You need an active license for the TestComplete Intelligent Quality add-on.

  • The Intelligent Quality add-on must be enabled in TestComplete.

    You can enable the add-on during TestComplete installation. If you did not enable the add-on during the installation, you can do this at any moment later via the File > Install Extensions dialog. Select File > Install Extensions from the TestComplete main menu and enable the Intelligent Quality > Intelligent Quality Core plugin in the resulting dialog.

  • PDF to Text support must be enabled in TestComplete.

    By default, it is enabled automatically if you enable the Intelligent Quality add-on during TestComplete installation.

    If you experience issues with PDF support in your tests, select File > Install Extensions from the TestComplete main menu and make sure the PDF to Text plugin is enabled (you can find it in the Intelligent Quality group). If the plugin is disabled, enable it. In the confirmation message, click the link to read a third-party license agreement. If you agree to the license terms, click Enable OCR.

How a PDF Checkpoint Works

During the test run, TestComplete:

  1. Gets the PDF file whose contents you want to verify.

  2. Recognizes the text content of the file using optical character recognition.

  3. Compares the text content with the baseline content that the Stores > Files collection contains.

  4. Reports the results.

How to Create PDF Checkpoints

You can add PDF checkpoints to your test during test recording and at design time using the Create Checkpoint wizard. For detailed instructions, see Creating PDF Checkpoints.

PDF Checkpoint Results

If the actual and the stored text contents are reported equal, the checkpoint posts a success message to the test log.

Otherwise, the checkpoint posts an error message to the test log. It also posts the comparison summary to the Details panel and detailed comparison results:

Detailed results of PDF file comparison

Click the image to enlarge it.

If you use a third-party diff utility to compare files, the checkpoint will also post the comparison report generated by that utility to the test log.

For a detailed description of the results PDF checkpoints generate, see Analyzing PDF Verification Results.

Alternatives to PDF Checkpoints

  • To compare PDF files byte-by-byte, use file checkpoints.

  • To check whether PDF file text matches an elaborate pattern, you can use the PDF.ConvertToText method to get the text content and then use regular expressions and various scripting objects that TestComplete provides to validate the content. You can find examples in Working With PDF Files.

Updating PDF Checkpoints

If the expected contents of your tested PDF file have changed, you may want to update your PDF checkpoints to use new baseline contents. Instead of updating the baseline data stored in the Stores > Files collection manually, you can command TestComplete to update it automatically.

To learn how to do this, see Updating PDF Checkpoints.

See Also

Files
Working With PDF Files
About TestComplete Platform, Modules and Add-Ons

Highlight search results