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
Meet React Native app 0.62 with Flipper
Amid global pandemic,React Native app version 0.62 was released on March 26, 2020. It comes with the support for Flipper by default. Introducing Flipper Highly popular in the Android and iOS communities, Flipper is a developer tool for debugging mobile apps. In this release, support by default has been enabled for new and existing React […]
Manage Remote Teams and Productivity During COVID-19
With more than 471,862 cases around the globe, the coronavirus (COVID-19) pandemic has a devastating impact not only on the lives of hundreds of thousands of people but also on the global economy. The government aiming to contain and mitigate the disease has initiated the largest Coronavirus lockdown in the country. This has affected the […]
Hybrid Mobile Application Development: When, Why, and How
When it comes to Hybrid mobile application development there is no one-size-fits-all solution. Every solution comes with its own set of pros and cons. React native Vs Flutter Vs Native app Native and cross-platform approaches using React Native or Flutter have emerged to be popular mobile app development solutions. While native app development has carved […]