Skip to main content

How to develop a Custom Keywords plugin in Katalon Studio

A custom keywords plugin is a Katalon Studio project with some custom keywords implementation. To develop a custom keywords plugin, follow these steps:
  • Create a new Katalon Studio project with the build.gradle file.

  • Implement your custom keywords with a katalon-plugin.json file.

  • You can add test cases to help verify these custom keywords and serve as samples for plugin users.

This tutorial introduces a detailed process of sharing custom keywords as plugins. You can download our sample custom keywords plugin on GitHub: Zip custom keywords plugin.

Develop a custom keywords plugin in Katalon Studio

Add your dependencies to the build.gradle file

To open the build.gradle file in Katalon Studio, do as follows:

  1. Go to File > New > Project, check the Generate build.gradle file box.

    Generate build.gradle file

    Katalon Studio will generate a default build.gradle template.

    The build.gradle template

  2. Add your dependencies to the build.gradle file.

    For example, we want to add our dependencies to the Zip custom keywords plugin. We enter the following code in the build.gradle file:

    For Gradle 7

    plugins {
    id 'java-library'
    id 'groovy'
    id 'com.github.johnrengelman.shadow' version '7.1.2'
    id 'com.katalon.gradle-plugin' version '0.1.1'
    }

    repositories {
    mavenCentral()
    }

    def pluginSources = [
    'Keywords',
    'Test Listeners',
    'Include/scripts/groovy'
    ]

    sourceSets {
    main {
    groovy {
    srcDirs = pluginSources
    srcDir 'Libs' // generated by Katalon Studio
    }
    }
    }

    shadowJar {
    exclude 'Temp*.class'
    }

    groovydoc {
    source = pluginSources
    docTitle = 'Zip Custom Keywords'
    }

    dependencies {
    implementation 'net.lingala.zip4j:zip4j:1.3.2'
    }

    The build.gradle file for Gradle 7

    For Gradle 5-6

    plugins {

    id 'java'

    id 'groovy'

    id 'com.github.johnrengelman.shadow' version '4.0.4'

    id "com.katalon.gradle-plugin" version "0.0.7"

    }

    repositories {

    jcenter()

    mavenCentral()

    }

    sourceSets {

    main {

    groovy {

    srcDirs = ['Keywords', 'Libs', 'Test Listeners', 'Include/scripts/groovy']

    }

    }

    }

    dependencies {

    compile 'net.lingala.zip4j:zip4j:1.3.2'

    }

    shadowJar {

    exclude 'Temp*.class'

    }

    katalon {

    dependencyPrefix = "com.katalon"

    minimize = false

    }

    The build.gradle file for Gradle 5-6

Implement your custom keywords with a katalon-plugin.json file

In the Keywords folder, add a katalon-plugin.json file with the following format:

{
"keywords": [keywordClass1, keywordClass2]
}

Example:

{
"keywords": ["com.katalon.plugin.keyword.zip.ZipKeywords"]
}

Package the plugins with Gradle

  1. Install Gradle. Follow the instruction on the Gradle website: Install Gradle.
  2. Open Terminal/Command Prompt, then go to the plugin project directory.
  3. Inside the plugin project folder, run:
    gradle katalonCopyDependencies
  4. Open the plugin project with Katalon Studio.
  5. Next, run gradle katalonPluginPackagein the same Terminal/Command Prompt, then check the build/libs for the JAR package of the plugin.
Note:
  • To execute katalonPluginPackage across platforms, open the plugin project with Katalon Studio first to repopulate the .classpath file. The packaging task uses these paths to look up Katalon Studio libraries.

You can refer to some other custom keywords plugins on our GitHub repository:

Test the custom keywords plugin in Katalon Studio

In a new Katalon Studio project, put the JAR package of the plugin in the Plugins folder. Reopen this project to use imported custom keywords.

Note:
  • You might not be able to use custom keywords plugin in Katalon Studio 9.x. This is because Katalon Gradle Plugin does not support compiling Groovy 3.0, which is bundled with Katalon Studio 9.x. To use the plugins, first build your custom keyword plugins in Katalon Studio 8.x, then put the plugins in the Plugins folder of your project in Katalon Studio 9.x.

Publish the plugin to Katalon Store

Once you’re done developing your plugins, submit them to Katalon Store. To learn more about submitting plugins to Katalon Store, you can refer to this document: Submit plugins. Katalon will review your contents against our policies before listing them on the Katalon Store.

See also