How to write Katalon Studio tests with IntelliJ IDEA and other IDEs

Love this thread. slowly but slowly is about reinventing the wheel :smiley:
Why not simply use IDEA+groovy+Spock?

apply plugin: 'groovy'

group = 'org.spockframework'
version = '1.0-SNAPSHOT'

description = """Spock Framework - Example Project"""

sourceCompatibility = 1.8

repositories {
        
     maven { url "http://repo.maven.apache.org/maven2" }
}
dependencies {
    compile group: 'org.codehaus.groovy', name: 'groovy-all', version:'2.5.2'
    compile group: 'org.codehaus.groovy.modules.http-builder', name: 'http-builder', version: '0.7.1'
    testCompile group: 'org.spockframework', name: 'spock-core', version:'1.2-groovy-2.5'
    testCompile group: 'com.athaydes', name: 'spock-reports', version:'1.6.1'
    testCompile group: 'org.slf4j', name: 'slf4j-simple', version:'1.7.13'
}

tasks.withType(Test) {
    systemProperties System.properties
}

that’s all you need

Thank you @Ibus that’s definitely another great option. At this moment we haven’t published our Maven-based libraries so if they are required dependencies the setting up will be a little bit tricky.

Well, we are not reinventing the wheel. I want to do unit-testing for custom Keywords with JUnit. In the Katalon Studio GUI it was difficult. Therefore devalex88 proposed alternative way: do it in IDEA or Eclipse. We are reusing the best wheels, aren’t we?

By the way :grin: , I miss “Page Object” in Katalon Studio. I hope I could reinvent the wheel called “Page Object” in Katalon Studio.

Martin Fowler wrote :

However, if you write tests that manipulate the HTML elements directly your tests will be brittle to changes in the UI.

Test Objects in Katalon Studio manipulate HTML elements directly, so my Katalon tests will be brittle to changes in UI.

The “Object Repository” stuffed by “Web Recorder” tool tends to be huge in size where hundreds of duplicating Test Objects are contained. A huge Object Repository is simply hard to maintain. Due to this concern, I would rarely use “Web Recorder” for testing a large-scale Web UI. I have a hope that introducing “Page Object” pattern into Katalon Studio would enable us to reduce the size of “Object Repository”.

I have some web-ui testing projects of mine which use IDE+Groovy+Gradle+WebDriver+Spock+GEB. GEB provides nice implementation of Page Object pattern. I like this tool set.

But I still love Katalon Studio primarily for its easiness for non-programmers (my colleagues at work) to getting started with. They can not get started with the “IDE+Groovy+Gradle+WebDriver+Spock+GEB” tool set ever; it has too much of technical prerequisites — they can not set it up at all.

So I miss “Page Object” pattern in Katalon Studio.

1 Like

@kazurayam i was just kidding. honestly i love the workarounds proposed.
@devalex88 mhm … i have an idea … not sure if will work.
What if we grab all the jar’s from katalon plugins and bring them into an IDEA project (maven or gradle) ?
In theory if they are in a standard place we should be able to use them …

I have to find some time next week to play with this, in vacation now …

1 Like

I have given up the idea of testing my custom keywords with JUnit outside Katalon Studio; I mean in Eclipse.

I want to do unit-tests on my custom keyword class com.kazurayam.ksbackyard.ScreenshotDriver. This class interacts with WebDriver to take screenshot of web sites, therefore it requires the Katalon Studio runtime environment. It is impossible to mock the KS runtime environment in Eclipse, so I gave up.

I am going to investigate 2 more options, both will be performed within Katalon Studio GUI:

  1. Use Cucumber (which is built-in Katalon Studio) for testing my custom keyword classes
  2. Develop another custom keyword “runJUnit” and call it in ordinary Katalon Test Cases. The keyword should make it easier to run JUnit tests located in the Includes/scripts/groovy directory. I also want to find some way to view the testing results in concise format.
1 Like

I started learning Cucumber in Katalon Studio. I read https://docs.katalon.com/katalon-studio/docs/running-cucumber-features-file.html#in-test-cases and found such sample code:

import org.junit.runner.RunWith;
import cucumber.api.CucumberOptions;
import cucumber.api.junit.Cucumber;
         
@RunWith(Cucumber.class)
@CucumberOptions(features = "Include/features", glue = "")
public class MyCucumberRunner {}

Well, this code is using org.junit.runner.RunWith. In other words, Cucumber is running on top of JUnit. I have got a clearer view how Cucumber is integrated into Katalon Studio.

3 Likes

I have developed a custom keyword which integrates JUnit in Katalon Studio. See the following post:

1 Like

More to the subject of the original post, I tried importing my Katalon project using the build.gradle option and everything in IntelliJ is mangled, not even sure where to start. I think I should have imported it as an eclipse project like you stated. Just found other threads where build.gradle turned out more favorable results. If you going down this path, caution to the wise - don’t import the project using the build.gradle file- that is if you are using Katalon with gradle integration to begin with. I could probably work through the challenges but I won’t live that long. Gonna retry the recommended way for now . . .

1 Like

@ze2

I understand you are writing to me @kazurayam.

I have ever done importing a Katalon Studio project into IntelliJ IDEA as well as Eclipse.

Do you want help for this issue? If so, please share more information on it so that other people can try reproducing the issue on their side — the zip of the katalon project that you want to import into IntelliJ IDEA, and the build.gradle script you used.

I do not see what you mean, sorry.


In the first place, why are you, @ze2, trying to import Katalon Studio project into IntelliJ IDEA or Eclipse? As I noted at Jan 8, I found that idea is useless for me.

hi,

in IntelliJ IDEA create maven project
    implement your classes & methods
    then create .jar in File --> Project Structure --> Artifacts
    give name for your .jar file, press OK
    then build artifacts
    Build --> build artifacts
    .jar file created to path out.artifacts
    copy .jar to Katalon Drivers folder
    import package.classname.methods in Katalon testcase or keyword class

hi @devalex88 , First of all thanks a lot for doing this.This is a great help for me.

I have imported my katalon project in intellij ,every jar is working fine in intellij also but i have a problem that i am not able to run our test cases as Object Repository is not getting identified . Reason what i think is that after importing project in intellij each object in object repository has been imported with extension “.rs” but it is looking for without “.rs”.
Eg. Katalon is looking for Object with path “Object Repository/Logout/UserIcon” but in project it is “Object Repository/Logout/UserIcon.rs” . Is this a reason i am not able to execute my test cases and If yes then plz help me how can we execute our test cases.

Amar convert your object repository into Keywords and then you would be able to access.

Please how do I convert the Object Repository into Keywords. Thanks in advance for helping.

Max 2, if you trying to not to utilize OR in katalon studio then you can define your all test objects as a keywords .
Refer to this page
https://docs.katalon.com/katalon-studio/docs/handling_static_dynamic_test_objects.html#create-a-separate-keyword-for-dynamic-selectors

Hi, I performed the same as you did, but it did not work for me.

. The error i am facing is Groovyc: parsing failed. Please help me to resolve this issue

1 Like

Hi ,

I tried running my groovy scripts within intelij with Groovy sdk and JDK 1.8

but i am unable to even open the browser up, how in the screenshots were you able to run the scripts?
Caught: com.kms.katalon.core.exception.StepFailedException: Unable to open browser with url: ‘’

What is the value of GlobalVariable.Portal_URL?

just a internal URL for my company