As we all know, “Test Automation” is one of the most important and unavoidable factors in the world of testing. With new automation tools invented every day, most of the testers are looking for something that has less coding. Currently, Selenium is one of the most commonly used automation tools. But for Selenium the testers need good programming skills also.
Is there any tool that satisfies the major requirements for a Tester? An efficient Open Source tool with little or no coding when compared to most of the available tools?
The answer – Katalon Studio, an Open Source Test Automation Tool. When compared to Selenium it is useful for people with little programming knowledge.
Web, Mobile and API testing are possible using Katalon. Here I am giving a basic idea regarding API testing using Katalon.
To start a new API project, launch Katalon
Create the Project
- File → New → Project → Give a Name
- Select Project as “Sample JIRA API Tests Project”
We can use the website https://reqres.in/ to get a few sample APIs for our learning.
When the site gets loaded, scroll down to find the sample APIs. By clicking on each REST-API in the list, the corresponding request and the response are displayed on top. For now, we will select the simple API – SINGLE USER.
Now go to Katalon again. We need to create a Web Service Request there. The best practice is to create a Folder and then create a Web Service Request there to organise them better.
Create Object Repository
Go to Object Repository → Right Click → New → Folder → Give a Name (I gave the name as API 2)
Next Right click on folder API2 → New → Web Service Request → Give a Name (Give a meaningful name here).
As we are doing something related to Users, I have named it as Users.
Select Request Type as RESTful.
In the URL field, give the url we have selected earlier – https://reqres.in/api/users/2. The resultant screen will look like this.
Give the protocol required. Here our url is to obtain the user list. So we can use GET and add parameters if any. Now, click on “Test Request” icon next to the url field. The result is displayed on the right side with the Status code, Elapsed time and Size in bytes.This is how to create a request and test it in Katalon.
Create Test Cases
Next step is to create a Test Case and the verification steps, without which we cannot validate the API.
Go to Test Case → Right Click → Folder → Name it.
Right click on Folder → Test Case → Give Name and Tag. Tags will be helpful while searching for the Test Cases.
Now create Tests
Click on Add drop-down → Select Web Service Keyword (For API tests we use Web Service Keywords)
The First Step is to send the request. Start typing “send” and it will display all the items with the entered text. Select “Send Request”. Double click on the null text under Object. Select our required object (Here its User Details under API 2). Click OK.
In the output section, give a variable name. The output of our API is stored in this variable.
Now we can start entering our test criteria and check the status code. From our previous API run, the status code after running the API is 200. So it is easy to verify whether the status code is 200 through our test cases.
Select “Verify Response Status Code”.
In the Input section, double-click. Initially, we need to give the variable name where we have stored our response. So select the Value Type as “variable” and give the value. Here we are going to give the value “User1” as we had already given the same for the variable earlier. Check the above screenshot.
Next one is the expected Status code. Our status code is 200. So we can give the same there.
Note: If you have any doubt regarding the Keywords, go to the Keywords Browser on left side → Built-in keywords → Web Service Keyword. We can also refer the Katalon Studio User guides.
If we wish to check for a particular value in the response we got, we can use the “Verify Element Property Value” keyword.Double click on Input column. As always, the first one is our Response object. There we need to give the variable name we had already provided. Next one is the “locator”. If I need to check whether the id value is 2 in our response, we need to give what is the position of this “id”. For this, we can take the help of some JSON pathfinders.
Here I am using the url http://jsonpathfinder.com/ for the same.
Give our response here. Moving on to the result section, click on our required element, in this scenario it is the “id”. It will display the corresponding path on top.
Here the path is “data.id”. Give the same in our test case. And the 3rd one is the value. Give the value “2” there as we need to check whether the id is 2.
Now run the test case and check the Log Viewer. We can see that the test has passed.
Now, let’s run one more time with the id value as 3. This time the test will fail, as in our response, the id value entered is 2.
Run the test and check the Log Viewer. The corresponding test has failed as shown below.
Create Test Suite
Next one is the Test Report. We can’t generate a report just by running the Test Case. For this, we need to create a Test Suite.
Test Suite → Right Click → Create a Folder first to organise better → Right click on Folder → Test Suite → Name it
Click on Add and select the required Test Case and then click OK. Run the Test Suite.
Go to Reports and check. There we can see the report for the executed Test Suite.
Export the Report
We can export the reports to the required formats. From Reports → Right click → Export as and select the required format.
That’s it. We have tested a sample API and got the report also. Similarly, we can test APIs by making use of the available keywords.
This is just a beginning. There are lots more to be discussed. Keep researching and share your findings friends in the comment section below, as I did.
Reference: How to test API with Katalon Studio by Raghav Pal – https://www.youtube.com/watch?v=Evikp4eQSGs
IoT mobile apps, the next big thing for current COVID-19 and future pandemics [Ultimate Guide]
In times where technology is a part of our everyday routine, the extension of its features to everyday devices is a peek into a futuristic world. For instance, when the pandemic struck, the need for remote monitoring was on the rise, more than ever. Gathering resources and medicines, consultation with doctors, monitoring of beds had […]
Healthcare mobile app development for organizations to address the disruption caused by the pandemic
In an increasingly convenient world where groceries, food, clothes are available at the click of a button, it was the healthcare sector that quite remained rooted to its traditional ways. However, since the onset of the pandemic, social distancing and other preventive measures, the usage of healthcare apps has seen a significant boost. Patients and […]
Mobile application Development Trends in 2021 in the Post-Pandemic Environment
The COVID-19 pandemic has exponentially triggered a big-time financial crisis, hurting practically all domains of life, including travel & tourism, real estate, leisure activities, small local businesses, and the quality of life of every being. However, the crisis has given birth to the vital need for digital solutions and developments that would help people face […]