Patterson Consulting is Closing

Patterson Consulting, LLC of Tennessee is in the process of closing and all operations will cease effective March 1, 2022. Please refer to our company page or FAQ for details.


Variables Tool Window


Variables are placeholders for other information that you can use in your Activity Calls instead of explicitly defining values.

There are four types of variables:

System Variables
Read-only Variables related to the current system (e.g. Date/Time, File System).
Environment Variables
Read-only Variables defined in one or more external files commonly used to store environmental data.
Session Variables
Read-only Variables related to the currently executing automation session.
User-Defined Variables
User-defined Variables created specifically for the current Scenario, Process, or User Activity.

Browsing Variables

AutoBloks provides many Variables for commonly-used information. When you launch AutoBloks, the Variables tool window can be used to browse the available Variables.

The Variables tool window lists the name of each Variable as well as the current value (if available) so that you have a better understanding of the data being represented. Select any Variable in the tool window and a description will also be displayed in the Variable Properties section at the bottom of the tool window.

Using Variables

Variables are primarily used as Input and Output Arguments for Activity Calls and Process Calls, but can also be used for Element Identification. AutoBloks uses a special Expression Syntax to allow Variables to be used in place of or in combination with standard text values.

For example, the following screen shows an input argument of an Activity Call where the Url argument is explicitly defined as

Input Argument With Explicit Text

Instead of hard-coding that value, a Process Variable called Url was created instead, and the value of that Variable was assigned to The previously hard-coded entry can now be replaced with the Variable using the expression {Url} as shown below:

Input Argument With Variable

Working with Variable expressions is easy with many ways to pick the right variable!

  • From the Variables tool window, you can use the Copy command on any Variable to place the variable expression on the clipboard
  • You can drag-and-drop any Variable from the Variables tool window to any text box control to insert the variable expression
  • Start typing and an auto-complete list of potential Variable name matches will be presented for you to select from (where supported)
  • Click the drop-down arrow to the right of supported controls to be presented with a menu of Variables from which to choose.

Refer to the Expressions topic for details on more complex Variable usage, including the ability to use multiple variables for a single field and how to directly use the characters { and } without them being treated as expressions.

User-Defined Scenario and Process Variables

Creating Variables specifically for a Scenario or Process can help you reduce data duplication and improve future maintenance. If you ever find yourself entering the same value more than once, consider replacing it with a Variable instead.

Creating a User-Defined Variable

To create a new user-defined variable, you will first need to make sure your Scenario, Process, or User Activity is open and is the selected document. You then click the New Variable button on the toolbar at the top of the Variables tool window.

Using the Variable Properties section at the bottom of the Variables tool window, give your Variable an appropriate Name. Optionally, you can also provide a Default Value and a Description to better understand the purpose of your Variable. If you do not provide a default value, you will need to assign a value at run-time or allow a value to be passed as a parameter (see below).

When naming your variable, the name must start with a letter (i.e. A-Z or a-z) or underscore (_) character. After the first character, the name can continue to include letters, underscores, but also digits (i.e. 0-9). The curly brace characters { or } you see throughout the application at the beginning and end of your Variable name are special characters used when working with expressions and are automatically displayed as part of the variable name in the Variables tool window.
The suggested naming convention for variable names is to begin each word with an upper-case letter followed by lower-case letters. Examples: FirstName, SocialSecurityNumber, Url, InvoiceNumber, EvenLongNamesCanBeEasilyReadThisWay. This convention is referred to as "PascalCase" or "UpperCamelCase".

Modifying a User-Defined Variable

To modify any User-Defined Variable, select the Variable in the Variables tool window and the editable information will be displayed in the Variable Properties section at the bottom of the tool window. There you can rename the Variable or edit the Default Value and Description.

Assigning a Value at Run-Time

A User-Defined Variable is frequently used to store information during run-time. There is a special Activity named Set variable that can be called from your Process or User Activity to assign any value to your variable.

Deleting a User-Defined Variable

If you no longer need a previously defined Variable, you can delete it. Select the Variable in the Variables tool window then click the Delete Variable button on the toolbar at the top of the Variables tool window.

