0 Shares 3510 Views 35 Comments

I was looking for PDF Checkpoint!!

May 13, 2013
3510 Views 35

I was looking for PDF Checkpoint, I got File Content Checkpoint!!

At the time when UFT 11.50 was about to launch, I read about the new upcoming features in UFT at so many places. One of the most interesting feature for me was PDF Checkpoint. I was waiting for this to explore. I am glad that team at HP is working hard to improve the quality and focusing on the missing features to include in newer versions. PDF Comparison and manipulation is an area in test automation, in which I have seen lots of requirement for tests and challenges in automating the scenarios. I have actually developed an API earlier to manipulate PDF files. Where I tried to cover most of the automation requirement. Never the less, I am not going to discuss about the API I developed, rather I wanted to see what all we are going to have with this new checkpoint in UFT 11.50. I was looking for PDF Checkpoint as soon as I got UFT installed on my system. But I didn’t find it. What I could find was a whole list of checkpoints as it is in QTP 11. By taking a closer look at all the checkpoints, I found that it is a new checkpoint that has been introduced in UFT 11.50 as ‘File Content Checkpoint’ which can be used to insert checkpoint for Text, Word, HTML, RTF and PDF file types.

Checkpoints in UFT

Checkpoints in UFT

As the name suggests- File Content Checkpoint can be used to compare the content of a file generated run-time (actual file) with the content of the source (expected file). Okay, So that means we can compare two pdf files for our tests. The next question comes in my mind that what all content we can compare? Can we compare images and tables in PDF too? The answer was, No.  File Content checkpoint can be used to compare the textual content only. It can be used on text in one line, multiple lines, or the entire document, as needed. I was sad there is not much as I was expecting, I will have to again rely on my API for other manipulating PDF files but happy to find that at least we now have the most commonly used testing i.e. comparing PDFs is in place in UFT. Rather we can now compare other file types too.

How it Works

UFT converts the document you select as source into text format and displays the content, using which you can configure your checkpoint. Checkpoint can be configured in File Content Checkpoint Properties Dialog box. If a file content checkpoint step fails during a run session, the Captured Data pane in the Run Results Viewer displays a side-by-side comparison of the generated document and the source document, enabling you to visually compare the differences between the documents, including lines or sections that were added or removed.

How to Create a File Content Checkpoint

Go to Design > Checkpoint > File Content Checkpoint or Click the Insert Checkpoint or Output Value button in the toolbar and select File Content Checkpoint.

Click the Insert Checkpoint or Output Value button  in the toolbar

Click the Checkpoint Button

The Source File for Checkpoint dialog box opens. Browse and select the relevant file, and click Open. The File Content Checkpoint Properties Dialog box appears. Here, you can change the name of the checkpoint. If you have mistakenly chosen the wrong source file, you can specify it here. The Content of the file will be shown in File Content Editor. You can select one line, multiple or all lines you want to verify.

File Content Checkpoint Properties Dialog

File Content Checkpoint Properties Dialog

As you hover over a line, a check box and a regular expression icon are displayed in the sidebar to the left of that line. Click the check box to select (or clear) the line for verification.

Select lines to compare

Select lines to compare

You can specify a regular expression for as well for verification for the content. FCP_RegEx Click the Treat Line as Regular Expression / Plain Text button, this will add backslashes prior to all special characters in that line and you can modify the regular expression. You can also add parameters for the content as you do in other checkpoints. Select the Content you want to parameterize, right click and select ‘Add Parameters to the Line’ option or Select the Button from the toolbar. Choose appropriate parameters as required at the Parameter configuration option dialog. File Content Editor has the toolbar button or right click menu option to evaluate the regular expressions. It also has the feature to preview the comparison. If the source file contains multiple pages, the File Content Editor is divided into separate pages. You can expand or collapse the pages, select or clear entire pages for verification, and so on.

Here is a video on how to use File Content Checkpoint taken from HP Blog – The Future of Testing Blog

