Static programmatic descriptions

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

You can describe an object directly in a statement by specifying properties and property values instead of specifying the object's name.

General syntax

Describe an object directly in a statement by specifying pairs of property names and values. Property name and value pairs are separated by commas, and each pair must be enclosed with double quotation marks.

Use the following syntax to specify properties and property values for an object's description:

TestObject("PropertyName1:=PropertyValue1", "...", "PropertyNameX==PropertyValueX")
TestObject The test object class.
PropertyName:=PropertyValue

The description property name and its value.

UFT One treats the property value as a regular expression if you define a property in this format.

To include a special regular expression character (such as *, ?, or +) as a literal character, add a \ (backslash) character before the special character.

PropertyName==PropertyValue

The description property name and its value.

UFT One treats the property value as a literal string if you define a property in this format.

Example: Suppose you are testing the following table in an SAPUI5 application. The table object names differ between two versions.

In version 1.71, the table object name is Products. However, in version 1.96, the table object name is __table0.

You want to write a script that runs on the two versions of the application and does the following:

Set a new product ID for Notebook Basic 15 and select all the rows.

In this case, you can use the programmatic description syntax to instruct UFT One to perform a Set method for the WebEdit object whose default value is equal to HT-1000, and perform a SelectAll method on the SAPUITable whose name either matches the Products string or the __table0 string.

Copy code
Browser("Samples - Demo Kit - SAPUI5").Page("Samples - Demo Kit - SAPUI5").WebEdit("default value==HT-1000").Set "abc"
wait 2
Browser("Samples - Demo Kit - SAPUI5").Page("Samples - Demo Kit - SAPUI5").SAPUITable("name:=(Products)|(__table0)").SelectAll

UftIsRegex property

When writing a description for a test object, you can instruct UFT One to treat all the specified property values of an object as literal strings. Create an object description using PropertyName:=PropertyValue pairs. Then add the UftIsRegex property and set its value to False.

For example, when running the following statement, UFT One finds the WebEdit object with the name username and the type text, and enters tutorial in the object.

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

The UftIsRegex property applies to all property values of the object description.

Using PropertyName:=PropertyValue and PropertyName==PropertyValue pairs, you can create a more flexible and accurate description.

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

Describing 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 or ALM Test Plan module, type: [ALM\Resources] Resources\<folder and file name> or [ALM]Subject\<folder and file name>).

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

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