How to develop Custom Keywords Plugins

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.

2 Likes

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:

I second this a lot! We might switch to using Katalon for testing, but it is going to be painful going from a elegant gradle solution (with gradle wrappers), to having the user download a version of gradle. This will make it harder to keep gradle versions consistent across usersā€¦

Really cool, thanks a lot! :sunglasses: