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.
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 the 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:
- 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.
- When creating the checkpoint, QTP does not record any part that is scrolled off the screen or hidden by any other object.
- While capturing the bitmap if another app is overlapping you AUT then that part of the screen is also captured.
- It can be added while recording or from the active screen.
For 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.
#1) 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.
#2) 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.
#3) The other options on 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.
#4) 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:
- 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
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.
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.
- 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 as an example. Open a notepad application. First, let us try with one line of text. I will just write a 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 at 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:
- Text checkpoints can be added while recording, editing or from the 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 the text directly from an object in cases when it is handwritten 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.