Adding an API Step to your Test

Updated by Aishwarya Rai

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 a test case:

  1. Log in to your Sofy account.
  2. Select Device Lab from the left navigation bar.
    Sofy home page with a callout over the Device Lab option in the left navigation bar.
  3. Acquire and launch a device.
  4. Start recording a test case.
  5. Click the API Step Icon at the bottom of the action bar to the right of the device screen. This will open the API Step Modal.
  6. Specify the request URL and select the type of request. Sofy currently supports GET, POST, PUT, PATCH, and DELETE.
  7. Click Send.
  8. You can also add up to 10 test variables from the values received in the response (for example, if you want to execute sequences of API calls based on data obtained during the test execution). Test variables will be assigned a value during the test run once the test case is saved. To add a test variable:
    1. Click on any value in the response.
    2. Click the + symbol next to the value. The test variable will appear under the Test Variables section.
      API Step modal window with a callout over the plus button to add variable.
    3. While capturing a variable from an API step, you can specify to Sofy if you want to treat it as a String, Integer or Float from the dropdown:
    4. Update the Regex (regular expression) field if you want to save only the relevant part as a variable. For example, you may want to store only the second word of a given string.
  9. While configuring your API step, you can also add new path variables, headers (like bearer tokens), and query parameters. To do this:
    1. Select the Headers, Query Params, or Path Variables tab under the request setting.
    2. Click Add new or the + button at far right.
      Add API Step modal window with a callout over the Add new and plus button.
    3. Name and select a variable for the header, query param, or path variable. You can also select a test variable you created in the API step.
      Add API Step modal window with a callout over the API Variables added in this step.
  10. Once you’re done configuring your API step, click Add API Step.


How did we do?