Skip to main content

Building an API Test from a Spec File

Using the API Testing HTTP Client, you can generate tests from external endpoints or files such as an OpenAPI Specification (spec).

What You'll Need

  • A Sauce Labs account (Log in or sign up for a free trial license)
  • An existing API Testing Project. For details on how to create one, see API Testing Quickstart
  • An OpenAPI Specification file (v3.0 or higher) or HAR (HTTP Archive) file

Looking to import from Postman? See Importing Postman Collections.

Importing Your Spec File

  1. Log in to Sauce Labs, then click API Testing.
  2. Go into any Project.
  3. From within a Project, click the HTTP Client tab.
    HTTP Client Button
  4. Click the Import OpenAPI/HAR/Postman button, then select and upload your file from your local machine.
    Import OpenAPI / Postman button
  5. Click on the folder in your Snapshots tree where you'd like to save your file.
    Import to Snapshots folder
  6. Click Save.
    Import file to Project
  7. After saving, you'll be able to view all of your endpoints under Snapshots, grouped by subdirectory. Click on the name of the request you'd like to test.
    Import to Snapshots folder
    The URL will populate in the **Enter Request URL** field.
    Sample request
  8. Click Send. The response body will then appear.
    Response Body

Run a Test

Follow the instructions under our Quickstart doc, starting with the Generate Test step.

More Information

  • Importing Sauce Labs API Tests from Postman
  • Features coming soon:
    • Support for additional spec file formats: RAML, API Blueprint, I/O Docs, SOAP, WSDL
    • Ability to create a test by referencing the URL that points to your spec file