Assertion on response content

Assertions allow checking the validity of the responses content returned by the server. Checks whether or not the server response contains a certain content. The server response is considered valid if all the content conditions are satisfied.

Validation cannot be applied to failed requests (HTTP errors, network errors, and so on).

Available settings

NameDescriptionAccept variableRequiredSince
nameThe name of the assertion.--7.6
xpathThe validation check will be carried out on one of the nodes in the response body. This node is defined using XPath expression.-7.6
jsonpathThe validation check will be carried out on one of the nodes in the response body. This node is defined using JSONPath expression.-7.6
notChecks whether or not the server response contains a certain content.
The default value is "false".
--7.6
containsThe validation check will be carried out on the response headers and body. If "xpath" or "jsonpath" is specified, then the validation is done on the result of the XPath or JSONPath expression.-7.6
regexpThis option allows considering that the "contains" value is a regular expression.
The default value is "false".
--7.6

⚠️ Response validations on XPath or JSON nodes are resource-consuming operations. Only use these types of validation if absolutely necessary.

⚠️ Using global responses validation (from container, transaction and user_paths elements) uses a lot of memory it is therefore recommended to use it sparingly and avoid applying it to large responses.

Example 1

Defining a validation to check if the response body contains the specified regular expression.

Example 2

Defining a validation to check if the response body contains the specified regular expression in using a variable.

Example 3

Defining a validation to check if the response body contains the specified JSON node.

Example 4

Defining a validation to check if the response body doesn't contain the specified text from a specified XML node.