Adding Contains as a verification type in a Visual test

Micro Focus Contributor
Micro Focus Contributor
1 0 445

Verifications allow for items to be validated as the script executes. In Visual tests, there is a predefined list of verification types that can be used. This list has been extended to include Contains and Does not Contain functionality for text types.
These new types can be used wherever a condition can be created, for example in if statements, in verifications, or in repeat loops. They have also been added as a function that can be used in an expression.

Using 'Contains' in a Verification

In this example, the text control of Notepad has been selected and the verification is being created against the text control. The Select the condition now includes two extra entries, Contains and Does not Contain.

Figure 1: Contains and Does not Contain condition types.

This creates a step in the Visual test that looks something like this

The Condition Designer allows you to change the type of Verification. You can change the type by editing the value in the Operator column.

Figure 2: Condition Designer allows editing.

Conditions in other statements

Since these new types are an extension of the condition types that are available to a Visual test, these types can be used wherever conditions can be defined, for example if statements and repeat loops. 


To complement this functionality in conditions, a new function has also been created for use in expressions using the Expression Designer. The function is named Contains() and takes two string parameters, the string in which to search and the string to search for. The function returns true if the string was found or false if it was not found.

Figure 3 : Using Contains() in the Expression Designer


The addition of this functionality gives Visual test users more flexibility when validating their application or when making decisions based on data.

The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.