Static programmatic descriptions

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

You can describe an object directly in a statement by specifying property:=value pairs describing the object instead of specifying an object's name.

General syntax

The general syntax is:

TestObject("PropertyName1:=PropertyValue1", "..." , "PropertyNameX:=PropertyValueX")

The method parts include:

TestObject The test object class.
PropertyName:=PropertyValue.

The description property and its value. Each property:=value pair should be separated by commas and quotation marks.

To describe an Insight test object, specify the ImgSrc property, with the PropertyValue providing the file system path or ALM path to an image of the control. (To specify an ALM path to a file located in the ALM Test Resources module, type: [QualityCenter\Resources] Subject\<folder and file name>).

For example, the statement below specifies a WebEdit test object in the Mercury Tours page with the Name author and an index of 3. During the run session, UFT finds the WebEdit object with matching property values and enters the text Mark Twain.

Browser("Mercury Tours").Page("Mercury Tours").WebEdit  ("Name:=Author", "Index:=3").Set "Mark Twain"

The statement below specifies an InsightObject test object in the Calculator window, with the image in the C:\AllMyFiles\Button6.bmp file. This file contains an image of the 6 button. During a run session, UFT finds the area on the calculator that looks like this image, and clicks its center.

Window("Calculator").InsightObject("ImgSrc:=C:\AllMyFiles\Button6.bmp").Click

Back to top

Regular expressions

UFT evaluates all property values in programmatic descriptions as regular expressions. Therefore, if you want to enter a value that contains a special regular expression character (such as *, ?, or +), use the \ (backslash) character to instruct UFT to treat the special characters as literal characters.

Back to top

Variables

You can enter a variable name as the property value if you want to find an object based on property values you retrieve during a run session. For example:

MyVar="some text string" 
Browser("Hello").Page("Hello").Webtable("table").Webedit("name:=" & MyVar)

Back to top

Finding parent test objects

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 parent objects in the hierarchy have been specified using programmatic descriptions, UFT cannot identify the object.

For example, do use:

  • Object repository names for the parent objects and a programmatic description for the object on which the operation is performed:

    Browser("Mercury Tours").Page("Mercury Tours").WebEdit("Name:=Author", "Index:=3").Set "Mark Twain"
  • Programmatic descriptions throughout the entire test object hierarchy:

    Browser("Title:=Mercury Tours").Page("Title:=Mercury Tours").WebEdit("Name:=Author", "Index:=3").Set "Mark Twain"
  • Programmatic descriptions from a certain point in the description (starting from the Page object description):

    Browser("Mercury Tours").Page("Title:=Mercury Tours").WebEdit("Name:=Author", "Index:=3").Set "Mark Twain"

Do not use programmatic descriptions for the Browser and Page objects but then attempt to use an object repository name for the WebEdit test object:

Browser("Title:=Mercury Tours").Page("Title:=Mercury Tours").WebEdit("Author").Set "Mark Twain"

Back to top

Insight test objects

To describe an Insight test object, specify the ImgSrc property, with the PropertyValue providing the file system path or ALM path to an image of the control. (To specify an ALM path to a file located in the ALM Test Resources module, type: [QualityCenter\Resources] Subject\<folder and file name>).

When using programmatic descriptions for Insight test objects, consider the following:

  • The description can contain only the ImgSrc property (mandatory) and ordinal identifier properties (optional).

  • The description cannot contain regular expressions.

  • The file containing the image of the control (specified in the ImgSrc property):

    • must be a non-compressed image file that supports 24 or 32 bits-per-pixel (JPEG, BMP or PNG).

    • must be accessible from any computer that runs the test or component.

  • When running the Click method on an Insight test object defined using a programmatic description, UFT clicks in the center of the control that matches the specified image.

Back to top