3

I want to run selenium tests on a Hudson slave.
The slave (i.e. the machine) that will execute the selenium is a Ubuntu 10.04.
Thus it has Gnome. Selenium needs a firefox to run.

What Hudson does now is, it creates a ssh connection to the Ubuntu machine and launches selenium there. Selenium tries to start a firefox.

And now it blames:

Error: cannot open display

What needs to be done that the 'ssh shell' gets a display from the X-server?

Caleb
  • 11,813
  • 4
  • 36
  • 49
nebenmir
  • 133
  • 1
  • 1
  • 3
  • I think many people are misunderstanding your question, or I am. To be clear, do you intend for Firefox to run on the Ubuntu machine and display on the Ubuntu machine? I.e. you are not asking how to have Firefox display back to the Hudson server, (which only triggers the test) – Norky Jun 10 '11 at 08:19
  • have you seen this rather similar question: http://serverfault.com/questions/108781/how-can-i-run-selenium-tests-on-an-ubuntu-server ? – Norky Jun 10 '11 at 10:36

5 Answers5

2

Make sure that the remote machine has ssh X11 forwarding enabled:

$ grep X11 /etc/ssh/sshd_config 
X11Forwarding yes
X11DisplayOffset 10
$

Use ssh -X user@remote_machine to connect to remote machine. If on remote machine you are using a different user to start the X client, use xauth list to get the current credentials in the ssh user, then use xauth add to add the credentials to the user you are becoming with sudo/su.

read -p 'Username: ' u;sudo -H -u $u xauth add $(xauth list|grep :$(echo ${DISPLAY: -4:2}));sudo su - $u
Mircea Vutcovici
  • 17,619
  • 4
  • 56
  • 83
  • If one has a firefox running on the local machine the '-no-remote' command line switch should be used to really run a new instance. (firefox would discover the already running one and quit silently) – cstamas Jun 10 '11 at 07:55
  • Thanx. The given command works. But the problem is, that I need to get Hudson to append the X paramter to the ssh command. But I guess this is not the right forum for hudson specific settings. – nebenmir Jun 10 '11 at 09:18
1

If the question is what I think it is

ssh testuser@ubuntuhost firefox --display :0 -no-remote

Will start firefox on ubuntuhost and have it display on that machine, assuming testuser is logged on to ubuntuhost already.

I don't know Selenium, or what exactly you're looking to test (performance, correctness of display, or simply a success return value from some javascript) but you might not even need a 'real' X server, i.e. one that actually appears on the monitor of the Ubuntu host. Xvfb might be helpful for you here, but that's beyond the scope of the original question...

Norky
  • 849
  • 4
  • 14
  • I'm sorry but that does not work. Still get foo@hitchhiker:~$ ssh ci@kabul firefox -display :0 -no-remote ci@kabul's password: Error: no display specified – nebenmir Jun 10 '11 at 09:10
  • @nebenmir: sorry, my mistake, firefox takes "--display", not "-display" – Norky Jun 10 '11 at 11:01
  • thanks a lot, very usefull with firefox imacros plugin as well !! – S12000 Dec 26 '15 at 20:07
0

You need to enable X forwarding, and run an X server locally. Pass -X or -Y to ssh.

Ignacio Vazquez-Abrams
  • 45,939
  • 6
  • 79
  • 84
0

ssh -X root@myserver or something like that

0

You need to forward X over the ssh tunnel, try this:

ssh -X host_IP

once logged in, start firefox in your terminal, it should forward your X-server to your local machine.

tw79
  • 31
  • 1
  • 4