从Jenkins运行Robot Framework测试时,浏览器永远不会打开 [英] Browser never opens when running Robot Framework tests from Jenkins

查看:247
本文介绍了从Jenkins运行Robot Framework测试时,浏览器永远不会打开的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在OSX笔记本电脑上运行来自Jenkins的RF/Selenium2Library测试.默认情况下,Jenkins作为用户"jenkins"安装.我已经安装了用于Jenkins的RF插件并设置了环境变量,除了浏览器从未打开(firefox或chrome)都没有问题,并且一切正常之外,一切正常,并且测试因硒超时而失败,并指出此类元素从未出现.

I'm experimenting with running my RF/Selenium2Library tests from Jenkins on my OSX laptop. Jenkins is installed as default as user 'jenkins'. I have the RF plugin for Jenkins installed and environment variables set, and everything works fine EXCEPT the browser never opens (neither firefox nor chrome) and the tests fail with selenium timeouts saying that such and such element never appeared.

我的直觉是,我需要在某个地方设置一个显示变量,以使浏览器能够正确打开.

My hunch is that I need to set a display variable somewhere to get the browser to open properly.

这是我从詹金斯(Jenkins)的'execute shell'命令,用于该项目:

Here's my 'execute shell' command from Jenkins for this project:

source/Users/Shared/Jenkins/.bash_profile; pybot -b/用户/共享/詹金斯/robot_output/dbug.log -i SMOKE01 -d/用户/共享/詹金斯/robot_output//用户/KWHome/Dev/PycharmProjects/BHI/Tests; 退出0

source /Users/Shared/Jenkins/.bash_profile; pybot -b /Users/Shared/Jenkins/robot_output/dbug.log -i SMOKE01 -d /Users/Shared/Jenkins/robot_output/ /Users/KWHome/Dev/PycharmProjects/BHI/Tests; exit 0

同样,Selenium似乎认为浏览器已在某个位置打开,并等待初始元素出现,但它们从未这样做,因为实际上没有打开浏览器.我是詹金斯(Jenkins)的新手,非常感谢您对了解这里发生的事情的任何建议.

Again, Selenium seems to think a browser is open somewhere and waits for the initial elements to appear, but they never do because no browser is actually open. I'm a total Jenkins newbie, so huge thanks for any advice on understanding what's going on here.

已添加:

这是从Jenkins构建后创建的jenkins用户dbug日志的一些输出:

Here's some output from the jenkins user dbug log created after a build from Jenkins:

20140719 21:28:23.914 - INFO - Opening browser 'firefox' to base url 'https://staging.azzi-mvconnects.com/'
20140719 21:28:27.273 - DEBUG - Opened browser with session id a2414ad7-f523-7441-8a54-dd5c68f4049b
20140719 21:28:27.274 - INFO - +----- END KW: Selenium2Library.Open Browser (3360)
20140719 21:28:27.274 - INFO - +----- START KW: Selenium2Library.Maximize Browser Window [ ]
20140719 21:28:27.415 - INFO - +----- END KW: Selenium2Library.Maximize Browser Window (141)
20140719 21:28:27.416 - INFO - +----- START KW: Selenium2Library.Wait Until Element Is Visible [ ${home_login_button} ]
20140719 21:28:32.500 - INFO - +------ START KW: Selenium2Library.Capture Page Screenshot [ ]
20140719 21:28:32.909 - INFO - </td></tr><tr><td colspan="3"><a href="selenium-screenshot-1.png"><img src="selenium-screenshot-1.png" width="800px"></a>
20140719 21:28:32.909 - INFO - +------ END KW: Selenium2Library.Capture Page Screenshot (409)
20140719 21:28:32.910 - FAIL - Element 'ctl00_LoginLink' was not visible in 5 seconds

浏览器似乎已打开",但从未出现在桌面上.我尝试在运行pybot的命令前放置"DISPLAY =:0",但没有任何更改.

The browser appears to have 'opened', but it never appears on the desktop. I tried putting 'DISPLAY=:0' before the command to run pybot but no change.

推荐答案

如果您的Jenkins作业需要运行显示GUI的内容,则您将无法在Jenkins中运行作为后台服务运行的版本(无论是在Windows,Mac还是Windows上) Linux).

If your Jenkins job needs to run something that displays a GUI, you cannot run that build in Jenkins which runs as a background service (whether on Windows, Mac or Linux).

(在Linux中,您可以使用Xvnc或类似的假X服务器玩花样,甚至还有Jenkins插件使之更简单.)

(In Linux you can play tricks with Xvnc or similar fake X servers and there are even Jenkins plugins that make it simpler.)

您的备选方案是:

  • 使用GUI会话登录并通过键入java -jar /path/to/jenkins.war在终端窗口中运行Jenkins.在GUI上下文中启动Jenkins时,Jenkins启动的任何进程都可以与GUI系统对话并绘制窗口.
  • 或者您可以在Jenkins中设置JNLP从站,然后使用GUI会话登录,打开Web浏览器以访问您的Jenkins,并启动连接到Jenkins主站的JNLP从站,现在从站正在GUI上下文中运行,您可以配置作业以在从属服务器上执行.在从站中执行的进程将能够与GUI系统对话并绘制窗口.
  • Log in using the GUI session and run Jenkins in a terminal window by typing java -jar /path/to/jenkins.war. When Jenkins is started in the GUI context, any processes started by Jenkins are able to talk to the GUI system and draw windows.
  • Or you can set up a JNLP slave in Jenkins, then log in using the GUI session, open a web browser to access your Jenkins and start the JNLP slave that connects to Jenkins master and now that the slave is running in GUI context, you can configure the job to execute on the slave. Processes that execute in the slave will be able to talk to the GUI system and draw windows.

这篇关于从Jenkins运行Robot Framework测试时,浏览器永远不会打开的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