How to develop Custom Keywords Plugins

Hi @mytruong,

Currently, we don’t support overloading custom keyword functions. We will release an enhanced version soon. Thanks.

Thank you @kazurayam for your feedback.

There will be a field for each plugin to specify their Github repositories. Companion materials can be provided their. @Dung_Ngo has updated the original post to include guidelines for publishing.

Test Listeners, Test Objects, etc. will be handled soon in the next version.

Let try to change the declare data type of method: def instead of List<{dataType}>
For example at line 91 in WebTableHelper class: private static List getSelectedOptions(List selects)
Please change it to: private static def getSelectedOptions(List selects)

I made junit4ks-all.jar.

I created a brand new project using Katalon Studio 6.0.6. I. I created Plugins directory in the root directory of the project. I copied the junit4ks-all.jar into the Plugins diretory. I reopened the project, and then I got the “Unable to open project” error dialog as follows:
UnableToOpenProject

I attached the junit4ks-all.jar (renamed to be *.zip because this forum site rejected *.jar file to be attached)
junit4ks-all.jar.zip (37 KB)

Please help fixing this error.

I want to generate the Javadoc/Groovydoc of junit4ks-all.jar and publish it in the Katalon Store, as I can pushlish the javadoc under the /docs directory of my Github project. Please extend the build.gradle to support generating and publishing the Groovydoc of custom keywords.

It works. Thanks a lot

1 Like

Would this apply to your case @kazurayam? We are working on it. A new beta version will be available this week.

I do not understand what Thong means.
Anyway, I would wait for the new version hoping no ArrayIndexOutOfBound expection to be raised.

I posted my amended build.gradle which is capable of generating the Groovy Doc of plugin.

1 Like

I applied the presented build.gradle file to my junit4ks project and successfully created the jar as follows:

$ ls -la build/libs
total 80
drwxr-xr-x 1 qcq0264 1049089     0 Mar 11 10:08 ./
drwxr-xr-x 1 qcq0264 1049089     0 Mar 13 13:00 ../
-rw-r--r-- 1 qcq0264 1049089 37888 Mar 11 09:45 junit4ks-all.jar

However, I would rather like to make the name of jar appeded with the version number, like

-rw-r--r-- 1 qcq0264 1049089 37888 Mar 11 09:45 junit4ks-all-0.16.0.jar

I would gladly write the version number in the build.gradle like

group="com.kazurayam"
version="0.16.0"

Writing the version number in build.gradle is a quite common exercise in Gradle I believe.

Adding the version number in the jar name requires modifying the katalonPluginPackage task, I believe. Please consider it.

================
I created junit4ks-all.jar and posted it in my Github project’s Releases page. Now anybody can download the jar.

I downloaded junit4ks-all.jar into the Drivers directory of my another Katalon project webdriverfactory4ks. I mean, I would use the Keyword classes contained in the junit4ks-all.jar just as one of the External libraries for Katalon Studio. I used junit4ks keywords to do unit-test my Groovy classes in the webdriverfactory4ks project using JUnit4. It just worked successfully.

This means, I could make my Custom Keywords packaged into a jar, publish it via Github, reuse it in another Katalon projects successfully.

1 Like

@kazurayam @mytruong We’ve fixed this issue in version 6.1.0 beta:

@devalex88,

If one does not have gradle installed on their machine, this command execution will fail. What he/she should do?

Me? I happened to have the gradle installed on my machine. But Katalon should not expect everybody has gradle installed.

1 Like

@devalex88,

The most straight-forward solution would be let new version of Katalon Studio to bundle Gradle Wrapper in it so that all Katalon Studio users can execute

$ cd <katalo project dir>
$ ./gradlew katalonPluginPackage

This would enable us to use Gradle quite extensively in Katalon Studio.

1 Like

Thank you for the idea. We will work on it in future releases.

I get an issue when using katalon 6.1 Beta for testing custom keyword plugin. I create a katalon project and put file .jar into the Plugins folder and reload it. Some toolbar entries such Run, Debug disappear, and I try to use Action -> Run but there are somethings wrong with the file .jar. Custom keywords of the plugin seemly are not loaded successfully.

katalon-studio-ashot-plugin.zip (27.0 KB)

Could you please take a look on the issue.

2 Likes

Hi @mytruong,

Please download Katalon Studio v6.1.2 release: https://github.com/katalon-studio/katalon-studio/releases and open a project with embedded the katalon-studio-ashot-plugin.jar, you will see the original error on Event Log tab:

Caused by: java.lang.NoClassDefFoundError: Unable to load class kms.turing.katalon.plugins.visualtesting.ScreenCapture due to missing dependency ru/yandex/qatools/ashot/Screenshot
	at org.codehaus.groovy.vmplugin.v5.Java5.configureClassNode(Java5.java:421)
	at org.codehaus.groovy.ast.ClassNode.lazyClassInit(ClassNode.java:357)
	at org.codehaus.groovy.ast.ClassNode.getMethods(ClassNode.java:479)
	at com.kms.katalon.custom.parser.CustomKeywordParser.parsePluginKeywords(CustomKeywordParser.java:130)
	at com.kms.katalon.controller.KeywordController.parseCustomKeywordInPluginDirectory(KeywordController.java:187)
	at com.kms.katalon.controller.KeywordController.parseAllCustomKeywords(KeywordController.java:137)
	at com.kms.katalon.controller.ProjectController.openProjectForUI(ProjectController.java:95)
	at com.kms.katalon.composer.project.handlers.OpenProjectHandler$1.run(OpenProjectHandler.java:152)
	at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:119)

To resolve this error, your custom keyword plugin needs to package along with the ashot.jar. Please read this article for more details: How to resolve external dependencies for a Plugin

Hello All,

I am facing unusual issue as below:
steps:
1- I have created Jars and put in plugin folder too.
2- But my test case is getting executed without importing this jars file.
note: I have removed all the keywords from current project folder.

1 Like

Please try closing and reopening the project.

2 Likes

Hi Thong :slight_smile:

May I ask when is the release for the support of Overloading Keywords? :slight_smile: