Adding API Step to your Test

Updated 1 month ago by Adnan Pandjou

Test cases are not just a set of steps performed on your screen. Today, test cases require creating runtime test data from API responses and using that data in subsequent steps (or deleting data after the test has completed execution). This makes automated tests reusable and resilient.

To add an API Step to Test, complete the following steps:

  1. Click the API Step Icon present towards the bottom end of the Action Bar:

  1. This will result in the API Step Modal to appear:

  1. API Step Configuration: Next, specify the Request URL and select the type of Request. Sofy currently supports the following:
    1. GET
    2. POST
    3. PUT
    4. PATCH
    5. DELETE
  2. API Step Variable: You can save the API response in a variable and use it inside the API Step Dialog box in the body, as well as in headers, query parameters, and path variables.
  3. Add the URL, choose a request type, and click "send". As an example, here, we send a GET request to and obtain the following response:

  1. Once a response is obtained, by clicking on the path or value of the response, the user can store the path in a user-created variable. This variable is assigned a value later during the lab run.
  2. In this example, when you click on "id", you will see a '+' symbol next to it, clicking on which will add a test variable towards the bottom of the modal

  1. We can also define multiple test variables at once (upto 10 at a time). You can easily add more test variables by clicking on the '+' symbol next to any given parameter in the API response. For example, here we can define test variable for both "id" as well as "name":

  1. Sofy also allows you to use existing variables captured and stored in the form of API variables / Test Data variables / variables defined during a Session inside the Body, Header, Query Params or as a Path Variable. This can be particularly helpful in many use cases, for example, using this, you can create more complex test scenarios and execute sequences of API calls based on data obtained during the test execution.
  2. For example, when you are adding an API Step to your test and wish to use an existing variable inside your Header, you can do so by clicking on the Header tab and then clicking on Add New. Once the dropdown appears, you can pull it down to see the list of all API variables, Test Data variables and Session variables for your app:

  1. Based on our use case, you can also define regular expressions (REGEX) on the response to save only the relevant part as a variable. For example, you may want to store a only the second word of any given string and therefore may want to use a regex in this case as shown here:

  1. Finally, click Add API Step to successfully save the variable:

How did we do?