简体   繁体   English

使用Jenkins在红宝石中运行硒测试

[英]Running selenium tests in ruby with Jenkins

I'm trying to set up CI on my local machine running on Mac. 我正在尝试在Mac上运行的本地计算机上设置CI。 To do so I use Xubuntu virtual machine, Jenkins, and some simple selenium tests. 为此,我使用了Xubuntu虚拟机,Jenkins和一些简单的硒测试。 tests on github 在github上测试

I get fresh install of Xubuntu, where I install Jenkins using official manual. 我会重新安装Xubuntu,并使用官方手册在其中安装Jenkins。 In Jenkins I installed some plugins(git, ruby, rake, rbenv). 在詹金斯,我安装了一些插件(git,ruby,rake,rbenv)。 In job config I use rbenv wrapper(2.1.0) with ignorance of os versions, also I use this gemlist: 在作业配置中,我将rbenv wrapper(2.1.0)与操作系统版本一起使用,而我也使用此gemlist:

bundler,rake,rspec,selenium-webdriver,capybara 

and running that job with 然后用

rspec spec

And when I run this job I recieve something like that for every test: 当我执行这项工作时,每次测试都会收到类似的信息:

Selenium::WebDriver::Error::WebDriverError: unable to obtain stable firefox connection in 60 seconds (127.0.0.1:7055) Selenium :: WebDriver :: Error :: WebDriverError:无法在60秒内获得稳定的Firefox连接(127.0.0.1:7055)

full output is here 完整的输出在这里

it looks like jenkins user have no access to display to run/see firefox. 看起来jenkins用户无权显示来运行/查看Firefox。 Anyone know how to make it work? 任何人都知道如何使其工作吗?

We ran into this at work recently and actually opted for Capybara and set the driver to poltergeist . 我们最近在工作中遇到了这个问题,实际上选择了水豚 ,并将司机设置为poltergeist This seemed better than trying to figure out how to run FF on our VM's. 这似乎比试图弄清楚如何在我们的VM上运行FF更好。

That said, we were able to get a small test suite running by following the instructions here 也就是说,我们可以按照此处的说明运行一个小型测试套件

Answer was not so simple as I think. 答案并不像我想的那么简单。 The problem is that jenkins service has no access to displays (when it installed via native package). 问题是,jenkins服务无法访问显示器(通过本地软件包安装时)。 Thats why when I try to start Firefox it's throw me a error. 这就是为什么当我尝试启动Firefox时会抛出一个错误。 try: 尝试:

$ sudo su - jenkins && firefox

So it's need access to display to start browser successfully. 因此需要显示才能成功启动浏览器。 This is how I done it: 这是我的方法:

  1. first of all I used answer form here where I changed to my local user. 首先,我在这里使用答案表格, 此我更改为本地用户。

  2. Then I installed xvfb plugin to Jenkins, and in my build job preset display to '0' - which is my actual user display. 然后,我将xvfb插件安装到Jenkins,并在我的构建作业预设显示中显示为“ 0”,这是我的实际用户显示。 with that option all my tests would run 'headless' but on actual display. 使用该选项,我的所有测试将“无头运行”,但会在实际显示中显示。

This could be not the best way to solve my problem, but it definitely works for me. 这可能不是解决我的问题的最佳方法,但肯定对我有用。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM