1

Goal

Execute scripts produced with Katalon Studio, using java. If this works, scripts could run on my devops pipeline: browserstack or my own selenium server.

Problem

I have this groovy script which is the same as Katalon studio produced scripts:

import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI
WebUI.openBrowser("https://www.katalon.com")

I tried to run this script using java maven project. I achieved to find all the required jars. But when I run I get this error: java.lang.VerifyError: Bad type on operand stack

Exception in thread "main" com.kms.katalon.core.exception.StepFailedException: Unable to open browser with url: 'https://www.katalon.com'
    at com.kms.katalon.core.webui.keyword.internal.WebUIKeywordMain.stepFailed(WebUIKeywordMain.groovy:64)
    at com.kms.katalon.core.webui.keyword.internal.WebUIKeywordMain.runKeyword(WebUIKeywordMain.groovy:26)
    at com.kms.katalon.core.webui.keyword.builtin.OpenBrowserKeyword.openBrowser(OpenBrowserKeyword.groovy:81)
    at com.kms.katalon.core.webui.keyword.builtin.OpenBrowserKeyword.execute(OpenBrowserKeyword.groovy:67)
    at com.kms.katalon.core.keyword.internal.KeywordExecutor.executeKeywordForPlatform(KeywordExecutor.groovy:73)
    at com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords.openBrowser(WebUiBuiltInKeywords.groovy:63)
    at com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords$openBrowser.call(Unknown Source)
    at Script1.run(Script1.groovy:17)
    at JenkinsGroovySandbox1.main(JenkinsGroovySandbox1.java:37)
Caused by: java.lang.VerifyError: Bad type on operand stack
Exception Details:
  Location:
    com/kms/katalon/core/webui/driver/DriverFactory.createNewRemoteWebDriver(Ljava/util/Map;Lorg/openqa/selenium/remote/DesiredCapabilities;)Lorg/openqa/selenium/WebDriver; @168: invokespecial
  Reason:
    Type 'io/appium/java_client/remote/AppiumCommandExecutor' (current frame, stack[2]) is not assignable to 'org/openqa/selenium/remote/HttpCommandExecutor'
  Current Frame:
    bci: @168
    flags: { }
    locals: { 'java/util/Map', 'org/openqa/selenium/remote/DesiredCapabilities', 'java/lang/String', 'java/lang/String', 'com/kms/katalon/core/network/ProxyInformation', 'java/lang/Object', 'io/appium/java_client/remote/AppiumCommandExecutor' }
    stack: { uninitialized 161, uninitialized 161, 'io/appium/java_client/remote/AppiumCommandExecutor', 'org/openqa/selenium/remote/DesiredCapabilities' }
  Bytecode:
    0x0000000: b800 f04d b802 a54e 2dc7 0006 1236 4eb8
    0x0000010: 020a 3a04 1904 b602 0e99 0014 2bb8 02a8
    ...
    0x00000e0: bf                                     
  Stackmap Table:
    append_frame(@15,Object[#154],Object[#154])
    append_frame(@45,Object[#527])
    same_frame(@98)
    append_frame(@119,Object[#3])
    same_frame(@142)
    same_frame(@172)
    same_frame(@202)

    at com.kms.katalon.core.webui.keyword.builtin.OpenBrowserKeyword$_openBrowser_closure1.doCall(OpenBrowserKeyword.groovy:74)
    at com.kms.katalon.core.webui.keyword.builtin.OpenBrowserKeyword$_openBrowser_closure1.call(OpenBrowserKeyword.groovy)
    at com.kms.katalon.core.webui.keyword.internal.WebUIKeywordMain.runKeyword(WebUIKeywordMain.groovy:20)
    ... 7 more

Theories

RemoteWebDriver

As we can see in the log, by default katalon libraries are using remote web driver with Appium. I can't find how to setup the webdriver in this script using katalon libraries. With pure selenium is very easy :D

I'm researching the possibility to use Local driver instead remote driver or how to configure the parameters in my simple groovy script to use my remote driver.

Katalon Community vs Enterprise

Maybe katalon scripts are supposed to be executed using Katalon tools, not from outside katalon tools.

Attempts

Mate Mrše
  • 7,997
  • 10
  • 40
  • 77
JRichardsz
  • 14,356
  • 6
  • 59
  • 94

1 Answers1

0

Finally I achieved to run any katakon script with java and maven. All of that on linux. This is what I did:

1.- load several katakon jars to my pom. They are not public (early 2021) so the only why was extract them from the katalon studio installation.

<dependency>
  <groupId>katalon</groupId>
  <artifactId>com.kms.katalon.core_1.0.0.202101180916.jar</artifactId>
  <version>1.0.0</version>
  <type>jar</type>
  <scope>system</scope>
  <systemPath>${katalon.studio.home.path}/plugins/com.kms.katalon.core_1.0.0.202101180916.jar</systemPath>
</dependency>

2.- Modify one katalon class due to new errors. The only solution was to delete one method of one class from katalon source code which is public:

original: https://github.com/katalon-studio/katalon-studio-testing-framework

modified: https://github.com/jrichardsz-software-architect-tools/katalon-runner/blob/beta/src/main/java/com/kms/katalon/core/testobject/ObjectRepository.java#L263

Here is my project wich I called: katalon-runner.

https://github.com/jrichardsz-software-architect-tools/katalon-runner

The execution flow is:

  • clone and build the katalon runner
  • record the ui flow with katalon to obtain the groovy scripts
  • using the shell, execute the katalon-runner passing it several parameters

As you see this has a plugin nature, so it is easy to use on Jenkins or any ci server.

Pd: I have some local changes. I will update the repository.

JRichardsz
  • 14,356
  • 6
  • 59
  • 94