So overall, this is impressive. We can now do file comparisons using this inbuilt checkpoint. Specially for PDF files, it was very much required. You might want to try LearnQuickTestPDF API as well and let me know how it works for you. I am in process to add some new features like comparing images. If you have any specific requirement, let me know via the comments section below or contact me using this Contact form.

You may be interested

UFT Patch Updates – UFT 14.03
Unified Functional Testing
434 views1
Unified Functional Testing
434 views1

UFT Patch Updates – UFT 14.03

Saket - Mar 11, 2018

Post the launch of UFT 14.0, there are three patch updates has been released including a number of features and enhancement. Recently Micro Focus unveiled third patch…

Setting up Web Service Automation Project
Katalon Studio
877 views
Katalon Studio
877 views

Setting up Web Service Automation Project

Saket - Oct 24, 2017

Web services are specific services that can be published and called over the Internet by client applications. Katalon Studio supports functional testing of web services. This topic…

Setting up Mobile Automation Project in MacOS
Katalon Studio
821 views1
Katalon Studio
821 views1

Setting up Mobile Automation Project in MacOS

Saket - Oct 09, 2017

Using Katalon Studio, mobile tester can design automation test for both Android and iOS to run on physical devices, cloud services and emulators. This tutorial explains how…

35 Comments

    • Hi Praveen,
      here is what you can do to set the comparison file at run time.
      1. create the checkpoint with the base file you want to compare. once you are done you will get the code for your checkpoint in your script. same code can be used to compare different file.
      2. go to Object repository and select the checkpoint you created.
      3. you will the see the option to parametrize the comparison file at the top. pls refer screenshot.
      4. you can parametrize the value with datatable or environment variable.
      5. Once you are set with this, you can change the file path at datatable field runtime.

      File Content Checkpoint Parameterized
      hope this answers your question. please let us know if you want more detail or having issue.

      Reply
  1. Hi Saket,

    i am unable to get your “LearnQuickTestPDF API” work for me. I am using Win 7. I tried API on qtp 10 and UFT 11.52.

    I am getting error “ActiveX component can’t create object: LearnQuickTest.ManipulatePDF”

    Can you please help me with this issue?

    Thanks

    Paul

    Reply
    • This might be because the dll is not registered successfully. can you try again by following the process mentioned? make sure a tlb file gets created at the end.
      I did not get chance yet to verify this on UFT, but I am working on newer version of this API, which should definitely work with UFT and address other verification like Tables, Images etc.

      Reply
  2. Thanks Saket

    I followed the process which you mentioned.
    Which folder I am supposed to see tlb file?

    I will wait for updated API for UFT.

    thanks

    Paul

    Reply
    • it should be in the same folder you extracted the dll.
      I will surely let you know in couple of weeks, once it is ready and tested.

      Reply
    • My apologies, Since you are working on win7 it is an issue of the right version of RegASM to register the dll, i.e 64-bit version of .NET framework.
      Can you try registering the dll with the steps below and let me know if this works for your. I have just re-tested it on win8 and UFT 12, it works perfectly.

      1. Close QTP/UFT is already open and then launch command prompt (if this does not work, try launching as administrator)
      2. Get you .Net framework path usally it should be as below, check .net fwk v2.0*
      C:\Windows\Microsoft.NET\Framework64\v2.0.50727\
      3. use the command below to register the dll
      C:\Windows\Microsoft.NET\Framework64\v2.0.50727\regasm.exe C:\Test\LearnQuickTest.ManipulatePDF.dll

      try in UFT. this should work. Please update.

      Reply
      • This Api not working for me, i am using UFT 12.02 on Win 7 64 bit, I have followed all your steps.

        After creating objtect, and oPDF. here am not getting intellisense menu and if manually type and execute, UFT throwing Error as ActiveX Component cant create object

        I have followed to register dll manually but still no luck, am i missing anything here, please help am stuck at this point 🙁

        Reply
          • I am not sure, whether all steps are success or not, cause after registering DLL manually o got this message “Types registered successfully”, current .net version is C:\Windows\Microsoft.NET\Framework64\v4.0.30319.

            After installing install.vbs, just a cmd prompt appears and dissapears, i dont see tlb file gets created.

            am i missing anything?

  3. Hi saket,

    I am using your API but for some reasons, its not working properly.

    1. print oPDF.GetFieldNames(“C:\sample.pdf”,”C:\res\res.txt”)
    It doesn’t capture any fields name in the res text file. res text file is empty.

    2. Can I get any specific field name and its value from pdf file?
    If you can show syntax with example for GetFieldValue, that would be great help.

    thanks

    Reply
  4. Hi Saket,

    One more issue I noticed.

    Once I run “print oPDF.GetFieldNames(“C:\fw4.pdf”,”C:\res\res.txt”)” statement, and after script stops, I am unable to open the pdf file.

    I shows error “There was an error opening this document. The file is damaged and could not be repaired”

    thanks

    Reply
  5. I tried without Print statement. It captures the field names but it corrupts the pdf file.
    When i try to open pdf file, it shows error “There was an error opening this document. The file is damaged and could not be repaired”

    thanks

    Reply
  6. Can we change the base file path, after adding the File content checkpoint?

    I have moved the base PDFs to a different location and while executing the checkpoint, its showing the error “Cannot identify the object…”.
    Error description shows Warning in referencefilename

    Reply
  7. Hi Saket,

    I have been exploring fileContent checkpoint for sometime but I am still not able to identify how to parameterize both files. At run time one can change the comparison file but no way to change base file. I know we can do comparison using vbscript but wanted to use FileContent as it shows clearly the difference in the results itself.

    Reply
    • I could understand “changing the base file”, it does not compare two files. rather it checks the file again the checkpoint values stored or set by user.
      if you want to set some other parameter, I think you should create another checkpoint.

      Reply
  8. Hi,

    I am using UFT12.50 and wanted to download API but i am unable to get your “LearnQuickTestPDF API”.

    Please send me API.

    Thanks, Prince

    Reply
  9. Hi Saket,

    I have tried you API on a Windows Server 2012R2, but it’s not working, I tried running it from cmd but nothing happens after I accept the terms and conditions. I have the admin rights. Can you help me?

    Reply
  10. Hi Saket,

    1. Is there a way to check all pages at one time? I have 1000 pages in one of my document and needed to check every page checkbox in order for the whole document to get compared. This takes a lot of time and effort.

    2. Can I add pages in my file content? I don’t want to repeat the whole process by adding the file content checkpoint and then add all regular expression lines again. It takes too much time to repeat the process especially if there are quite a number of pages in the file. I just want to update or edit my file content by adding another page inside the file content.

    Reply
    • UFT does not have these options yet for file content checkpoint. I tried with run-time scripting, but no luck. I could not find nay properties.
      I think you should try with scripting way to compare your files instead of file content checkpoint.

      Reply
  11. Hi Saket, i need your help in rectifying one issue.

    I’m using UFT latest version and trying to use File Content Checkpoint. I’m actually trying to compare value by with a value present in the data table.
    Example : My value in the pdf report is “Canada” , instead of comparing it with canada, i want to take the value from datatable during runtime and compare it with the actual result, that is i passed country value as “India” through DataTable. I Selected the value in the pdf report and using parameterization i added Column refernce in the DataTable. But when i execute the code, it shows a mismatch and in the comparision, it shows actual value as -canada and Expected Value as – “DataTable.Value (“Country”,dtGlobalSheet) “instead of the original value present in the column. Please help.

    Reply

Leave a Comment

Your email address will not be published.

Most from this category

Join The Growing Group of 15000+ Test Automation Engineers

Signup for our newsletter and get access to free downloads, as well as tips, tricks and techniques and various test automation resources.
Name
Email Address
Secure and Spam free...