# Context Parameters

In utility methods/ response validators, you will get access to various kinds of information related to that particular context in which you are executing the method. The purpose of this guide is to specify the format of each kind of information available to them.

This information is available by the this keyword inside the method.

  1. this.execution
    Only available if you invoke the utility methods inside the Variable Extractor tab or inside the custom response validator. This contains the API request and response details. The structure of this.execution is as follows:

      {
        "request": {
          "url": "STRING - URL with Query Params",
          "method": "STRING - Request Method",
          "headers": {
            "REQUEST_HEADER_NAME": "STRING - HEADER_VALUE"
          },
          "body": "Request Body"
        },
        "response": {
          "statusCode": "NUMBER - Status Code",
          "headers": {
            "RESPONSE_HEADER_NAME": "STRING - HEADER_VALUE"
          },
          "executionTime": "NUMBER - In Milliseconds",
          "content": "STRING - Response Body",
          "parsed": "Parsed Response Body"
        },
        "remarks": "STRING - Optional"
      }
    
  2. this.variables
    This contains the current values of the variables, they can be either global or extracted variables. The structure of this.variables is as follows:

    {
      "VAR_NAME": "ANY - VAR VALUE"
    }
    
  3. this.methods
    This contains the methods map. Through this, you may invoke other utility methods. The structure of this.methods is as follows:

    {
      "METHOD_NAME": "FUNCTION"
    }
    

    If you want to pass on the context parameters to your method then use the following syntax:

    this.methods.METHOD_NAME.call(this, arg1, arg2);
    
  4. this.assertion
    This contains the information about the current assertion if you have invoked the utility method in the Property or Expected Value column of the assertion or if you have used the custom operator. The structure of this.assertion is as follows:

    {
      "source": "STRING - value can be one of jsonBody, xmlBody, textBody, statusCode, responseTime, responseHeaders, custom",
      "property": "STRING - whatever you have specified",
      "operator": "STRING - whatever you have specified",
      "expectedValue": "STRING - whatever you have specified"
    }
    

    Please note that if you have specified any variables or invoked any utility methods, then this.assertion will never show you the resolved values. Its purpose is only to show you the information which you have specified.

  5. this.expectedValue
    The expected value is calculated from the Assertions table. This information is available to the custom response validator/operator. The type can be anything depending upon the context.

  6. this.actualValue
    The actual value is calculated from the Assertions table. This information is available to the custom response validator/operator. The type can be anything depending upon the context.

  7. this.expectedResponse
    This contains the expected response for the test case. This information is retrieved after resolving all the variables and methods in the Expected Body section. The type will always be STRING.

  8. this.testcase
    This contains all the information about the test case which you are currently executing. The structure of this.testcase is as follows:

    {
      "id": "STRING - Test Case ID",
      "testSuiteId": "STRING - Test Suite Name",
      "details": {
        "summary": "STRING - Test Case Summary",
        "description": "STRING - Test Case Description",
        "externalId": "STRING - Test Case External Id",
        "condition": "STRING - Test Case Condition",
        "loopSource": "STRING - Loop Source Field Value",
        "waitForSeconds": "Number - Value of Wait for Seconds field (Can be null)",
        "runnable": "Boolean - Runnable Flag"
      },
      "validation": {
        "assertions": [
          "OBJECT - `this.assertin` format",
          ...
        ],
        "expectedBody": {
          "content": "STRING - Expected Body Content",
          "type": "STRING - Expected Body Type"
        },
        "expectedSchema": {
          "content": "STRING - Expected Schema Content",
          "type": "STRING - value will be json"
        }
      },
      "request": {
        "url": "STRING - Test Case URL",
        "method": "STRING - Request Method",
        "headers": {
          "HEADER-NAME": "STRING - HEADER VALUE"
        },
        "queryParams": [
          {
            "name": "STRING - Query Parameter Name",
            "value": "STRING - Query Parameter Value"
          },
          ...
        ],
        "body": {
          "content": "STRING - Request Body",
          "type": "STRING - Request Body Type",
          "formParams": [
            {
              "name": "STRING - Form Parameter Name",
              "value": "STRING - Form Parameter Value"
            },
            ...
          ]
        }
      },
      "variables": [],
      "resultVariable": "STRING - Result Variable",
      "extensions": {},
      "$data": {},
      "hooks": [
        "STRING - Local Hook Id 1",
        "STRING - Local Hook Id 2",
        ...
      ]
    }
    

    Please note that if you have specified any variables or invoked any utility methods, then this.testcase will never show you the resolved values. Its purpose is only to show you the information which you have specified.

  9. this.request
    This contains all the information related to the current API request after all the variables and methods are resolved. This information is available when you invoke the utility methods in configuring the Authorizations.

{
  "url": "STRING - URL without Query Params",
  "urlWithQuery": "STRING - URL with Query Params",
  "method": "STRING - Request Method",
  "headers": {
    "REQUEST_HEADER_NAME": "STRING - HEADER_VALUE",
    ...
  }
  "queryParams": [
    {
      "name": "STRING - Query Parameter Name",
      "value": "STRING - Query Parameter Value"
    },      
  ]
  "body": {
    "content": "STRING - Request Body",
    "type": "STRING - Request Body Type",
    "formParams": [
      {
        "name": "STRING - Form Parameter Name",
        "value": "STRING - Form Parameter Value"
      },
      ...
    ]
  }
}