RequestStep

A RequestStep node is used for sending HTTP requests. TestMace allows to configure a request and use it as a single request or as a part of a scenario.

A RequestStep node in the project tree

To create a RequestStep node right-click on a Folder or Project node and choose Add node -> RequestStep.

This is how a RequestStep node looks like in the project tree:

Let's discuss its features in more detail. The color of the top left circle signifies an HTTP request status: gray - if the request hasn't been sent yet, green - if the HTTP code is successful (e. g. 200, 201, etc), red - if the HTTP code is unsuccessful (e. g. 404, 500, etc). The sheet icon color signifies a child Assertion node status: gray - if the node hasn't been run yet, green - if after running the Assertion node either doesn't exist or was successfully run, red - if the Assertion node was run unsuccessfully (some tests were failed).

There are several actions you can do with this node type:

  • Add node. Click on it to add a child node. You can choose a node type in the submenu.

  • Rename. Change the node name.

  • Duplicate. Make a copy of the node. The new node will be named NodeName [Copy [number]].

  • Remove node. Use it to delete the node.

  • Run. Run the node.

  • Share the node. Note that the link with information about the node will be created in the clipboard.

  • Show in explorer. Open the folder with the node in the file manager.

RequestStep Node Tab

After you create a RequestStep node (or double click on it) you'll see the RequestStep node tab. It looks like this:

Let's discuss every interface part in detail.

Request Configuration Area

The top area of the tab looks like this:

In the screenshot you can see the following parts of the tab:

  1. Request method. There are several methods you can choose from:

    • GET — get a resource

    • POST — create a resource

    • PUT — update a resource

    • DELETE — delete a resource

    • PATCH — make some changes to a resource

    • OPTIONS — specify resource connection parameters

  2. The URL field.

  3. The Run button.

  4. The button for editing variables

‌You can see the edit panel for headers, query parameters, authorization and request body down below. This is the panel for POST requests:

The panel has the following tabs:

  • Headers - edits an HTTP headers list;

  • Query parameters - edits a query parameters list;

  • Body - configures a request body;

  • Authorization - configures authorizations;

  • Other - configures other request parameters.

The Headers and Query parameters tabs have similar interfaces - they are both tables with bulk editing and row disabling options. Moreover, HTTP headers can be set by default.

The Other tab has the following interface:

You can set the Requires SSL certificates be valid parameter. It is Inherit by default, which means that the value of the parent node is inherited. If this parameter of the parent node is Inherit, the parameter is disabled. You can choose from:

  • Yes

  • No

  • Inherit

Now look at the Body tab:

You can choose your body type from a dropdown menu:

  • JSON - to send JSON data. You can use the editor with JSON syntax highlighting and the variables mechanism support to edit the data. When sending a request a Content-Type header with the application/json

    value is added to the HTTP headers list.

  • Form data - to edit multipart/form-data forms. It is a table with bulk edit option. The table rows may contain either plain strings or file links as their values.

  • Form URL encoded - to edit application/x-www-form-urlencoded forms. It is a table with bulk edit option.

  • File - to send a file content in the request body.

  • XML - to send XML data. You can use the editor with XML syntax highlighting and the variables mechanism support to edit the data. When sending a request a Content-Type header with application/xml value is added to the HTTP headers list.

  • Text - to send text data. You can use the editor with the variables mechanism support to edit the data. When sending a request a Content-Type header with text/plain value is added to the HTTP headers list.

Response Configuration Area

Let's send a request to the https://testmace-stage.herokuapp.com/posts url and look at the response area:

You can see short info about the response at the top of the area: a successful or unsuccessful response code, time and size.

There are the following tabs at the bottom of the response area:

  • Response body - contains the response body in different formats, such as:

    • Parsed - a tree form of the response. Each tree element has a context menu, so that you could create Assertion nodes and work with dynamic variables.

    • JSON - JSON syntax highlighting of the response body. It is available only if you have a JSON response body.

    • XML - XML syntax highlighting of the response body. It is available only if you have an XML response body.

    • HTML - HTML syntax highlighting of the response body. It is shown if the response body is an HTML page.

    • Text - plain text with no highlighting.

    • Preview - a rendered response body version. It is shown if the response body is an HTML page.

  • Response headers - a response HTTP headers list.

  • Assertions - a list of assertions that a child Assertion node has.

File Representation

A RequestStep node is a folder with the node name, containing the index.yml file with the following format:

