Jenkins Cannot Run Firefox: No Protocol Specified Error: Cannot Open Display:: 0

jenkins cannot run firefox: No protocol specified Error: cannot open display: :0

Just install a virtual framebuffer in your machine and it will work.

Now i'm using Xvfb, but there are many others.

Here is some tutorials to setup your machine:

  • http://www.installationpage.com/selenium/how-to-run-selenium-headless-firefox-in-ubuntu/
  • http://www.labelmedia.co.uk/blog/setting-up-selenium-server-on-a-headless-jenkins-ci-build-machine.html

Also, there is this plugin: https://wiki.jenkins-ci.org/display/JENKINS/Xvfb+Plugin

Error: cannot open display: :0 geckodriver selenium

I think the frame buffer should be the right method, the problem maybe the command you use. Try the following command:

xvfb-run -d -s '-screen 0 1920x1080x24' /home/dummy/project/venv/bin/gunicorn --chdir /home/dummy/project -w 9 main:app  # remove -d option or use -a option instead

Unable to start browser from Jenkins CI

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.

Trying to run Selenium tests using Hudson - Error: no display specified

You need to run the browsers launched by Selenium in headless mode so that they don't try to open a display. Here's a good blog post with more details.



Related Topics



Leave a reply



Submit