Katalon Debian 无头浏览器

Posted

技术标签:

【中文标题】Katalon Debian 无头浏览器【英文标题】:Katalon Debian Headless Browser 【发布时间】:2018-03-16 17:37:42 【问题描述】:

我正在从 Selenium 切换到 Katalon,但遇到了一些问题。 我正在使用安装在 Debian OS 上的 Jenkins: 我正在运行这个命令:

./katalon --args -runMode=console -projectPath="/var/lib/jenkins/jobs/katalon_test/workspace/spot-systemtest/src/katalon/spot/katalon test.prj" \
-reportFolder="Reports" -reportFileName="report" \
-retry=0 -testSuitePath="Test Suites/WarmUp" \
-browserType="Headless"

我在执行过程中遇到异常:

10-05-2017 06:41:34 AM - [ERROR] - Test Cases/core/login spot2 FAILED because (of) java.awt.HeadlessException: 
No X11 DISPLAY variable was set, but this program performed an operation which requires it.

当我将变量设置为“:0”时,它会抱怨:

10-05-2017 06:24:49 AM - [ERROR] - Test Cases/core/login spot2 FAILED because (of) java.awt.AWTError: Can't connect to X11 window server using ':0' as the value of the DISPLAY variable.

没有 XServer,因为这是服务器操作系统。

我厌倦了添加环境。多变的: 导出 JAVA_OPTS="-Djava.awt.headless=true"

我也尝试在katalon 执行中传递这个参数。 不幸的是,没有任何帮助。

第二件事。 我在这样的每一步都遇到错误 java.lang.NoClassDefFoundError: com.kms.katalon.core.webui.keyword.internal.WebUIAbstractKeyword

完整的堆栈跟踪在这里

+ ./katalon --args -runMode=console -projectPath=/var/lib/jenkins/jobs/katalon_test/workspace/spot-systemtest/src/katalon/spot/katalon test.prj -reportFolder=Reports -reportFileName=report -retry=0 -testSuitePath=Test Suites/WarmUp -Djava.awt.headless=true -browserType=Headless
Starting Groovy-Eclipse compiler resolver.  Specified compiler level: unspecified
122 2.4.7.xx-201611170128-e46 = ACTIVE

--------------------------------------------------------------------------------
Test Suites/WarmUp - Headless - 20171005_062446..........................0/8(0%)
--------------------------------------------------------------------------------

