[Expand]Writing Automated Script Code/viewarticle/78103/
 [Expand]Working With Files, Databases and Excel Sheets/viewarticle/78102/
 [Expand]Web Testing - Functional Testing of Web Pages/viewarticle/78101/
 [Expand]TestComplete Trial Version Questions/viewarticle/78095/
 [Expand]Test Log and Results/viewarticle/78100/
 [Expand]Supported Applications, Operating Systems and Develompent Tools/viewarticle/78094/
 [Expand]Recording, Running and Debugging Automated Tests/viewarticle/78093/
 [Collapse]Objects, Files and Images Comparison/viewarticle/78092/
   Can I use TestComplete to compare PDF files?/viewarticle/65847/
   I need to compare an object in the beginning, and then compare it again at the end. How can I do that?/viewarticle/65879/
   I save the object by using Objects.Save and some properties are not saved. Can these properties be saved?/viewarticle/65890/
   Is it possible to capture an image or a screenshot while executing the test for later comparison?/viewarticle/65908/
   Is there any way to prevent the failure of bitmap comparisons from changes in screen resolution or color depth?/viewarticle/65849/
   Regions.Compare indicates that the images are different even though they look the same. What is wrong?/viewarticle/65745/
   Is it possible to update checkpoints automatically?/viewarticle/65832/
 [Expand]Licensing Questions/viewarticle/65756/
 [Expand]General Questions About Automated Testing/viewarticle/78090/
 [Expand]Automated Testing Tasks - Basic/viewarticle/78089/
 [Expand]Automated Testing Tasks - Advanced/viewarticle/78088/
 [Expand]Testing Mobile Applications/viewarticle/78099/
 [Expand]Accessing Application's Internal Objects, Methods and Properties/viewarticle/78087/
 [Expand]Working With Source Control/viewarticle/78104/
Updated: 8/15/2016 Applies To: TestComplete Rating: AverageAverageAverageAverageAverage 4 vote(s) Click to rate: PoorNot badAverageGoodExcellent
Q.: Can I use TestComplete to compare PDF files?

A.: Currently, there are no features for comparing Adobe PDF files. However, you can use one of the following solutions:

  • Use an external library (like Apache PDFBox) with TestComplete. It allows you to:

    • find text in a PDF document,

    • compare images,

    • compare the entire document,

    • and so on.

    To learn how to use the library with TestComplete, see the Testing PDF Files With TestComplete article.

  • Compare PDF files byte-by-byte just like any other file by using the File Checkpoints and the Files.Compare methods. This can help reveal files that have a different size, creation date and other physical attributes. See the "File Checkpoints" help topic for details.
  • Capture screenshots of each page of the PDF documents and then compare the corresponding pictures by using the Picture.Compare or Regions.Compare method or by using Region Checkpoints. See the "Alternatives to Region Checkpoints" help topic for more information.
  • Compare the internal properties of the Adobe Reader process that are exposed by the MSAA plugin. These properties contain the fragments of the PDF document (paragraphs, lists, headers and others), thus you can compare the values of properties that relate to different documents. This technique is a little more difficult, but it is the most reliable solution.

    In order for Adobe Reader to be recognized as an MSAA application, you need to perform the following steps:

    1. Make sure that TestComplete's Desktop module is installed on your computer and the Microsoft Active Accessibility Support feature is active in the File | Install Extensions dialog.
    2. Open the Project Properties window (right-click your project in Project Explorer and select the Edit | Properties context menu item).
    3. Select the Open Applications | MSAA category and enable the * item in the List of accepted windows.

    Once this is done, TestComplete exposes every object that supports the IAccessible interface. This significantly increases the number of objects that are available to TestComplete and you now have the ability to access individual parts of the document: paragraphs, lists, headers, and so on. Each of them is represented as individual MSAAObject and you can retrieve the fragment's text via the Value property.

    However, due to a great number of objects, it becomes difficult to locate the needed element. For example it can have a name like: Sys.Process("AcroRd32").Window("AcrobatSDIWindow", "aTestFile.pdf - Adobe Reader", 1).Window("AVL_AVView", "AVToolBarHostView", 1).Window("AVL_AVView", "AVInternalDocumentView", 1).Window("AVL_AVView", "AVSplitterView", 2).Window("AVL_AVView", "AVPageView", 4).MSAAObject("client").MSAAObject("editable_text").

    In this situation, it is convenient to locate the needed element with the Finder tool of the Object Spy window. Alternatively you can use a similar tool in the Create Property Checkpoint dialog. This dialog generates code that verifies the value of the specified property, but the code can easily be modified for the comparison goals.

© 2020 SmartBear Software. All rights reserved.
Email Send feedback on this document