Dynamic programmatic descriptions

Relevant for: GUI actions, scripted GUI components, and function libraries

You can use the Description object to return a Properties collection object containing a set of Property objects. A Property object consists of a property name and value. You can then specify the returned Properties collection in place of an object name in a statement. (Each property object contains a property name and value pair.)

Create a Properties collection

To create the Properties collection, you enter a Description.Create statement using the following syntax:

Set MyDescription = Description.Create()

After you have created a Properties object (such as MyDescription in the example above), you can enter statements to add, edit, remove, and retrieve properties and values to or from the Properties object during the run session. This enables you to determine which, and how many properties to include in the object description in a dynamic way during the run session.

After you fill the Properties collection with a set of Property objects (properties and values), you can specify the Properties object in place of an object name in a statement.

For example, instead of entering:

Window("Error").WinButton("text:=OK", "width:=50").Click

you can enter:

Set MyDescription = Description.Create()
MyDescription("text").Value = "OK"
MyDescription("width").Value = 50
Window("Error").WinButton(MyDescription).Click

When working with Properties objects, you can use variable names for the properties or values to generate the object description based on properties and values you retrieve during a run session.

You can create several Properties objects if you want to use programmatic descriptions for several objects.

For details on the Description and Properties objects and their associated methods, see the Utility Objects section of the UFT One Object Model Reference for GUI Testing.

Back to top

Regular expressions and programmatic descriptions

By default, the value of all Property objects added to a Properties collection are treated as regular expressions. Therefore, if you want to enter a value that contains a special regular expression character (such as *, ?, +), use the \ (backslash) character to instruct UFT One to treat the special characters as literal characters. For details on regular expressions, see Regular expressions.

You can set the RegularExpression property to False to specify a value as a literal value for a specific Property object in the collection. For details, see the Utility Objects section of the UFT One Object Model Reference for GUI Testing.

Back to top

Programmatic descriptions and the object hierarchy

When using programmatic descriptions from a specific point within a test object hierarchy, you must continue to use programmatic descriptions from that point onward within the same statement. If you specify a test object by its object repository name after other objects in the hierarchy have been described using programmatic descriptions, UFT One cannot identify the object.

For example, you can use Browser(Desc1).Page(Desc1).Link(desc3), because it uses programmatic descriptions throughout the entire test object hierarchy.

You can also use Browser("Index").Page(Desc1).Link(desc3), because it uses programmatic descriptions from a certain point in the description (starting from the Page object description).

However, you cannot use Browser(Desc1).Page(Desc1).Link("Example1"), because it uses programmatic descriptions for the Browser and Page objects but then attempts to use an object repository name for the Link test object (UFT One tries to locate the Link object based on its name, but cannot locate it in the repository because the parent objects were specified using programmatic descriptions).

Back to top