The goal of the present QTP tutorial is to describe:
How to get number of controls (Links, Edits, Images, etc) with QTP DP.
Let's investigate Descriptive Programming on examples.
First of all, we should understand what Descriptive Programming means:
What is QuickTest Professional Descriptive Programming (QTP DP)?
Answer: QTP DP is a run-time processing of objects which are not located in QTP Object Repository.
I've created new QTP script which starts with http://labs.google.com/sets page.
This QTP script is simple enough:
And its result is:
As you can see, it works correctly and returns correct number of Edits on a page.
I'm going to explain this QTP script and answer the following question:
How does QTP Descriptive Programming work?First of all, I've created new Description object:
Description object contains collection of properties, which identify any UI object such as a browser, a page, a dialog, a list, a button etc.
To specify that we want identify all Edits on browser's page I use "micclass" property:
Note: the "mic" prefix in "micclass" stands for "Mercury Interactive Constant".
How do you know the class name ("micclass") of object?
Use Spy for that:
Open QTP object Spy and check recorded properties of object.
For example, these are properties of Edit:
As you can see, there is "Class Name" property and its value - "WebEdit". So, "WebEdit" is a value of Class Name of all Edits located on Web page.
Note: "Class Name" is a synonym of "micclass".
I gathered Class Names of Web objects in this table:
|#||Type of Web object||Class Name(micclass)|
Since we created Description object for all edit boxes, we can use this description to get all specified objects ( = edit boxes).
The next step returns the collection of all child objects (i.e. edit boxes) contained within the page:
To get the number of found objects in a returned collection, we use Count property:
And the result is 5 found Edits on Google Sets page:
So, this is a mechanism of QuickTest Professional Descriptive Programming.
Also, we can use the same code to get number of others objects - Links, Images, Buttons, etc.
For that I modified QTP script:
The result of this QTP script is the following:
You can compare the result with the initial web page (see first image in the present article) and verify that QTP Descriptive programming works correctly - it returns correct numbers of objects.
- I've explained and shown the mechanism of QuickTest Professional Descriptive Programming (QTP DP).
- The present QTP tutorial explains how to get number of different objects - Edits, Links, Images, Buttons, etc.
I hope, that this article has helped you to understand QTP DP.
The future QTP tutorials will cover others questions on QTP Descriptive Programming.
- QTP Descriptive Programming - How to perform operations on objects
- QTP Descriptive programming - Processing images
- QTP Descriptive Programming - How to close browsers
- QTP VIDEO - How to capture dynamic text
- QTP - How to get font size/color, background color and other attributes of controls
- All QTP visual tutorials
Have you got interested materials or your own thoughts on QTP (QuickTest Professional)?
Let's share them and help each other to improve our skills and knowledge!
You can send them to my email:
Thank you in advance, dear readers.