简体   繁体   English

从Jenkins运行Robot Framework测试时,浏览器永远不会打开

[英]Browser never opens when running Robot Framework tests from Jenkins

I'm experimenting with running my RF/Selenium2Library tests from Jenkins on my OSX laptop. 我正在尝试在OSX笔记本电脑上运行Jenkins的RF / Selenium2Library测试。 Jenkins is installed as default as user 'jenkins'. 默认情况下,Jenkins作为用户“ 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. 我已经安装了用于Jenkins的RF插件并设置了环境变量,并且一切正常,除非浏览器从未打开(firefox和chrome)都没有,并且测试因硒超时而失败,并指出此类元素从未出现。

My hunch is that I need to set a display variable somewhere to get the browser to open properly. 我的直觉是,我需要在某个地方设置一个显示变量,以使浏览器正确打开。

Here's my 'execute shell' command from Jenkins for this project: 这是我从詹金斯(Jenkins)的'execute shell'命令,用于该项目:

source /Users/Shared/Jenkins/.bash_profile; 来源/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; pybot -b /用户/共享/詹金斯/robot_output/dbug.log -i SMOKE01 -d /用户/共享/詹金斯/ robot_output / /用户/ KWHome / Dev / PycharmProjects / BHI / Tests; exit 0 出口0

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. 再次,Selenium似乎认为浏览器已在某个位置打开,并等待初始元素出现,但它们从未这样做,因为实际上没有打开浏览器。 I'm a total Jenkins newbie, so huge thanks for any advice on understanding what's going on here. 我是Jenkins的新手,非常感谢您对了解这里发生的事情的任何建议。

ADDED: 添加:

Here's some output from the jenkins user dbug log created after a build from Jenkins: 这是从Jenkins构建后创建的jenkins用户dbug日志的一些输出:

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

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. 我尝试在运行pybot的命令前放置“ DISPLAY =:0”,但没有更改。

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). 如果您的Jenkins作业需要运行显示GUI的内容,则无法在Jenkins中运行作为后台服务运行的版本(无论是在Windows,Mac还是Linux上)。

(In Linux you can play tricks with Xvnc or similar fake X servers and there are even Jenkins plugins that make it simpler.) (在Linux中,您可以使用Xvnc或类似的假X服务器玩弄花样,甚至还有Jenkins插件使之更简单。)

Your alternatives are either: 您可以选择以下任一方法:

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

This question here answers my question, hands down: stackoverflow.com/questions/8787682/…. 这个问题在这里回答了我的问题:stackoverflow.com/questions/8787682/…。 Jenkins runs the tests as a service in the background. Jenkins在后台将测试作为服务运行。 It must do something similar on osx/unix. 它必须在osx / unix上执行类似的操作。

We need to run headless browser. 我们需要运行无头浏览器。 We had achieved this for Firefox. 我们已经为Firefox实现了这一目标。 We used centOS in jenkins Slave. 我们在詹金斯奴隶中使用了centOS。

I have documented it here: http://dailychitty.blogspot.in/2014/07/configuring-jenkins-agent-to-run-robot.html 我已经在这里记录了它: http : //dailychitty.blogspot.in/2014/07/configuring-jenkins-agent-to-run-robot.html

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 机器人框架未在詹金斯上运行 - robot framework not running on jenkins 从Jenkins运行Cucumber测试时浏览器无法打开 - Browser not opening when running Cucumber tests from Jenkins jenkins上的机器人框架测试中的Web驱动程序异常 - Web driver exception on robot framework tests on jenkins 当 Jenkins 运行测试时,无法看到浏览器上正在运行 Selenium 测试 - Unable to see Selenium tests are running on the browser when the test is run by Jenkins 从jenkins运行时,浏览器不会自动启动 - Browser is not launching automatically when running from jenkins 在Docker容器中运行Robot Framework Selenium测试时出现Geckodriver / Firefox问题 - Geckodriver/Firefox issue when running Robot Framework Selenium tests inside Docker container Jenkins在不打开浏览器的情况下运行selenium测试 - Jenkins running selenium tests without opening browser "机器人框架:在测试之间重用现有的浏览器窗口" - robot framework: Reuse existing Browser Window between Tests 使用jenkins运行selenium测试用例(测试用例在机器人框架中) - Running selenium test cases(Test cases are in robot framework) using jenkins 通过testng Framework执行时,我的硒测试不是从cmd或Jenkins运行的。 结果:总测试次数:0,失败次数:0,跳过次数:0 - My selenium tests aren't running from either cmd or Jenkins when executed via testng Framework. Results: Total tests run: 0, Failures: 0, Skips: 0
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM