MaxSoft IntelliAPI — API Test Automation Tutorial 4
PUT API Automation
- Get a clone of IntelliAPI demo project from here.
- As an example we’ll automate a test to edit a category.
- Open “api_doc.xlsx” file inside resources/api_document.
- Provide relevant details for “API_NAME”, “API_ENDPOINT”, “HTTP_METHOD”, “BODY_TYPE” and “JSON_PAYLOAD_TEMPLATE” columns as follows,
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.
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 “Edit A Category in Deck Service”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,
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,
13. In the third step, you must specify the existing category which you need to edit. Usually edit will be performed using a path parameter as the ID.
14. In the fourth step, you must create the JSON payload by replacing the values which was provided in the “api_doc.xlsx” file. Since my payload contains the “name” and “description” properties and I have defined their values as “#name” and “#description” in the excel file, I will write the step as follows,
15. As the fifth step, I can invoke the API as follows,
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,
18. Then we’ll validate the response contents using JSON Path Assertions as follows,
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
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 !!!