What is Katalon Studio?
Katalon Studio is an easy-to-use automation tool for testing APIs, web, and mobile applications. It helps both beginners and experts perform tests quickly.
Setting Up API Test in Katalon Studio
- Download and Install Katalon Studio: Get it from Katalon.
- Create a New Project: Open Katalon, create a new API project.
Example 1: Simple GET Request
- Create a Test Case: Right-click on Test Cases > New Test Case and name it "GetPostsTest".
- Add GET Request: URL: https://jsonplaceholder.typicode.com/posts.
- Verify Response:
import com.kms.katalon.core.webservice.keyword.WSBuiltInKeywords as WS
def response = WS.sendRequest(findTestObject('API Requests/GetPostsRequest'))
WS.verifyResponseStatusCode(response, 200)
WS.verifyElementPropertyValue(response, 'title', 'sunt aut facere repellat')
- This tests if the API returns status 200 and checks the title property.
Example 2: Simple POST Request
- Create a POST Request: URL: https://jsonplaceholder.typicode.com/posts. Body:
{
"title": "foo",
"body": "bar",
"userId": 1
}
- Send and Validate:
def response = WS.sendRequest(findTestObject('API Requests/PostCreateRequest'))
WS.verifyResponseStatusCode(response, 201)
WS.verifyElementPropertyValue(response, 'title', 'foo')
Conclusion
Katalon Studio simplifies API testing by providing an intuitive interface. With just a few steps, you can automate API requests, validate responses, and ensure your application integrates properly.
Top comments (0)