It is going to be an article on Expert View overview, Step generator and a brief introduction to Checkpoints that will be carried on further until we cover all the details elaborately with examples on how to use these while recording actual scripts. This is the 12th tutorial in QTP training series.
Expert view of QTP –
- Expert view is where the operations we performed on the AUT get displayed as VB Script code.
- For every LOC in this view, there is a corresponding column in Keyword view.
- There is also the action drop down box that can be used to access, view and edit different actions in the test.
- This view is particularly useful for users who are familiar with programming using VB script.
- One of the most important uses of this view is that it facilitates the creation of functions and function libraries. (a topic for detailed discussion later)
- The user can print the test or function library as it appears in this view anytime. File->Print will print the test.
This is how it looks:
You can add statements to this view directly by typing in or by using step generator.
- This is a facility that QTP provides in order to make adding programmatic steps into QTP easy for the user.
- You can use it in the Keyword view, function library, Active screen or Expert view to generate steps
- It can be used to write steps into a test or to a function library.
- To launch, use the menu option “Insert->Step Generator” menu option. Right-click anywhere you want the step to go and select “Insert Step-> Step generator” or F7(except in Active screen)
I will explain this with a scenario: Open www.gmail.com and click on “Create Account” link. This is how this statement will look.
Browser("Gmail: Email from Google").Page("Gmail: Email from Google").Link("Create an account").Click
If I need to check if the link exists at all, before I write the code to click on it, I will need a step before the above statement. This is how I do it:
Step # 1) Select the place where you need the step inserted.
a) Expert view: Place the cursor where you want the step to go and launch step generator.
b) Keyword view: Select the step below which you want to insert the step.
c) Active screen: In the active screen window, right click and choose the step generator option. It will ask you to choose the object on which your step should be based on. Following that the step generator window is launched.
Step #2) This is the step generator window that gets launched. Please note the details that it is displaying now. It is showing all the details related to the step that is currently chosen. We can choose the required values for the new step but that does not affect the current step.
I am going to set the values as required by me to enable checking if the link exists.
As you can see, I chose a Test Object, Create an account link and chose the operation Exist. I left the arguments empty because it is optional and chose that the return value of the operation is stored in a variable var_Exist. It displays the VB Script statement, as it is going to appear in the Expert view in the “Generated Step” field. In other words, the syntax.
Step #3) The drop down where I chose a test object, I can alternately choose to base my step on a utility object or Functions.
Step #4) Object: this field contains a list of required object or the function library source.
Step #5) Operation field will let you choose the appropriate method, property or function.
Step #6) Arguments and Return value: These fields are self-explanatory. The user could parametewise the arguments or provide constant values.
Step #7) The user can just insert one statement or choose to follow it with another one by checking the “Insert another step” option ON.
Step #8) So, back to our example. I will click OK. This is the statement that gets inserted.
var_Exist = Browser("Gmail: Email from Google").Page("Gmail: Email from Google").Link("Create an account").Exist Browser("Gmail: Email from Google").Page("Gmail: Email from Google").Link("Create an account").Click
We have so far encountered in various places of your articles, some references to checkpoints. There are many ways to define what a checkpoint is, this is mine –“It is a logical point in your test where you are trying to establish if there is a match between a certain expected value to the actual value as it exists on the AUT”.
We have talked earlier; QTP provides certain inbuilt checkpoints but does not limit the user to just those. At any point in a test, the tester is free to build any number of checkpoints in this test to include verification points. That according to me is one of the most versatile features in QTP.
It is obvious that custom checkpoints are entirely relative to each one’s problem at hand. We will equip ourselves with basic concepts on the checkpoints that come as an integral part of QTP.
1) When a checkpoint is added, QTP adds a “Check CheckPoint” in the Expert view and a corresponding row in the keyword view.
Browser("Gmail: Email from Google").Page("Gmail: Email from Google").Check CheckPoint("Gmail: Email from Google")
2) The user can have the checkpoint statement return a boolean value that depicts the result of the checkpoint. If it passed, it returns a 1 and 0 if failed. To be able to that, we need to use parentheses around the checkpoint argument in the statement in the Expert View.
i=Browser("Gmail: Email from Google").Page("Gmail: Email from Google").Check(CheckPoint("Gmail: Email from Google"))
3) By default, the name of the checkpoint will be the name of the object on which this check is performed.
4) The user can accept this name or change it
5) When the test runs, if the expected value matches with the actual one for the checkpoint, the checkpoint passes otherwise it fails.
6) The results can be viewed in the Run Results Viewer.
There are 10 checkpoints that QTP provides to its users:
- Standard Checkpoint
- Image Checkpoint
- Bitmap Checkpoint
- Page Checkpoint
- Text Checkpoint
- XML Checkpoint
- Text Area Checkpoint
- Table Checkpoint
- Accessibility Checkpoint
- Database Checkpoint
The general way a checkpoint is inserted is after the initial test steps are created. It is possible to add checkpoints during recording or editing though.
It is recommended that the tester has preliminary knowledge about all the checkpoints in order to make the right judgment about what checkpoint is apt for the task at hand.
We are going to do just that in the next article. We are going to see what each checkpoint does and try to learn how to use them.