Posted over 10 years ago. Visible to the public.

Hide your Selenium browser window with a VNC server

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

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:

Copy
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

Copy
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:

Copy
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

Copy
vncserver -kill :6

makandra has been working exclusively with Ruby on Rails since 2007. Our laser focus on a single technology has made us a leader in this space.

Owner of this card:

Avatar
Tobias Kraze
Last edit:
over 5 years ago
by Martin Straub
Keywords:
headless
About this deck:
We are makandra and do test-driven, agile Ruby on Rails software development.
License for source code
Posted by Tobias Kraze to makandra dev
This website uses short-lived cookies to improve usability.
Accept or learn more