Tuesday 3 April 2012


How does QTP Descriptive Programming work?
First of all, I've created new Description object: 
Set Desc = Description.Create()
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:
Desc("micclass").Value "WebEdit"
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:
QTP Object Spy
Open QTP object Spy and check recorded properties of object.
For example, these are properties of Edit:
QTP Object Spy - recorded properties
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 objectClass Name(micclass)
1Web BrowserBrowser
2PagePage
3Edit boxWebEdit
4ImageImage
5LinkLink
6Web ElementWebElement
7ButtonWebButton
8CheckboxWebCheckBox
9Combobox (DropDownList)WebList
10TableWebTable


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:
Set Links = Browser("Google Sets").Page("Google Sets").ChildObjects(Desc)

To get the number of found objects in a returned collection, we use Countproperty:

MsgBox "Number of Edits: " & Links.Count

And the result is 5 found Edits on Google Sets  page:
Number of Edits

No comments:

Post a Comment