Introduction to the API Fortress Platform and Visual Test Composer
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 create a Sauce Labs account and get started with a free trial. You can now access API testing.
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.
We now have a project in which we can begin writing API Tests. Let's create the first API Test.
We're going to test against the Sauce Labs GET user endpoint. In order to successfully create this test, we'll need to complete the following steps using the Visual Editor:
From the project:
GET User Info
Test for /team-management/users method
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:
https://api.us-west-1.saucelabs.com/team-management/v1/users?limit=3and click Send.
You should receive the following error response to the right of the request input:
"HTTP Code 401: Authorization failed"
You are getting this error because you need to send an authorization header, identifying who you are in order to get a response from the GET request.
We will use this request, however, to generate a test in the next section.
Lets use the test creation feature to get an authorization header that you can then add to an HTTP request to generate a test with that HTTP request.
Start with the HTTP call to the team management endpoint URL:
In the previous step, we encountered a common authentication error, HTTP: 401, because we didn't send the
accesskey that Sauce Labs requires to communicate with their API.
To fix this error, we'll need to 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
limit; under String value, put
3. This sets the number of responses to a limit of 3, so that your test doesn't take too long to complete.
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=3) is still there:
GET 3 Users):
200response code and something similar in the response headers:
See the Workflow to create a GET request with an Basic Authorization header.
First GET Testand a description), click Save, and then click through the prompts. You should now see a full test back in the Tests page.
To view your test results:
If you are getting an API test error and want to find out more about what an HTTP call you are making is returning, the HTTP Client (accessible from your project dashboard) can be a useful tool.
You can use the HTTP Client to send a request and even add in headers, such as authorization credentials, or other information.
If you navigate back to the Tests page, you may see an Unpublished changes message in the right-hand nav.
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 Unpublished changes message, then 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, you'll see a test that is published, but not scheduled, indicated by a
- underneath the Schedules tab:
Below are the steps to schedule a test.
If everything worked correctly:
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: