Utilize Custom Keywords in Katalon Studio

Esti Wati
Esti Wati
Aug 18 · 3 min read

Creating automated tests with Katalon Studio is basically using their built-in keywords to represent the actions on the application that is being tested. These built-in keywords are intended to make it easier for users to automate with less coding experience. Furthermore, Katalon Studio also has a Custom Keywords feature which is used to expand the automation capabilities apart from the built-in keywords that have been provided. These custom keywords as well can be used repeatedly just like the built-in keywords.

Illustration by Freepik Stories

So, how to create and use the custom keywords?

For this example, I will make custom keywords to pick a date from date picker. I use this type of date picker which is used in one of the DSF projects. This date picker only allows users to click on the previous or next arrow when selecting a date that is in the previous months or after this current month.

Here is the step to create custom keywords in your project. First, create a new package. In this example, I create a package inside an existing project with the name com.keyword.datepicker.

Then create a new keyword from the package earlier. For this keyword, I named the class name as selectDate.

Inside the selectDate class, we need to add the @Keyword annotation to indicate this is a keyword.

Under the annotation, create a keyword name with the required parameters. For example, I named the keyword as date with the parameter dateMonthYear (I only use one parameter since I want to pass this “dd-MM-yyyy” value).

Then create your code as you desired, you can use either Groovy or Java, even combine it with the built-in keywords.

In this keyword I combine it with the built-in keywords, I use conditions to separate a date selection that is in the current/previous months, or after the current month.

To use this custom keyword can be done by adding it inside the Test Case. You can add it from the manual view or script view, in this example I use script view. To add it you need to type CustomeKeywords. and choose the custom keyword from the suggestion. You can reuse this keyword in other test cases just like the built-in keywords.

Then fill in the custom keywords required parameter. For this, I fill it with the date “15–02–2021”.

Here is the result after running the Test Case.

https://docs.katalon.com/katalon-studio/docs/introduction-to-custom-keywords.html
https://docs.katalon.com/katalon-studio/docs/how-to-use-custom-keyword-in-groovy-class.html

DSF Web Services Engineering

Development Center by PT. Dipo Star Finance