How to develop a Custom Keywords plugin in Katalon Studio
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.
Requirements
Katalon Studio version 6.0.6 onwards.
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:
- Go to File > New > Project, check the Generate build.gradle file box.
Katalon Studio will generate a default
build.gradle
template.
- 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'
}
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
}
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
- Install Gradle. Follow the instruction on the Gradle website: Install Gradle.
- Open Terminal/Command Prompt, then go to the plugin project directory.
- Inside the plugin project folder, run:
gradle katalonCopyDependencies
- Open the plugin project with Katalon Studio.
- Next, run
gradle katalonPluginPackage
in the same Terminal/Command Prompt, then check thebuild/libs
for the JAR package of the plugin.
- 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.
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.