2

I am unable to start the browser on the CI server (localhost on Linux in my case) when triggering a cucumber test via invoking a rake task after build from Jenkins. Jenkins console log is as below. I am pretty sure everything is set up properly, as I can run it successfully on the server via command line.

01:26:43 [cucumber] $ /usr/local/rvm/scripts/gems/ruby-2.3.0/bin/rake schedule_win_job:features --trace

01:26:43 ** Invoke schedule_win_job:features (first_time)

01:26:43 ** Execute schedule_win_job:features

01:26:43 /usr/local/rvm/scripts/rubies/ruby-2.3.0/bin/ruby -S bundle exec cucumber --tag @schedule_job --profile dev

**01:27:45 unable to obtain stable firefox connection in 60 seconds (127.0.0.1:7055) (Selenium::WebDriver::Error::WebDriverError)**

01:27:45 /usr/local/rvm/scripts/gems/ruby-2.3.0/gems/selenium-webdriver-2.53.0/lib/selenium/webdriver/firefox/launcher.rb:90:in `connect_until_stable'

01:27:45 /usr/local/rvm/scripts/gems/ruby-2.3.0/gems/selenium-webdriver-2.53.0/lib/selenium/webdriver/firefox/launcher.rb:55:in `block in launch'

01:27:45 /usr/local/rvm/scripts/gems/ruby-2.3.0/gems/selenium-webdriver-2.53.0/lib/selenium/webdriver/common/socket_lock.rb:43:in `locked'

01:27:45 /usr/local/rvm/scripts/gems/ruby-2.3.0/gems/selenium-webdriver-2.53.0/lib/selenium/webdriver/firefox/launcher.rb:51:in `launch'

01:27:45 /usr/local/rvm/scripts/gems/ruby-2.3.0/gems/selenium-webdriver-2.53.0/lib/selenium/webdriver/firefox/bridge.rb:43:in `initialize'

01:27:45 /usr/local/rvm/scripts/gems/ruby-2.3.0/gems/selenium-webdriver-2.53.0/lib/selenium/webdriver/common/driver.rb:53:in `new'

01:27:45 /usr/local/rvm/scripts/gems/ruby-2.3.0/gems/selenium-webdriver-2.53.0/lib/selenium/webdriver/common/driver.rb:53:in `for'

01:27:45 /usr/local/rvm/scripts/gems/ruby-2.3.0/gems/selenium-webdriver-2.53.0/lib/selenium/webdriver.rb:84:in `for'

01:27:45 /usr/local/rvm/scripts/gems/ruby-2.3.0/gems/watir-webdriver-0.9.1/lib/watir-webdriver/browser.rb:46:in `initialize'
orde
  • 5,233
  • 6
  • 31
  • 33
Ruifeng Ma
  • 2,399
  • 1
  • 22
  • 40
  • Same answer as: http://stackoverflow.com/questions/36917134/unable-to-run-automation-on-firefox-jenkins from earlier today - make sure you have Firefox 45 on your path. – titusfortner Apr 28 '16 at 19:17
  • Sorry I checked through and all the requirements you mentioned are met, yet the problem still persists. If I change the browser to Chrome, I encounter a new problem reported here [StackOverflow question](http://stackoverflow.com/questions/22558077/unknown-error-chrome-failed-to-start-exited-abnormally-driver-info-chromedri) and the solution there does not work for me either. – Ruifeng Ma Apr 29 '16 at 11:10
  • By the way, below is the error message I got if I try to start firefox using a bare shell command through Jenkins. `[20:38:21] /usr/bin/firefox [20:38:21] Error: GDK_BACKEND does not match available displays` – Ruifeng Ma Apr 29 '16 at 12:53

2 Answers2

0

Someone else had a similar issue and the solution looked to be making sure you have a stable version of Capybara and latest selenium webdriver

unable to obtain stable firefox connection in 60 seconds (127.0.0.1:7055)

Let me know if this solution helps!

Community
  • 1
  • 1
modusAndrew
  • 251
  • 2
  • 8
  • Thank you for your answer. Although the solutions there did not help, they provided me a hint to get to the root cause a bit closer. After installing Jenkins server, there is a service account called jenkins created. It seems this account does not have the privileges to open a display. I'll search again to get a final solution and post it here. – Ruifeng Ma Apr 30 '16 at 00:48
0

It turns out the account nature of Jenkins user does not allow it to run GUI tests within the Jenkins server.

Firefox is a GUI application and it needs to connect to an X server to send its commands to draw windows and such. Usually Jenkins is set up to run as a background system daemon that has no access to any X server session.

This is the reason for below error when trying to launch firefox in a Jenkins build using shell command /usr/bin/firefox.

No protocol specified

XDG_RUNTIME_DIR not set in the environment

Error: cannot open display: :0

Hence a possible solution would be to use pkexec command to trigger the test with root privilege (it might be possible to add the Jenkins user to the sudo group such that it can run the commands successfully, but not recommended due to security concern, and I tried it didn't work).

To achieve full automation with pkexec needs some other settings, e.g. disable authentication prompts. I will update with a more detailed answer once I have the step-wise solution ready.

Ruifeng Ma
  • 2,399
  • 1
  • 22
  • 40
  • Of course we can use the [Xvnc plugin](https://wiki.jenkins-ci.org/display/JENKINS/Xvnc+Plugin), which is a lot easier, as documented [here](http://stackoverflow.com/questions/27060519/unable-to-run-firefox-through-jenkins). – Ruifeng Ma May 03 '16 at 14:31