needed to run some tests for a web application on a remote server. only ssh access was realistic. was using selenium webdriver. wanted to use the real browser, which requires the gui of course. is that possible? yes…
remote system is running ubuntu. first we install vnc on it. it is some kind of virtual remote desktop thing. uu yes
sudo apt-get install x11vnc
sudo apt-get install xvfb
the first one is the vnc server, the second one allows you to create new virtual displays while starting the server over command line.
start the remote server
x11vnc -safer -localhost -nopw -forever -create
safer: all the examples had this so i put it there. doh?
localhost: only allow connections from localhost (where you ssh anyway)
forever: allow connecting to the virtual desktop as many times as you like, so you can shut down your ssh client, restart the ssh connection later, reconnect to the virtual display and check the results and what it is doing. you might need to “nohup” it, i forget.. but try it out.
to only allow one time connection and no more change “forever” to “once”.
then to reconnect to the same display at a later time with another ssh session, do the following
x11vnc -safer -localhost -nopw -forever -display :20
where the only difference is that instead of “create” we now have “display” with the identifier of the display we created previously.
then you need to be able to connect to your virtual desktop. i used tightvnc which is a java-based vnc client. when you run x11vnc it prints out the port number. usually that is 5900 but if that is taken might be something else.
so we need to set up an ssh tunnel for that. in putty you go to settings->connection->ssh->tunnels and set whatever port you like in “source port”, lets pretend that is also 5900. and on the “destination” set “locahost:5900” or whatever your port is. now start tightvnc and set it to connect to “localhost:5900”. that is, this is the source port you set in putty (or whatever you use for your tunnel). confusing with the same ports, right, well can’t make it easy on myself arrrrrr…
then you have a connection (you wish). now you will see at the top your display id such as :20. use this later to re-connect your vnc session if needed. you can also find this out by logging into the system over ssh while using the remote session and typing “w”. the w command lists the tty of the user as the display id.
now you have graphical display on the remote system. so now you just run your webdriver tests as usual. with some luck, you can just leave them running and later come back, connect to the same virtual display id, and see what it has managed to test for you.. whooppee.