Saturday, January 19, 2013

File Content Checkpoint

File Content Checkpoint

QTP 11.50 or UFT 11.50 introduced File Content Checkpoints. You can compare the contents (one line, multiple lines, or the entire document) of a file (PDF, HTML, Word, TXT, and RTF) that is generated during a run session with the contents of a source file with the help of File Content Checkpoint. Lets checkout a very simple example of File Content Checkpoint.

I have two text files as shown below:



We will compare these files with the help of File Content Checkpoint.

-Open a new test or do CTRL+N.
-Go to Action tab.
-Click on Design -> Checkpoint -> File Content Checkpoint.
-Source File for Checkpoint dialog opens.
-Select file1 (as a source file) and click Open.
-File Content Checkpoint Properties dialog opens.



-Click on Checkbox left to Page 1.
-Select file2 (which we want to compare) in the Comparison file path.
-Click OK to close the File Content Checkpoint Properties dialog.
File Content Checkpoint is added.



-Click Run or F5.
The test will fail as expected because our files (file1 and file2) are different.
See how in the results, QTP shows the difference by highlighting it under Captured Data. You can see the two parts below: File Content Text (Expected) and File Content Text (Actual).



Below are the results when the contents of both the files are same:



Now lets make a little change in the two text files we have. Above we compared all the lines in a file. Below we will compare just one line.



-I have moved 524 at the top in file2.
-Open a new test or do CTRL+N.
-Go to Action tab.
-Click on Design -> Checkpoint -> File Content Checkpoint.
-Source File for Checkpoint dialog opens.
-Select file1 and click Open.
-File Content Checkpoint Properties dialog opens.



-Check the Checkbox on the left of 524 and select file2 (which we want to compare) in the Comparison file path.
-Click Ok.
-Run the test.



Now what do you infer from the results?