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 Advantage Online Shopping page with the name username and the type text. During the run session, UFT One finds the WebEdit object with matching property values and enters the text tutorial.

Browser("Advantage Shopping").Page("Advantage Shopping").WebEdit("name:=username", "type:=text").Set "tutorial"

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 One 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

By default, UFT One evaluates all property values in programmatic descriptions as regular expressions.

When values are treated as regular expressions and you want to include a special regular expression character (such as *, ?, or +) as a literal character, add a \ (backslash) character before the special character.

When writing a description for a test object, you can add a UftIsRegex property to the programmatic description and set it to False. This instructs UFT One to treat the property values in this description as literal strings and not as regular expressions.

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 One 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("Advantage Shopping").Page("Advantage Shopping").WebEdit("name:=username", "type:=text").Set "tutorial"
  • Programmatic descriptions throughout the entire test object hierarchy:

    Browser("Title:=Advantage Shopping").Page("Title:=Advantage Shopping").WebEdit("name:=username", "type:=text").Set "tutorial"
  • Programmatic descriptions from a certain point in the description (starting from the Page object description):

    Browser("Advantage Shopping").Page("Title:=Advantage Shopping").WebEdit("name:=username", "type:=text").Set "tutorial"

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:=Advantage Shopping").Page("Title:=Advantage Shopping").WebEdit("username").Set "tutorial"

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 One clicks in the center of the control that matches the specified image.

Back to top