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:
-
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.
-
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.
-
Switch to the Response page (for HTTP traffic) or to the WebSocket Message page (for WebSocket traffic). This page contains the selected server response.
Explore the response data and find the values to check.
-
Use data selectors to extract the needed values and to store them to variables.
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.
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.
-
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).
-
-
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