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.