Work with controls without learning them into the Object Repository

Programmatic descriptions, also known as "Descriptive Programming" (DP) approach, can be very useful if you want to perform an operation on an object that is not stored in the object repository. You can also use programmatic descriptions in order to perform the same operation on several objects with certain identical properties, or in order to perform an operation on an object whose properties match a description that you determine dynamically during the test run.

The syntax of the programmatic description is

<TestObject>("Property Name1:=Property Value1", "Property Name 2:=Property Value 2")

where TestObject is the class of the test object, and Property Name:=Property Value is the description of the object, separated by commas.

Example: WebEdit("Name:=Author", "Index:=3").Set "Mark Twain"

This line creates a WebEdit test object and sets the description of the object as follows:

  • Name of the object is "Author"
  • Index of the object is "3"


Window("regexpwndtitle:=Notepad").Dialog("regexpwndtitle:=Find").WinEdit("AttachedText:=Fi&nd what:").Set "hello"

This line creates a Window test object and assigns a child object of type dialog to it. A child of type edit is assigned to the dialog object.

Tip: If there is a need to use the same parent in many script lines it is better to assign the parent object into a variable and use the variable instead.


‘ Instead of writing
Window("regexpwndtitle:=Notepad").Dialog("regexpwndtitle:=Find").Move 50, 50
Window("regexpwndtitle:=Notepad").Dialog("regexpwndtitle:=Find").WinEdit("AttachedText:=Fi&nd what:").Set "hello"
Window("regexpwndtitle:=Notepad").Dialog("regexpwndtitle:=Find").WinButton("Text:=&Find Next").Click

‘ Write
Set w = Window("regexpwndtitle:=Notepad").Dialog("regexpwndtitle:=Find")
w.Move 50, 50
w.WinEdit("AttachedText:=Fi&nd what:").Set "hello"
w.WinButton("Caption:=Find next").Click

Alternatively, you may use the following format:

With Window("regexpwndtitle:=Notepad").Dialog("regexpwndtitle:=Find")
.Move 50, 50
.WinEdit("AttachedText:=Fi&nd what:").Set "hello"
.WinButton("Text:=&Find Next").Click
End with

Important: One cardinal rule to follow when creating descriptive programming statements is in regards of hierarchy to use (parent/child relationship, who is the parent for X object), if encountering identification problems, HP strongly recommends using the hierarchy displayed by Object Repositories (when objects are captured/recorded/learned for a script/test). Any other order may work or not, unless indicated by HP on special scenarios, the recommendation above is a must.

For more information on using descriptive programming (DP), please refer to the "Programmatic Descriptions" section in the User’s Guide:

  • QTP: Defining Functions and Other Programming Tasks > Working in the Expert View and Function Library Windows
  • UFT: GUI Testing Design > Programming in GUI Testing Documents in the Editor > Concepts

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s