MaxSoft IntelliAPI — API Test Automation Tutorial 2

GET API Automation

Osanda Deshan Nimalarathna
MaxSoft — IntelliAPI

--

  1. Get a clone of IntelliAPI demo project from here.
  2. As an example we’ll automate a test to get all decks.
  3. Open “api_doc.xlsx” file inside resources/api_document.
  4. Provide relevant details for “API_NAME”, “API_ENDPOINT”, “HTTP_METHOD”, “BODY_TYPE” and “JSON_PAYLOAD_TEMPLATE” columns as follows,
Adding the entry in API document excel file

5. Save the excel file.

6. Create a new specification in specs folder using any name.

7. Now you can see the below text file.

Creating a spec file

8. You can give any name for Specification heading and Scenario heading.

9. In the first step, you must define the API name which you need to invoke. That API name should be included in the “api_doc.xlsx” file.

10. For this example I am going to use “Get all Decks” as the API name since I have provided those details in the excel file in step 4.

11. Now you can write the first step as,

Preparing to invoke GET API
Preparing to invoke GET API

12. As the second step, you need to configure the authentication token. Since this API request needs the token, we can provide configuration values as follows,

Setting authentication configurations
Setting authentication configurations

13. Since this is a GET request you won’t have any request body. But you may have path parameters and query parameters.

If you have path parameters, your next step would be,

Setting the path parameters

If you have query parameters, your next step would be,

Setting the query parameters

In this example, this API do not have any path parameter or query parameter. So I won’t add those steps to my spec file.

14. As the fourth step, I need to include headers for the API, because this header is mandatory for this API.

Setting the request headers
Setting the request headers

15. As the fifth step, I can invoke the API as follows,

Invoking the API
Invoking the API

16. Now I have invoked the API and I have the response as well. So I can validate the response using the following steps.

17. So in the sixth step, we’ll validate the status code of the response,

Validating the response status code
Validating the response status code

18. Then we’ll validate the response contents using JSON Path Assertions as follows,

Validating the response content using JSON path
Validating the response content using JSON path

19. Now you have already completed the designing phase. You can execute this test scenario by clicking the green color play button on the left corner of the scenario heading.

Executing the test scenario

20. After you run the test, go to reports/html-report and open “index.html”

That’s how this framework works. I will guide you to perform some other API test automation in coming tutorials.

Keep in touch……….

Happy Automation !!!

--

--

Osanda Deshan Nimalarathna
MaxSoft — IntelliAPI

Founder of MaxSoft | RPA Solution Architect | Open-source Contributor | Automation Framework Developer | Technical Specialist