• How to Create a Custom Keyword – Katalon Studio | Software Testing Material

    In addition to the built-in keywords, users can define custom keywords to extend the capability of Katalon Studio. Once created, custom keywords can be used in test cases just like other built-in keywords. This feature allows users to expand keywords and reuse them across projects.

    Create a Package

    A package allows you to group custom keywords into a specific category, making keywords easier to search and use.

    1. Select File > New > Package from the main menu to open the New Keyword Package dialog. Enter the name for your package and click OK.

    New custom Keyword Package

    2. A new package is created under Keywords of Katalon Studio accordingly.

    Keywords of Katalon Studio

    Create a Custom Keyword

    1. Select File > New > Keyword from the main menu to open the New Keyword dialog. Enter the name for your keyword and select a package for the keyword. Click OK.

    New Keyword dialog

    2. A new keyword is created under the specified package accordingly.

    new keyword is created

    3. Enter the following block of code in your class to define a custom keyword in Java/Groovy:


    @KeywordThe annotation to indicate that the block of code below is the definition of a keyword.
    keywordNameThe name that you would like to use for your custom keyword
    parametersThe list of parameters that would be used in the custom keyword

    For example:

    define a custom keyword in Java/Groovy

    4. Save the Keyword file when you’re done.

    Custom keywords in Manual view

    Follow the steps below to use your defined custom keywords in the Manual view of a test case:

    1Open a test case in Manual view, then add Custom Keyword in script from the command toolbar.

    add Custom Keyword in Manual View

    2. A new test step is added with a list of all defined custom keywords. Select your recently created keyword here.

    defined custom keywords

    Custom keywords in Scripting view

    Follow the steps below to use your defined custom keywords in the Scripting view of a test case:

    • The Class CustomKeywords allows you to access all custom keywords. Enter the following syntax into the script editor:


    • The Content Assist function will be invoked immediately after you type the dot character. Content Assist provides context-sensitive suggestions for code completion. Therefore, all the custom keywords defined in your test project will be displayed as below:

    Content Assist function

    • Select the recently created keyword and provide all parameters as required.

    The following API docs provide details on the functions used to work with custom keywords:

    Driver FactorygetWebDriver()Get the currently active web driver.
    Test ObjectaddProperty(String name, ConditionType condition, String value)Add a new property to a test object
    "setProperties(List properties) Set properties of a test object
    "getObjectId()Get object ID.
    "findPropertyValue(String name, boolean caseSensitivefindPropertyValue(String name, boolean caseSensitive))Find the value of a property using its name
    Keyword UtillogInfo(String message)Log message
    "markError(String message)markError(String message)Mark a keyword as an error
    "markErrorAndStop(String message)Mark a keyword as an error and stop execution
    "markFailed(String message)markFailed(String message)Mark a keyword as failed and continue execution
    "markFailedAndStop(String message)markFailedAndStop(String message)Mark a keyword as failed and stop execution
    "markPassed(String message)markPassed(String message)Mark a keyword as passed
    "markWarning(String message)markWarning(String message)Mark a keyword as warning

    You can download this project for example regarding custom keyword.

    Here is the link “Katalon Studio Complete Tutorial

    Sharing is caring.

    Share on facebook
    Share on twitter
    Share on linkedin

    Like This Post?

    We have a lot more where that came from?

    We only send really good stuff occasionally, promise.

    Rajkumar SM

    Leave a Comment

    Your email address will not be published. Required fields are marked *

    Share on facebook
    Share on google
    Share on twitter
    Share on linkedin
    Share on whatsapp

    Recent Posts:

    Scroll to Top
    API Testing eBook