简体   繁体   中英

Running selenium tests in ruby with Jenkins

I'm trying to set up CI on my local machine running on Mac. To do so I use Xubuntu virtual machine, Jenkins, and some simple selenium tests. tests on github

I get fresh install of Xubuntu, where I install Jenkins using official manual. In Jenkins I installed some plugins(git, ruby, rake, rbenv). In job config I use rbenv wrapper(2.1.0) with ignorance of os versions, also I use this 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)

full output is here

it looks like jenkins user have no access to display to run/see 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 . This seemed better than trying to figure out how to run FF on our VM's.

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). Thats why when I try to start Firefox it's throw me a error. 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. 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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