Comments (image map) Parameters (image map) Parenthesis (image map) Calculations (image map) Variables (image map)


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

You can specify variables to store test objects or simple values in your action, scripted component, or function library. When using a variable for a test object, you can use the variable instead of the entire object hierarchy in other statements. Using variables in this way makes your statements easier to read and to maintain.

To specify a variable to store an object, use the Set statement, with the following syntax:

Set ObjectVar = ObjectHierarchy

In the example below, the Set statement specifies the variable UserEditBox to store the full Browser.Page.WebEdit object hierarchy for the username edit box. The Set method then enters the value tutorial into the username edit box, using the UserEditBox variable:

Set UserEditBox = Browser("Advantage Shopping").Page("Advantage Shopping").WebEdit("username")
UserEditBox.Set "tutorial"

Note: Do not use the Set statement to specify a variable containing a simple value (such as a string or a number). The example below shows how to define a variable for a simple value:

MyVar = Browser("Advantage Shopping").Page("Advantage Shopping").WebEdit("username").GetTOProperty("type")

You can also use the Dim statement to declare variables of other types, including strings, integers, and arrays. This statement is not mandatory, but you can use it to improve the structure of your action, scripted component, or function library.

Example: The examples below demonstrate using the Dim statement to declare a variable:

In an action or scripted component (using the TrackingNumber variable):

Dim TrackingNumber
TrackingNumber = Browser("Advantage Shopping").Page("Advantage Shopping").WebElement("trackingNumberLabel").GetTOProperty("innertext")

In a function libraries (using the actual_value variable):

Dim actual_value
	' Get the actual property value
	actual_value = obj.GetROProperty(PropertyName)