Table of contents
1.
Introduction
2.
Katalon Studio Plugin
2.1.
Create a Maven-based Java project
2.2.
Update pom.xml
2.3.
Features
2.4.
Create your implementationClass
2.5.
Build your plugin
2.6.
Test your plugin
2.7.
Test execution event
3.
Frequently Asked Questions
3.1.
What is the difference between a Platform and a Custom keyword plugin?
3.2.
What are the sources of installing plugins into a project?
3.3.
What is the role of the PluginActivationListener?
4.
Conclusion
Last Updated: Mar 27, 2024
Medium

Create your first Katalon Studio plugin

Author Yashesvinee V
0 upvote
Career growth poll
Do you think IIT Guwahati certified course can help you in your career?

Introduction

Hi there!

Would you like to learn how to build your very own Katalon Studio plugin? You're in the right place. This blog will focus on building a Katalon Studio Plugin and testing it. So, let's get right into it.

Create your first Katalon Studio plugin

Katalon Studio Plugin

A Katalon Studio plugin is a Maven-based Java project that contains pom.xml, plugin.xml files and all the packaged codes of the plugin. The pom.xml file describes the plugin's functionality. The plugin.xml file stores data on the extensions of the plugin. 

We shall create a plugin that listens to the plugin activation event and prints a message after successful installation on Katalon Studio.

Creating this plugin would require Java SDK 1.8, Maven 3.3+ and Katalon Studio.

Create a Maven-based Java project

Construct a Maven Java project with the following structure.

Maven-based project folder structure

Update pom.xml

Use the following template for your pom.xml file.

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

    <modelVersion>4.0.0</modelVersion>

    <parent>
        <groupId>com.katalon</groupId>
        <artifactId>com.katalon.platform.parent</artifactId>
        <version>1.0.17</version>
    </parent>

    <!-- Replace your plugin description here -->
    <groupId>(enter your groupID)</groupId>
    <artifactId>(enter your artifactID)</artifactId>
    <version>1.0.0</version>

    <packaging>bundle</packaging>

    <dependencies>
        <!-- Katalon Platform dependencies-->
        <dependency>
            <groupId>com.katalon</groupId>
            <artifactId>com.katalon.platform</artifactId>
            <version>1.0.17</version>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <version>2.4</version>
                <executions>
                    <execution>
                        <id>unpack-dependencies</id>
                        <phase>prepare-package</phase>
                        <goals>
                            <goal>unpack-dependencies</goal>
                        </goals>
                        <configuration>
                            <excludes>com/katalon/platform/**,org/eclipse/**,org/osgi/**</excludes>
                            <includes>**/*.class</includes>
                            <outputDirectory>${project.build.outputDirectory}</outputDirectory>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.felix</groupId>
                <artifactId>maven-bundle-plugin</artifactId>
                <extensions>true</extensions>
                <configuration>
                    <instructions>
                        <Bundle-SymbolicName>${project.groupId}.${project.artifactId};singleton:=true</Bundle-SymbolicName>
                        <Bundle-Version>${project.version}</Bundle-Version>
                        <Import-Package></Import-Package>
                        <DynamicImport-Package>*</DynamicImport-Package>
                        <_noee>true</_noee>
                        <_nouse>true</_nouse>

                        <!-- Change your public export package here -->
                        <Export-Package>(enter your default package)*</Export-Package>
                    </instructions>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

Features

Katalon Studio's core features for plugins are mentioned here. The plugin.xml file contains many extension tags, each of which describes how client plugins can hook into Katalon Studio. These are extension points. The extension points are available as listeners. Consider this extension to Subscribe to a plugin activation event.

<extension
        point="com.katalon.platform.extensions_point">
      <point
            id="com.katalon.platform.api.extension.pluginActivationListener"
            interfaceClass="com.katalon.platform.api.extension.PluginActivationListener"
            serviceClass="com.katalon.platform.internal.lifecycle.PluginActivationListenerService">
      </point>  
</extension>
  • id: It represents the ID of the extension point.
     
  • interfaceClass denotes the interface class client plugins that should provide the implementation to extend this extension.
     
  • serviceClass is an internal service class.
     

We can extend this extension point in the plugin.xml file as follows.

<plugin>
    <extension
            point="com.katalon.platform.extensions">
        <point
              id="<enter groupID>.FirstExtensionId"
              extensionPointId="com.katalon.platform.api.extension.pluginActivationListener"
              implementationClass="<enter default package>.FirstPluginActivationListener">
        </point>
    </extension>
</plugin>
  • extensionPointId is the id of the extension point.
     
  • implementationClass implements the interfaceClass and extends the interface to perform custom actions.
     

Create your implementationClass

Create a file called FirstPluginActivationListener in the src/java/main folder and add the code.

package <enter your default package name>;

import com.katalon.platform.api.Plugin;
import com.katalon.platform.api.extension.PluginActivationListener;

public class FirstPluginActivationListener implements PluginActivationListener 
{
    // Message to be displayed in the console after plugin is activated.
    @Override
    public void PostActivation(Plugin plugin) 
    {
        System.out.println("Hi, the Activated plugin is: " + plugin.getPluginId());
    }
}
You can also try this code with Online Java Compiler
Run Code

Build your plugin

In the command line window, enter mvn clean package and wait for a successful build message. After the build is completed, a .jar file with the name you specified as the artifactID will be present in the target folder.

Test your plugin

All messages from the plugin are displayed in the Event log tab present next to Log Viewer. Click on Plugin/Install Plugin and choose the .jar file created in the previous step. This will launch the plugin, and a notification message will be displayed stating Plugin installed successfully. The Event log will display the following result.

Hi, the Activated plugin is: <groupID>.<artifactID>

Test execution event

Execute the Test suite and observe the Event log for successful completion status.

Must Read Apache Server

Frequently Asked Questions

What is the difference between a Platform and a Custom keyword plugin?

A Platform plugin is a Maven-based Java project. A custom keywords plugin contains some custom keywords implementation.

What are the sources of installing plugins into a project?

Plugins can be downloaded from the Katalon Studio and installed. They can also be installed from the local Plugin folder.

What is the role of the PluginActivationListener?

The PluginActivationListener is an extension point that allows client plugins to listen to events involving the activation and de-activation of a plugin.

Conclusion

This blog discusses how to create a Katalon Studio Plugin. Check out our articles on Generate Test Steps in Manual and Script View, Sample API tests project in Katalon and Search and Call Test cases in Katalon.

Explore our Library on Coding Ninjas Studio to gain knowledge on Data Structures and Algorithms, Machine Learning, Deep Learning, Cloud Computing and many more! Test your coding skills by solving our test series and participating in the contests hosted on Coding Ninjas Studio! Looking for questions from tech giants like Amazon, Microsoft, Uber, etc.? Look at the problems, interview experiences, and interview bundle for placement preparations. Upvote our blogs if you find them insightful and engaging! Happy Coding!

Thank you
Live masterclass