{
  "type": "object",
  "properties": {
    "type": {
      "description": "Type of Folder node",
      "const": "RequestStep",
      "type": "string"
    },
    "assignVariables": {
      "description": "List of variables assignments",
      "type": "array",
      "items": {
        "$ref": "#/definitions/AssignVariable"
      },
      "default": []
    },
    "requestData": {
      "$ref": "#/definitions/IRequestData"
    },
    "authData": {
      "$ref": "#/definitions/IAuthorizationData",
      "description": "Authorization parameters"
    },
    "children": {
      "description": "List of children names",
      "type": "array",
      "items": {
        "type": "string"
      },
      "default": []
    },
    "variables": {
      "$ref": "#/definitions/NodeVariables",
      "description": "Node variables dictionary"
    },
    "name": {
      "description": "Node name",
      "type": "string"
    }
  },
  "required": [
    "assignVariables",
    "authData",
    "children",
    "name",
    "requestData",
    "type",
    "variables"
  ],
  "definitions": {
    "AssignVariable": {
      "type": "object",
      "properties": {
        "path": {
          "description": "Path in $response variable (e.g. body.id)",
          "type": "string"
        },
        "assign": {
          "$ref": "#/definitions/NodeReference",
          "description": "Link on target node (one of parents)"
        },
        "variable": {
          "description": "Name of dynamic variable in target node",
          "type": "string"
        }
      },
      "required": [
        "assign",
        "path",
        "variable"
      ]
    },
    "NodeReference": {
      "type": "object",
      "properties": {
        "refNodePath": {
          "description": "Absolute path to node",
          "type": "string"
        },
        "type": {
          "description": "Marker of reference entity",
          "const": "reference",
          "type": "string",
          "default": "reference"
        }
      },
      "required": [
        "refNodePath",
        "type"
      ]
    },
    "IRequestData": {
      "type": "object",
      "properties": {
        "request": {
          "description": "Common request parameters",
          "type": "object",
          "properties": {
            "method": {
              "$ref": "#/definitions/RequestMethod",
              "description": "HTTP-method"
            },
            "url": {
              "type": "string"
            }
          },
          "required": [
            "method",
            "url"
          ]
        },
        "params": {
          "description": "Query parameters",
          "type": "array",
          "items": {
            "$ref": "#/definitions/NameValueParam"
          }
        },
        "body": {
          "$ref": "#/definitions/IRequestBody",
          "description": "Body parameters"
        },
        "headers": {
          "description": "Headers",
          "type": "array",
          "items": {
            "$ref": "#/definitions/NameValueParam"
          }
        },
        "disabledInheritedHeaders": {
          "description": "Names of disabled headers",
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "strictSSL": {
          "$ref": "#/definitions/StrictSSLOptions",
          "description": "Requires SSL certificates be valid"
        }
      },
      "required": [
        "body",
        "disabledInheritedHeaders",
        "headers",
        "params",
        "request",
        "strictSSL"
      ]
    },
    "RequestMethod": {
      "enum": [
        "DELETE",
        "GET",
        "OPTIONS",
        "PATCH",
        "POST",
        "PUT"
      ],
      "type": "string"
    },
    "NameValueParam": {
      "type": "object",
      "properties": {
        "name": {
          "type": "string"
        },
        "value": {
          "type": "string"
        },
        "isChecked": {
          "type": "boolean"
        }
      },
      "required": [
        "name",
        "value"
      ]
    },
    "IRequestBody": {
      "type": "object",
      "properties": {
        "type": {
          "$ref": "#/definitions/RequestBodyType",
          "description": "Type of body"
        },
        "jsonBody": {
          "description": "JSON string of body",
          "type": "string"
        },
        "xmlBody": {
          "description": "XML string of body",
          "type": "string"
        },
        "textBody": {
          "type": "string"
        },
        "formData": {
          "description": "multipart/form-data form",
          "type": "array",
          "items": {
            "$ref": "#/definitions/RequestStepFormData"
          }
        },
        "formURLEncoded": {
          "description": "application/x-www-form-urlencoded form",
          "type": "array",
          "items": {
            "$ref": "#/definitions/NameValueParam"
          }
        },
        "file": {
          "description": "Link on file, which will be used as a content for body",
          "type": "string"
        }
      },
      "required": [
        "file",
        "formData",
        "formURLEncoded",
        "jsonBody",
        "textBody",
        "type",
        "xmlBody"
      ]
    },
    "RequestBodyType": {
      "enum": [
        "File",
        "FormData",
        "FormURLEncoded",
        "Json",
        "Text",
        "Xml"
      ],
      "type": "string"
    },
    "RequestStepFormData": {
      "type": "object",
      "properties": {
        "type": {
          "$ref": "#/definitions/FormDataField"
        },
        "name": {
          "type": "string"
        },
        "value": {
          "type": "string"
        },
        "isChecked": {
          "type": "boolean"
        }
      },
      "required": [
        "name",
        "type",
        "value"
      ]
    },
    "FormDataField": {
      "enum": [
        "File",
        "Text"
      ],
      "type": "string"
    },
    "StrictSSLOptions": {
      "enum": [
        "Inherit",
        "No",
        "Yes"
      ],
      "type": "string"
    },
    "IAuthorizationData": {
      "type": "object",
      "properties": {
        "type": {
          "type": "string"
        }
      },
      "required": [
        "type"
      ]
    },
    "NodeVariables": {
      "type": "object",
      "additionalProperties": {
        "type": "string"
      }
    }
  },
  "$schema": "http://json-schema.org/draft-07/schema#"
}

Last updated