Make sure your Variable is not in use before you delete it. Your Scenario, Process, or User Activity will fail to playback properly if it attempts to access a Variable that does not exist.

Promote Variable to Parameter

A Process call be called from a Scenario and a User Activity can be called from a Process or other User Activities. Often, you will need to pass data to these items and sometimes receive data back. One or more of the variables defined in the called item can be prompted to an Input or Output parameter to allow this data to pass.

Environment Variables

Creating a User-Defined Process Variable for common or widely used data (like user names or system URL's) can be repetitive and result in a lot of maintenance if those values need to be updated. Environment Variables are repositories of one or more user-defined variables that can be loaded by AutoBloks to be accessible by any Process. If the value ever needs to be modified, it can be modified in one location without having to update all the Processes that use it.

File Format

Environment Variables are defined in an XML-formatted file (refer to W3Schools Tutorial if you need assistance with XML). The following is the minimum necessary to define a single environment variable in a file:


Look Familiar?

If this format looks familiar, we intentionally used the same file format used by Micro Focus Unified Functional Testing (UFT) to allow data to be shared with the popular tool.

While the above shows the minimum definition necessary for a variable, additional values can optionally be provided for more detail and organization:

A short description or summary of the purpose of the variable. This information will be displayed in the Variable Properties section of the tool window and can help you and others understand the purpose of the variable.
A category can be used to group related variables under a common category. You can specify a single category (e.g. Credentials) or you can create a hierarchy of categories by separating each category with a backslash character (e.g. Credentials\Billing).

The following is a more complete example of environment variables defined in a file:

        <Description>The URL of the application under test.</Desktop>
        <Description>The user name of the billing account with admin rights.</Desktop>
        <Description>The user name of a test account simulating a customer of the billing system.</Desktop>

Managing Environment Files

Once you have defined environment files within files, you will need to instruct AutoBloks to load those files.

If you work on a team, consider storing your environment variable files on a shared network drive so everyone can use the same data and you have a single source to update if values change.

Open the AutoBloks Options Dialog

  1. Select File on the Ribbon Command Bar.
  2. Select Options from the Ribbon Backstage Menu. The AutoBloks Options dialog will now be displayed.
  3. Select the Data tab.

Options Dialog Run Tab

The following commands are available on the AutoBloks Options dialog:

Adds a new environment repository by prompting you to select one or more files containing environment variables.
Removes the select repository file.
Reloads the repository in the contents of the file have changed since the file was added or the application was launched.
Moves the selected repository up or down in scope. The higher in the list, the higher the scope. If the same variable is defined in multiple files, the variable that is lowest in scope (i.e. lowest in the list) will be used.

Understanding Variable Scope

Variables can be defined through multiple sources. Since variables are referred to by name, what happens if more than one variable is defined with the same name? When this happens, variable defined in the lowest scope will be used. The following outline variable scope from highest to lowest:

  1. System Variables
  2. Environment Variables (by the order each file is defined)
  3. Session Variables
  4. User-Defined Variables for the current Scenario, Process, or User Activity

For example, there is a built-in System Variable called CurrentDate. If you also defined an Environment Variable with the name CurrentDate, the value used by AutoBloks during playback will correspond to the value defined by the Environment Variable since it is lower in scope than a System Variable.

The Variables tool window displays each group of variables in order of scope from highest to lowest (i.e. System Variables at the top, Process Variables at the bottom).
User-defined variables in a Scenario, Process, or User Activity are limited to item in which they are defined. For example, a user-defined variable for a Scenario will not be exposed to any Process that is called by the Scenario. Likewise, user-defined values for a Process cannot be accessed by a User Activity called from that Process. To allow data to cross these boundaries, you will need to pass the data to/from the called item:
  1. Create a corresponding user-defined variable in the Process or User Activity being called.
  2. Promote the variable as an Input Parameter.
  3. When calling the item, populate the Input Parameter with the desired User-Defined Variable.
Patterson Consulting, LLC of Tennessee is in the process of closing and all operations will cease effective March 1, 2022. Please refer to our company page for details.