Creating Validation Rules

Applies to LoadComplete 4.97, last modified on May 20, 2019

This topic explains how to create validation rules that verify data of server responses.

Creating Validation Rules

To check the contents of a server response, you have to configure your user scenario so that LoadComplete extracts the desired value from the response to a variable and then verifies the variable with a validation rule:

  1. Open your user scenario for editing. To do this, right-click the Scenarios > Your_Scenario item in the Project Explorer and then click Edit. LoadComplete will open the scenario in the Scenario editor.

  2. In the Scenario Explorer, select the needed request (for HTTP scenarios) or server message (for WebSocket scenarios).

    You can use the Find dialog to find the needed request or message faster.

  3. Switch to the Response page (for HTTP traffic) or to the WebSocket Message page (for WebSocket traffic). This page contains the selected server response.

    The Response Page of the Scenario Editor

    Click the image to enlarge it.

    Explore the response data and find the values to check.

  4. Use data selectors to extract the needed values and to store them to variables.

    Save Response Data to a Variable

    Click the image to enlarge it.

    If you are testing a Rich Internet Application like Adobe Flash, Flex or Microsoft Silverlight, to save a value to a variable, specify the needed variable in the Variable column on the Response Body tab.

    Save Response Data to a Variable

    Click the image to enlarge it.

    If needed, in the Convert column, specify a decoding or encoding rule for the extracted value (this way, you will prepare the extracted value for comparison). See Converting Correlation Data.

    To learn more about retrieving values from server responses, see Extracting Data From Responses.

  5. On the Validators tab, specify the validation condition:

    • Right-click somewhere within the tab and then click New Item. This will add a new condition.

    • In the Variable column, specify the variable whose value you want to check.

    • In the Variable or Value column, specify the baseline value against which you want to check the specified variable, or the variable that stores the baseline value.

      When specifying the baseline value, you can enter numbers, strings, date/time values, boolean values (true/false) and other values of simple types. Below you can find some tips on specifying baseline values.

    • In the Condition column, select a comparison operation (Equals, Does not equal, Contains, Does not contain).

      Specifying Validation Parameters

      Click the image to enlarge it.

  6. Select File > Save from LoadComplete main menu to save the changes.

    The validation rule is ready.

Notes on Specifying Baseline Values

  • You can validate simple data types:

    • Strings

    • Long strings

    • Numbers

    • Date/time values

    • Boolean values (true/false)

    To verify complex data like objects or arrays, use individual rules for object properties or array items. Validation of binary data is not supported.

  • LoadComplete does not support wildcards and regular expressions in baseline data.

  • Do not enclose baseline strings in quotes.

  • Important:┬áThe format of baseline data must match the format the server uses in the response. This format may differ from the format, which you use on your computer.

    • The date/time format the server uses can differ from the format you use on your computer. For example, you may use the 12-hour time format (am/pm) while the server can return time in the 24-hour format. The date format can also differ. For validation to pass, use the format that the server uses.

    • Use the same character for the decimal point in floating-point values as the server uses.

    • Use the same thousand separator in numeric values as the server uses.

    • Use the same capitalization for True and False values as the server uses.

    To determine the data format, which the server uses, explore the response contents on the tabs of the Response page.

  • You can create multiple conditions that will check the same response against several values.

See Also

Validating Response Contents
Using Variables
Extracting Data From Responses
Checking Whether a Server Response Contains Specific Text

Highlight search results