1

Firstly I was getting the following error:

org.openqa.selenium.firefox.NotConnectedException: Unable to connect to host 127.0.0.1 on port 7055 after 45000 ms. Firefox console output:
Error: no display specified

So I have used export DISPLAY=:0 to circumvent this problem. Followed to that I have found Selenium tests were running using the root user and all was fine.

However now I can see when these tests are getting executed from Jenkins the following error is coming up:

org.openqa.selenium.firefox.NotConnectedException: Unable to connect to host 127.0.0.1 on port 7055 after 45000 ms. Firefox console output:
No protocol specified
Error: cannot open display: :0

I am running this on a Redhat 6 box.

Exploring
  • 2,493
  • 11
  • 56
  • 97

2 Answers2

3

You can download the Jenkins xvnc plugin and make that plugin start(and export) a virtual display for selenium to use. The jenkins user may not have access to the :0 display.

Amey
  • 8,470
  • 9
  • 44
  • 63
1

The best approach to solve this problem is making changes to the jenkins start script.

The solution that works on Ubuntu for me correctly is as follows:

1.Open Jenkins shell script located at: /etc/init.d/jenkins.

2.Add the following lines as follows before PATH variable:

/usr/bin/X :0 vt7 -ac
export DISPLAY=:0
xhost +
sjmach
  • 426
  • 6
  • 15
  • `sudo service jenkins restart` now gives me the following errors: `(EE) Fatal server error: (EE) Server is already active for display 0 If this server is no longer running, remove /tmp/.X0-lock and start again. (EE) (EE) Please consult the The X.Org Foundation support at http://wiki.x.org for help. (EE) No protocol specified xhost: unable to open display ":0"` – Jonathan May 15 '15 at 21:26
  • There might be an error in your Xorg configuration. A solution is detailed here: http://askubuntu.com/questions/69896/cant-run-x-configure-server-is-already-active-error. However, I would suggest you use the plugin as suggested by Amey. – sjmach May 16 '15 at 14:02
  • @sjmach, I've my jenkins server installed on Windows machine. In that case what is equivalent of this. I mean which file I need to update with the changes you've suggested. – Alpha Feb 03 '20 at 07:20
  • @TDHM: Are you using a Windows machine locally or on a cloud provider (VM)? – sjmach Feb 03 '20 at 10:16
  • For our project, it is on VM but I also have prepared Jenkins master on my machine locally. First one is more important. If you've solution for second one, please do suggest that as well. – Alpha Feb 03 '20 at 10:49
  • @TDHM: Assuming it is on Azure, this might work for you - https://learn.microsoft.com/en-us/azure/virtual-machines/windows/quick-create-portal. The idea is to do a remote desktop connection to run the tests. – sjmach Feb 03 '20 at 11:57
  • @sjmach thanks but unfortunately the VM is in-house. Is there any other way to configure it? – Alpha Feb 03 '20 at 13:33
  • Even if the Vm is in house you can use rdp. How do you connect that machine? – sjmach Feb 05 '20 at 16:33