How to capture Checkpoint return value?

For those who are new to QTP, let me tell you a key functional testing feature provided by QTP - Checkpoint. The definition as per QTP Help is "A checkpoint is a verification point that compares a current value for a specified property with the expected value for that property. This enables you to identify whether your application is functioning correctly. "



For eg: lets go to Google.




We see three links right of the search box. We will add a check to see if the text "Preferences" is present between the links "Advanced Search" and "Language Tools". QTP provides a feature called as Text checkpoint to accomplish this. So in QTP, we will click on Insert -> Checkpoint -> Text Checkpoint








Next we will click on the "Preferences" Link in Google. We would see that the checkpoint properties would be as shown below
Now you would see that your line of code in QTP would be

Browser("Google").Page("Google").Check CheckPoint("Google")
So far so good..... Your test result will show "Pass" if the checkpoint passed. QTP makes use of the "Check" method to work on a checkpoint. The return type for the Check method is a boolean value, meaning this would return a true or false. If it returns true, your results would show pass and if it returns false, your results would show a fail.
Ok...now to the topic related to the title of this post.... what if we want to capture this return value...!!!
Lets try the following...
retVal = Browser("Google").Page("Google").Check CheckPoint("Google")
Oops....what happened....




If you want to retrieve the return value of a checkpoint, you must add parentheses around the name of the checkpoint in the statement. When you call a function and expect a return value you must add parantheses. So your new statement would be
retVal = Browser("Google").Page("Google").Check(CheckPoint("Google"))
MsgBox retVal


This would give the message box with value True.
Hope this helped you all. Keep blogging. As always..

I dont want to have any sort of copyright or copyleft in this site but if you are reusing this code in any other site, I would appreciate you to provide this page as a link so that others get a more descriptive explanation of this concept. Your suggestion and comments are always welcome. Cheers !!!
As always,
Your friend in need,

George, Reju

Read Users' Comments (1)comments

1 Response to "How to capture Checkpoint return value?"

  1. Anonymous Says:
    August 29, 2016 at 6:07 AM

    You just saved my day. Thanks!

Post a Comment

Visitors

Website Counter