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 any time. File->Print will print the test.
You can add statements to this view directly by typing in or by using step generator.
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 any where you want the step to go and select “Insert Step-> Step generator” or F7(except in Active screen)
Example:
I will explain this with a scenario: Open www.gmail.com and click on “Create Account” link. This is how this statement will look.
1
| Browser("Gmail: Email from Google").Page("Gmail: Email from Google").Link("Create an account").Click |
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 be 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 #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.
1
2
| 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 |
Checkpoints
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 check points in his 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.
Example:
1
| Browser("Gmail: Email from Google").Page("Gmail: Email from Google").Check CheckPoint("Gmail: Email from Google") |
Example:
1
| i=Browser("Gmail: Email from Google").Page("Gmail: Email from Google").Check(CheckPoint("Gmail: Email from Google")) |
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
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.
No comments:
Post a Comment