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

Let us just continue our journey of familiarizing with important QTP concept of adding checkpoints in today’s QTP tutorial too. In 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 run time. In contrast, image checkpoint is just for webimage 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.

Couple of important points to remember:

  1. Bit map 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 bit map checkpoint on the www.gmail.com page’s Google icon.

I start a test with 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)

QTP Bitmap checkpoint

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.

  • RGB tolerance: Once set this value will determine how many RGB values of the pixels can be different for the checkpoint to not fail.
  • Pixel tolerance: when this option is checked on, the user has to select whether he wants to specify this value in % or a number. For example, if the user chooses 5 pixels and the image has 1000 pixels.  If in run time, up to 5 different pixels the differences are not counted towards failing the checkpoint. If more than 5 differences exist, only then the checkpoint fails.  If both RBG tolerance and Pixel tolerance values are set, RGB tolerance is calculated first.

d) There is also a time out factor that we talked about earlier in 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:

QTP Bitmap checkpoint

  • In case there is a difference in the image in runtime, the checkpoint fails and the two images (one saved, one that came up during runtime) are displayed in the test results.
  • This feature can be configured from: Tools->Options->Run->Screen capture

QTP Bitmap checkpoint

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:

QTP Text Checkpoint

------------

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:

QTP Text Checkpoint

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.

  • For web applications it displays the text that is within the object in red. Refer to the dialog above.
  • For a windows application, it displays the text you selected while creating the checkpoint.
  • Also for a windows application if you selected a text that is more than one line, then summary area displays [Complex value].

Let us look at it with an example. Open a note pad 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:

QTP Text Checkpoint

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:

QTP Text Checkpoint

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:

QTP Text Checkpoint

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:

  • Text checkpoint can be added while recording, editing or from active screen.
  • Once created, all the properties can be modified from the checkpoint properties window that can be accessed from keyword view, expert view or OR.
  • Text checkpoint works in most of the environments unlike text area checkpoint that works only in a windows environment. We will get to it next.
  • In case QTP cannot retrieve text directly from an object in cases when it is hand written stuff that is scanned and put as an image, it employs OCR to identify the text.

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.



The Best Software Testing Training You'll Ever Get!

software testing QA training

7 comments ↓

#1 Ravindra on 04.28.13 at 8:48 pm

Hi. This is really good tutorial. I have few doubts of image and bitmap checkpoints. If you could answer that would be great.

1) Which checkpoint (image or bitmap) need to be used to check type of a image file?

2) Which checkpoint can be used to check part of a image from source to destination?

#2 Swati on 04.29.13 at 12:47 am

@Ravindra: 1. If its an image file in the webpage you would go with Image checkpoint
2. For checking a part of an image, bitmap checkpoint is the way to go.

#3 Pallavi on 04.30.13 at 1:56 pm

thanks for clearing the difference between image and bitmap checkpoints

#4 chandrasekar on 05.03.13 at 8:45 am

can any one send the link to download QTP 11.0 full version……

pcs06@hotmail.co.uk this is my mail id

#5 teena on 10.12.13 at 2:07 pm

i am a newbiee to QTP, and trying to learn it through online resources. I came across this wonderful site explainig the concepts in detail with relevant examples.

while trying to work out with the above mentioned text checkpoint, i.e., trying to select the ‘Create an account’ button object, the QP is throwing the error as below:

Logical Name:Gmail:Email from Google
Class:Page

Cannot create Text checkpoint
cannot retrieve text for this object

Can you please let me know why this error is popping up everytime i try to select the button.Awaiting your response

#6 Deepthi on 10.24.13 at 7:34 am

Hi Teena,

Even I encountered a similar error while inserting standard checkpoint while QTP is in recording mode. I stopped recording and then resumed with inserting the checkpoint and then it worked fine.

#7 Anick on 12.06.13 at 6:38 pm

Thanks much for your descriptive ideas and thoughts.

Leave a Comment