API Fortress is the API Testing Platform of Sauce Labs. We will use this platform throughout the remainder of this course. Some concepts we cover during this course require the API Fortress platform.
However, you can try and follow along using other tools like Postman, and then import your requests later on.
If you don't have an API Fortress account you can visit the API Fortress home page, and select the Free Trial button at the top to request a 30-day free trial.
After you fill out the necessary fields, you then receive an email with your login credentials for the platform.
NOTE: If you don't receive an email confirmation, check your spam folder or please email firstname.lastname@example.org for assistance.
For this first test project we will test against the Sauce Labs API.
Simple Test against the Sauce Labs User API
We now have a project in which we can begin writing API Tests. Let's create the first API Test!
Negative : You must have a API Fortress account in order to follow along in this step. Use this link to sign up for a free trial. If you have an account, Sign In.
We're going to test against the Sauce Labs GET user endpoint. In order to successfully create this test we need to complete the following steps using the Visual Editor :
From the project:
GET User Info
Test for /team-management/users method
Negative : Enter tags individually an then press ‘Enter' to submit the tag. These will be helpful down the road when you want to search or query test results by tag name.
At the moment, the test content is empty. So from here, we can generate a test with the following options:
For the purposes of this lesson, we will generate a test manually with the HTTP Client.
From the Tests page:
"HTTP Code 401: Authorization failed"
Negative : To see the raw response body in the HTTP Client select Body and then either Raw or Parsed
Let's add a GET component that makes a successful API call against the Sauce Labs REST API.
In the previous step we encountered a common authentication error, HTTP: 401, because you didn't send the
accesskey that Sauce Labs requires to communicate with their API. In order to fix this error we must add our Sauce Labs Account Credentials as a Basic Authentication Header.
https://api.us-west-1.saucelabs.com/team-management/v1/users– The URL that you are retrieving data from
payload- The variable where the response to GET is stored
json- The format of the information from the GET call
3– Sets the number of responses to a limit of 3, so that your test doesn't take too long to complete
Negative : There is no autosave! It's important to save each time you make a change to your test and/or an HTTP Request.
base64Basic Authorization value (e.g.
Basic anRhY2s0Oxxxxxxxxxxxxxxxxxxxxxxxx==) to your clipboard
base64Basic Authorization value into your HTTP Client Headers section and type
Authorizationinto the Key field. Also, make sure the endpoint URL:
https://api.us-west-1.saucelabs.com/team-management/v1/users?limit=3is still there:
GET 3 Users):
200response code and something similar in the response headers:
First GET Testand a description), select Save, and click through the prompts, and you should now see a full test back in the Tests page.
If your previous step ran without any errors you should see the following test results page:
If you ran into any errors, they appear here along with troubleshooting tips.
If you navigate back to the Tests page, you may notice to the right is a message stating: Unpublished changes
There's either one of two reasons for this:
All the work we previously completed only exists as a Working Copy. It's basically still in rough draft form, and we need to publish the test in order to actually use it in production.
From the Test editing page, hover over the message that states "Unpublished changes" and select the Publish button to publish the working copy.
Immediately, the Publish button turns green to indicate your test is ready for a scheduled a test run. Save your test.
Scheduling a test basically means we can set up a recurring job (sort of like a
cron job) that can run our published tests at a specific time, along with other test parameters. If you look on the project page where your tests are listed, a test that is published, but not scheduled, appears with a
- underneath the Schedules tab like this:
Below are the steps to schedule a test.
From the page where your projects' tests are listed, select the Schedule Test button:
You should now see the Test Scheduler:
If everything worked correctly, you should see the following status on the Schedule page:
Also, you will see the following on the page where the tests for your project are listed:
Congratulations on running, publishing, and scheduling your first API Test!
In the next module, we will take a step back and dive deeper into the API Fortress Test Component Library where we cover such topics as: