QTP Tutorial #14 – How to Add Bitmap and Text Checkpoints in QTP Tests

Let us just continue our journey of familiarizing with the important QTP concept of adding checkpoints in today’s QTP tutorial too. In a previous tutorial, we learned how to add Standard and Image checkpoints in QTP tests.

In today’s QTP training session we will learn how to insert Bitmap and Text Checkpoints in QTP tests.

Bitmap checkpoint

A lot can be inferred from the name of this checkpoint itself.  However, it is often confused with the Image checkpoint.

Differences between Image and Bitmap checkpoints:

Difference #1: Image checkpoint works only on Web environment whereas Bitmap checkpoint works on any supported environments.

Difference #2: Bitmap checkpoint can be used to compare an area of an application

or page, an object or any part of an object. On setting this checkpoint it captures the chosen portion of the screen as a bitmap and compares it with the result at runtime. In contrast, image checkpoint is just for web image objects.

Therefore, Bitmap checkpoint captures the visible parts of your AUT and compares them as bitmaps, pixel by pixel.

Typically this is used to check maps, logos or any other diagrams in your AUT.

A couple of important points to remember:

  1. Bitmap checkpoints are dependent on factors like screen resolution, Operating systems and RGB settings.  So any changes to any of these factors will cause the checkpoint to fail.
  2. When creating the checkpoint, QTP does not record any part that is scrolled off the screen or hidden by any other object.
  3. While capturing the bitmap if another app is overlapping you AUT then that part of the screen is also captured.
  4. It can be added while recording or from the active screen.

Example: I want to create a bitmap checkpoint on the www.gmail.com page’s Google icon.

I start a test with a record and run settings set in a way that it opens www.gmail.com on internet explorer when I record the test. Then I select Insert->Checkpoint->Bit map checkpoint. Then I select the ‘google’ logo on the www.gmail page. The following dialog opens up:

(Note – click on any image to enlarge)

Take a close look at the above window.

a) The image appears in the Bitmap checkpoint properties dialog and then the user has an option to choose either to check for the entire image or choose a selection.

b) If you check on the ‘Check only selected area’ option to be ON, then you will be able to select the portion of the image. Since it is hard to represent it pictorially, I would suggest the readers give it a try practically to see how this works.

c) The other options in the screen are basically the fine tuning properties. They are really there to make sure the checkpoint passes even though certain RGB or pixels are a little inconsistent.

d) There is also a timeout factor that we talked about earlier in the previous article.

I will go ahead and choose a portion of the logo and click OK.

The following statement is generated in the Expert view:

 Browser("Gmail: Email from Google").Page("Gmail: Email from Google").Image("Google").Check CheckPoint("Google") 

Keyword view looks like this:

Once created the Bitmap checkpoint it can be edited later on from the checkpoint properties screen. This dialog can be launched from the Keyword view, expert view or the Object Repository.



Text Checkpoint

There will be many instances during the testing process when the text displayed in the AUT will have to be checked.  ‘Text’ in this context refers to a text string.

One way of doing that is by using a standard checkpoint and checking the “text” property of an object. Let us give that a try. Again I will open the www.gmail.com and check the text that is displayed in the “Check Account” button or link.

I would choose to insert a standard checkpoint from the menu and set the following details:

The statement that it inserts is:

 Browser("Gmail: Email from Google").Page("Gmail: Email from Google").Link("Create an account").Check CheckPoint("Create an account") 

However, QTP provides specific checkpoints to achieve these.

Text checkpoint: We will use the same example and see how Text checkpoint is different from inserting a standard checkpoint over the ‘text’ property.

I chose “Insert->Checkpoint->Text checkpoint” from the menu while recording on the gmail.com page in internet explorer.

The following dialog is displayed:

Let us look at each field in this dialog and understand what role each value we set in this dialog play in our checkpoint.

1) Name: by default a checkpoint’s name is the object’s name on which a checkpoint is placed. The user can change it if required.

2) Class: specifies the type of the object. This is non-editable.

3) Checkpoint summary: An understandable explanation of what this checkpoint does.

Let us look at it as an example. Open a notepad application. First, let us try with one line of text. I will just write test in the entire notepad, insert a text checkpoint and click on the text in the notepad. The following is how this dialog appears:

Now, I will insert two lines of text. So test and test 1 in two lines, look how this text appears in the Checkpoint summary:

4) You can configure the text to specify what is the “Text before”, “Text after” and “Checked Text”.

For instance, if I need to see if ‘test’ appears in the notepad before ‘test1’ the same can be specified by clicking on the ‘Configure’ button above. The following dialog opens up:

5) The next options are to parameterize and to set the rules for comparison. They are pretty much self-explanatory.

A checkpoint statement is inserted into the test once the user sets all the options and clicks OK:

As always, please feel to post questions and comments. We will continue with checkpoints in the next article too.

P.S. You can check out the list of all previously posted QTP tutorials in this series here.