Defining Variables
Variables allow you to extract data from request, subtest, and Ghost Inspector steps for use in subsequent steps in the test. Similar to Assertions, each variable is defined by a name
, source
, and property
.
Defining VariablesSample POST Body (JSON) to set {{myUserId}} to the value of JSON element 'user_id'
"variables": [
{
"source": "response_json",
"property": "user_id",
"name": "myUserId"
}
]
Variable Sources List
Sources
-
response_status
Create a variable from the value of the HTTP status code from the Response
-
response_headers
Create a variable from the value of a Response Header. You must include a property with the name of the header to extract the value from
-
response_json
Parse the response body as JSON. You must include a property with the JSON path to extract
-
response_xml
Parse the response body as XML. You must include a property with the XPath to extract
-
response_text
Parse the response body as plain text. This source does not specify a
property
-
response_time
Create a variable from the execution time of the response in milliseconds
-
response_size
Create a variable from the size of the Response body in bytes