Skip to main content

Verification Snippets in Katalon Studio

Katalon Studio supports the ability to write verification scripts directly in the details of the web service object. The Verification Snippets reduces the time of going back and forth between the test case and the request object to add test scripts. Verifying the response can be done instantaneously.

To access the Verification snippets, click on the Verification tab of the web service request object.

Snippets

Using Verification Snippets

When you click on one of the available snippets, Katalon Studio automatically generates a snippet for you.

Note:
  • The generated snippet is only an example. You should not try to use them immediately without making adjustments to match your needs.

You can also verify the data of the XML or JSON response body. To add these verification scripts, in the Response panel, switch to JSON or XML response body, select the data, and press key combination Ctrl / Command + K.

verify data of JSON response body

Katalon Studio compares the values in the response body with the predefined values in verification scripts.

Once the verification snippets are generated, you can use them in either your current web service request object or in your test case.

  • In the web service request object, click on the drop-down of Test Request and select Test Request and Verify.

    test request and verify

    This action sends the current request and also executes verification snippets. Verification logs executed using verification snippets are displayed on the Verification Log tab. If you do not want to send a test request using current verification snippets, then just click on Test Request.

    test request

  • In a test case, use the WS.sendRequestAndVerify keyword. This keyword also sends the current request and executes verification snippets. For example:

    WS.sendRequestAndVerify(findTestObject('Your_Test_Object'))

    The execution results are displayed in the Log Viewer tab.

    send request and verify

List of Available Verification Snippets

On the right panel of the Verification tab is the list of common pre-built snippets which can assist you in most of the verification cases.

SnippetDescription
Get current responseReturn response object after sending a request successfully.
Get current requestReturn the current request object.
Get a global variableReturn the value of a global variable.
Get a variableReturn the value of a variable that you have created in the Web Service Test Object.
Response body: Contains stringVerify if a response body contains a specific string.
Response body: Convert to JSON ObjectConvert a response body to JSON.
Response body: Is equal to a StringVerify if a response body is equal to s string.
Response body: JSON value checkCheck for a JSON value in a response body.
Response headers: Content-Type headerVerify Content-Type header's value.
Status code: Code is 200Verify if response's status code is 200 or no.
Status code: Successfully requestVerify if the request is sent successfully.
Request body: Validate GraphQL against schemaValidate the request body against a GraphQL schema.
Response body: Array containsVerify specified arrays contain values.
Response body: Validate JSON against schemaValidate the response body against a JSON schema.
Response body: Validate XML against schemaValidate the response body against an XML schema.