10-05-2017 06:24:48 AM - [START]  - Start Test Suite : WarmUp
10-05-2017 06:24:48 AM - [RUN_DATA] - Logging run data 'hostName' with value 'root - ee4afc86e8bd'
10-05-2017 06:24:48 AM - [RUN_DATA] - Logging run data 'os' with value 'Linux 64bit'
10-05-2017 06:24:48 AM - [RUN_DATA] - Logging run data 'hostAddress' with value '172.17.0.8'
10-05-2017 06:24:48 AM - [RUN_DATA] - Logging run data 'katalonVersion' with value '4.8.0.2'
10-05-2017 06:24:48 AM - [START]  - Start Test Case : Test Cases/core/login spot2
10-05-2017 06:24:48 AM - [INFO]   - Evaluating variables for test case
10-05-2017 06:24:48 AM - [START]  - Start action : openBrowser
10-05-2017 06:24:49 AM - [END]    - End action : openBrowser
10-05-2017 06:24:49 AM - [ERROR]  - Test Cases/core/login spot2 FAILED because (of) java.awt.AWTError: Can't connect to X11 window server using ':0' as the value of the DISPLAY variable.
10-05-2017 06:24:49 AM - [END]    - End Test Case : Test Cases/core/login spot2
10-05-2017 06:24:49 AM - [START]  - Start Test Case : Test Cases/core/open_module_DASHBOARD
10-05-2017 06:24:49 AM - [INFO]   - Evaluating variables for test case
10-05-2017 06:24:49 AM - [START]  - Start action : click
10-05-2017 06:24:49 AM - [INFO]   - Finding Test Object with id 'Object Repository/core/open_module'
10-05-2017 06:24:49 AM - [END]    - End action : click
10-05-2017 06:24:49 AM - [ERROR]  - Test Cases/core/open_module_DASHBOARD FAILED because (of) java.lang.NoClassDefFoundError: com.kms.katalon.core.webui.keyword.internal.WebUIAbstractKeyword
10-05-2017 06:24:49 AM - [END]    - End Test Case : Test Cases/core/open_module_DASHBOARD
10-05-2017 06:24:49 AM - [START]  - Start Test Case : Test Cases/core/open_module_ADDRESS_BOOK
10-05-2017 06:24:49 AM - [INFO]   - Evaluating variables for test case
10-05-2017 06:24:49 AM - [START]  - Start action : click
10-05-2017 06:24:49 AM - [INFO]   - Finding Test Object with id 'Object Repository/core/open_module'
10-05-2017 06:24:49 AM - [END]    - End action : click
10-05-2017 06:24:49 AM - [ERROR]  - Test Cases/core/open_module_ADDRESS_BOOK FAILED because (of) java.lang.NoClassDefFoundError: com.kms.katalon.core.webui.keyword.internal.WebUIAbstractKeyword
10-05-2017 06:24:49 AM - [END]    - End Test Case : Test Cases/core/open_module_ADDRESS_BOOK
10-05-2017 06:24:49 AM - [START]  - Start Test Case : Test Cases/core/open_module_TRACKING
10-05-2017 06:24:49 AM - [INFO]   - Evaluating variables for test case
10-05-2017 06:24:49 AM - [START]  - Start action : click
10-05-2017 06:24:49 AM - [INFO]   - Finding Test Object with id 'Object Repository/core/open_module'
10-05-2017 06:24:49 AM - [END]    - End action : click
10-05-2017 06:24:49 AM - [ERROR]  - Test Cases/core/open_module_TRACKING FAILED because (of) java.lang.NoClassDefFoundError: com.kms.katalon.core.webui.keyword.internal.WebUIAbstractKeyword
10-05-2017 06:24:49 AM - [END]    - End Test Case : Test Cases/core/open_module_TRACKING
10-05-2017 06:24:49 AM - [START]  - Start Test Case : Test Cases/core/open_module_TRANSPORT_ORDER
10-05-2017 06:24:49 AM - [INFO]   - Evaluating variables for test case
10-05-2017 06:24:49 AM - [START]  - Start action : click
10-05-2017 06:24:49 AM - [INFO]   - Finding Test Object with id 'Object Repository/core/open_module'
10-05-2017 06:24:49 AM - [END]    - End action : click
10-05-2017 06:24:49 AM - [ERROR]  - Test Cases/core/open_module_TRANSPORT_ORDER FAILED because (of) java.lang.NoClassDefFoundError: com.kms.katalon.core.webui.keyword.internal.WebUIAbstractKeyword
10-05-2017 06:24:49 AM - [END]    - End Test Case : Test Cases/core/open_module_TRANSPORT_ORDER
10-05-2017 06:24:49 AM - [START]  - Start Test Case : Test Cases/core/open_module_REPORT
10-05-2017 06:24:50 AM - [INFO]   - Evaluating variables for test case
10-05-2017 06:24:50 AM - [START]  - Start action : click
10-05-2017 06:24:50 AM - [INFO]   - Finding Test Object with id 'Object Repository/core/open_module'
10-05-2017 06:24:50 AM - [END]    - End action : click
10-05-2017 06:24:50 AM - [ERROR]  - Test Cases/core/open_module_REPORT FAILED because (of) java.lang.NoClassDefFoundError: com.kms.katalon.core.webui.keyword.internal.WebUIAbstractKeyword
10-05-2017 06:24:50 AM - [END]    - End Test Case : Test Cases/core/open_module_REPORT
10-05-2017 06:24:50 AM - [START]  - Start Test Case : Test Cases/core/open_module_PURCHASE_ORDER
10-05-2017 06:24:50 AM - [INFO]   - Evaluating variables for test case
10-05-2017 06:24:50 AM - [START]  - Start action : click
10-05-2017 06:24:50 AM - [INFO]   - Finding Test Object with id 'Object Repository/core/open_module'
10-05-2017 06:24:50 AM - [END]    - End action : click
10-05-2017 06:24:50 AM - [ERROR]  - Test Cases/core/open_module_PURCHASE_ORDER FAILED because (of) java.lang.NoClassDefFoundError: com.kms.katalon.core.webui.keyword.internal.WebUIAbstractKeyword
10-05-2017 06:24:50 AM - [END]    - End Test Case : Test Cases/core/open_module_PURCHASE_ORDER
10-05-2017 06:24:50 AM - [START]  - Start Test Case : Test Cases/core/logout_spot2
10-05-2017 06:24:50 AM - [INFO]   - Evaluating variables for test case
10-05-2017 06:24:50 AM - [START]  - Start action : click
10-05-2017 06:24:50 AM - [INFO]   - Finding Test Object with id 'Object Repository/core/top_bar/top_bar_menu_by_icon'
10-05-2017 06:24:50 AM - [END]    - End action : click
10-05-2017 06:24:50 AM - [ERROR]  - Test Cases/core/logout_spot2 FAILED because (of) java.lang.NoClassDefFoundError: com.kms.katalon.core.webui.keyword.internal.WebUIAbstractKeyword
10-05-2017 06:24:50 AM - [END]    - End Test Case : Test Cases/core/logout_spot2
10-05-2017 06:24:50 AM - [END]    - End Test Suite : WarmUp
Copying report to folder /var/lib/jenkins/jobs/katalon_test/workspace/spot-systemtest/src/katalon/spot/Reports...

--------------------------------------------------------------------------------
Test Suites/WarmUp - Headless - 20171005_062446........................8/8(100%)
--------------------------------------------------------------------------------

【问题讨论】:

【参考方案1】:

我认为您还需要为 Jenkins 添加其他配置。

    安装这个插件:https://wiki.jenkins.io/display/JENKINS/Xvfb+Plugin

    安装后,在此插件的“附加设置”字段中使用此设置:

    导出 DISPLAY=:1.0

对于您的其他问题,您可以发布完整的测试用例脚本吗?

【讨论】:

以上是关于Katalon Debian 无头浏览器的主要内容,如果未能解决你的问题,请参考以下文章

火狐浏览器+katalon Recorder插件=UI脚本录制

火狐浏览器+katalon Recorder插件=UI脚本录制

katalon系列十五:给浏览器添加cookie自动登陆

无法单击Katalon Studio中的对象

无头浏览器是啥?它有啥用?

教你怎么用JavaScript检测当前浏览器是无头浏览器