Pages

Friday 12 July 2013

QTP Tutorial #13 – Steps to Insert Standard and Image Checkpoint in QTP Tests


In the previous QTP training session we listed all the checkpoints that QTP provides. All these checkpoints are very important to insert verification points in QTP tests to check if current and expected values of an object match or not. This determines the PASS or FAIL status of that test.
In today’s tutorial we will deal with QTP standard and image checkpoints in detail.

Standard Checkpoint:

1) It is used to check the Object Property value.
2) Compares the expected value with the actual value during runtime.
3) It can be set during recording or editing a test.
4) Active screen can also be used to insert this checkpoint. It is important that sufficient information be available in the active screen to be able to insert a checkpoint.
For Example: If there is a screen with, Login edit box, Password Edit box, OK, Cancel and Help buttons. We need to check if the Cancel button is visible. We are trying to achieve this by placing a checkpoint on the “Visible” object property of the Cancel button. While recording I performed a enter Login, enter password and click OK; and the setting on my active screen is to just store the objects I acted on and not the others, I will not be able to place the checkpoint on the cancel button because the active screen does not possess information about that object. Therefore, it is important for the active screen to have captured all the objects in the page and only then we can insert the checkpoint. I hope this explains what I mean when I say that the active screen should have sufficient information.
5) Once added, the checkpoint properties can be changed using the “Checkpoint Properties” dialog box.
6) Every checkpoint gets added to the local object repository when added. It can be moved to the shared object repository if needed.
7) Supported for all the environments as long as the appropriate add-ins are loaded.
8) Some examples of the objects that this can be used on are: web images, Edit boxes, static text, web tables etc.
How to insert a standard checkpoint while recording:
Step #1) Insert->Checkpoint: Select this option from the menu after starting a record session.
Step #2) Standard checkpoint icon – Clicking on this icon also results in the same thing.
Step #3) A list of relevant checkpoints applicable to the current or selected step on performing one of the steps listed in 1 and 2.
Standard checkpoint
Step #4) Select the type of checkpoint. We will select “Standard” in our case.
Step #5) QTP interface gets hidden and the user can choose the object in the AUT over which the user wants to insert a checkpoint.
Step #6) Select the object and the following screen appears:
Standard checkpoint 1
Step #7) Choose the object and click OK in the dialog. The checkpoint properties dialog box is displayed.
Standard checkpoint 2
Step #8) Select the properties you want checked and click OK. I am going to choose just the name. As you can see above, you can modify the properties to to either a constant value or parameterize. There is also a timeout parameter that you can set. What this means is that, QTP waits for the particular number of seconds specified in this dialog for a certain Object to attain a property value before it performs the check.
Step #9) This is how I set the parameters and click OK.
Standard checkpoint 3
Step #10) This is how my checkpoint looks in the keyword view: (click to enlarge image)
Standard checkpoint 4
Step #11) In the expert view, the following code gets displayed:
1
Browser("Gmail: Email from Google").Page("Gmail: Email from Google").WebButton("Sign in").Check CheckPoint("Sign in_2")
How to insert a Standard checkpoint while editing:
1) Active Screen:  In the active screen, right on an object and select the option to insert standard checkpoint. After that, follow the same steps as above to insert a checkpoint. (click to enlarge image)
Standard checkpoint 5
2) At any step in the QTP test, select the menu option “Insert->Checkpoint” and choose “Standard checkpoint”. Again follow the steps as above.
How the checkpoint properties can be accessed and modified
After creation, the user can modify a checkpoint as required. This can be done through the “Checkpoint properties” dialog box. This dialog can be accessed in the following ways:
1) While creating a checkpoint this box opens up for initial definition of the properties
2) Select an existing checkpoint statement in the Keyword view, right click and select “Checkpoint properties”
3) Open the Object repository and the properties are available there are shown below: (click to enlarge image)
Standard checkpoint 6
From this box, all the properties of a checkpoint can be modified as required.
Since the standard checkpoint is the first in our list I have provided the detailed steps of adding it in different scenarios and modifying it in different ways in detail. Moving forward I am going to list the properties and features that are unique for each checkpoint. It should be noted that the steps to add, use and manipulate the checkpoints are all the same for most of the checkpoints. From now on, unless specifically mentioned, the above approach can be used generically across the other ones too.

Image Checkpoint:

A slight variation of a standard checkpoint is while it is used on web images.
In case the object on which the checkpoint inserted happens to be a web image, the following dialog box opens up.
Image Checkpoint
It should be noted that this screen is almost identical to “Checkpoint Properties” dialog, it is specific to images.
The only extra parameter is the “Compare Image Content” checkbox. If it is checked, the image in run time is checked with the one stored during the creation of the checkpoint to see if it is exactly the same. If they are the same, the test results will only have one image. If they are different both the images will be displayed in the test results.
For example, on the gmail page, I tried to insert a standard checkpoint on one of the images from the Active screen and this is what gets displayed: (click to enlarge image)
Image Checkpoint 1
I will not make any changes in the dialog, you can if you wish to and click OK.
This is how the inserted checkpoint is going to be: (click to enlarge image)
Image Checkpoint 2
The expert view code:
1
Browser("Gmail: Email from Google").Page("Gmail: Email from Google").Image("nosign-r42").Check CheckPoint("nosign-r42") 
That is all for today! We will continue with the other checkpoints in further session. Please feel free to post your questions.

No comments: