Read more

Hide your Selenium browser window with a VNC server

Tobias Kraze
July 25, 2011Software engineer at makandra GmbH

This is now part of geordi. Please don't follow the instructions below, if you use geordi.

Illustration UI/UX Design

UI/UX Design by makandra brand

We make sure that your target audience has the best possible experience with your digital product. You get:

  • Design tailored to your audience
  • Proven processes customized to your needs
  • An expert team of experienced designers
Read more Show archive.org snapshot

Inspired by the recent headless Selenium note, I found yet another solution for the problem to hide your selenium tests away.

This has the advantages
^

  • not to require a gem (so you do not force this on others)
  • to allow you to take a look at the running webdriver if necessary

Simply make a script that runs your cucumber tests and runs this before:

vncserver :6 -localhost -nolisten tcp -SecurityTypes None &>/dev/null 
DISPLAY=":6"

Your webdriver will now start within a VNC server (which will only listen to your machine). To take a look, open a VNC viewer using

vncviewer :6

You can close the viewer, and the tests will keep running.

Custom resolution

The X session provided by the VNC server can have a custom resolution. Just pass your preferred resolution like this: -geometry 1280x1024

Ubuntu issues

You need a VNC server and viewer:

sudo apt-get install tightvncserver
sudo apt-get install xtightvncviewer

sudo apt-get install vnc4server # alternative vncserver if tightvncserver doesn't work

Also on Ubuntu you are asked for a password the first time you start the VNC server. It will not be used by the above call after that (due to SecurityTypes None).

So for a first-time setup run it without the "&>/dev/null" part, choose a password, and terminate your vnc server.

Terminating the VNC server

vncserver -kill :6
Posted by Tobias Kraze to makandra dev (2011-07-25 23:49)