Web Services testing using katalon studio is not a new feature but in katalon studio version 5.4 but really they make it very easy with some great changes.
In this tutorial, We will see how to perform rest API testing using katalon studio.
Web Services testing using katalon studio (Rest API).
Step 1: Create a new project File>New>Project.
Step 2: Click on ObjectRepository>New>WebServiceRequest.
Step 3: Now you need to fill some entries.
- Enter the name of the service.
- Select request type like restful or shop. In this demo, we are going to use restful API.
- Enter URL. (URL of the API).
Step 4: select API and choose a request type like GET, POST and finally execute the URL. You can see the response at the right site.
The Response can be displayed in multiple ways.
pretty: Response is displayed in a pretty format which is easier to read.
raw: Response is displayed in the raw text without any format.
preview: Response will be displayed as visualized.
Set the parameter according to the requirements.
How to use the response of the rest API in Test Case.
Create a test case and insert the below code in your script mode.
Execute the Test Case and check the response in the Katalon studio console.
def response = WS.sendRequest(findTestObject('getData')) System.out.println(response.getResponseText())
Some important methods and terms you need to know:
To get Response in text : response.getResponseText().
To get the Size of response : response.getResponseSize().
To get the content Type : response.getContentType().
To verify content type : response.jsonContentType().
The request method indicates the expected action to be executed on the specified resource. Katalon Studio supports following methods for REST services: GET, POST, PUT, DELETE.
The URL registered for the RESTful web services.
Any parameter to be passed along with the RESTful request object. These values are generated automatically based on the Request URL or can be manually added.
Credentials for HTTP authentication.
Type: Basic, OAuth 1.0, or No Authorization
The header information to be included to transmit in the RESTful request object. ‘Content-Type’ value is generated automatically based on the HTTP Body.
You can also select headers from the list of suggested options (by double-clicking on the Name cell) or enter another header of your interest. Refer to Supported HTTP Headers for more details.
The body information to be included to transmit in the RESTful request object. Katalon Studio supports the following transmit types: