Skip to content

Instantly share code, notes, and snippets.

@mshmsh5000
Created September 6, 2012 20:32
Show Gist options
  • Save mshmsh5000/3660158 to your computer and use it in GitHub Desktop.
Save mshmsh5000/3660158 to your computer and use it in GitHub Desktop.
A headless Selenium testing system is an ideal addition to any development workflow. Selenium reduces testing time, and integrates into CI tools such as Jenkins. The benefits are great, but only *if* you can get your tests to run.
One of the most time consuming problems that can arise from a headless system is a failed test. How can you debug, when you can't see the browser? Ideally, you will test your scripts locally before running them on the headless system, but anyone who has even dabbled in the world of automation knows that a single procedure can yield very different results on different systems and in different environments. You can deal with the differences, but first you have to see them.
After much searching, I could not find a straight answer as to how to export this display to my Windows machine from our Linux server. It is really quite simple, and can be done in a few steps.
In order to display a headless Selenium test on a Windows machine from a Linux server, you must first be able to have an X window (X11[LINK TO WIKIPEDIA ENTRY]) server running on your Windows machine. This is the underlying window display environment common to Unix systems. I used Xming, as it is the easiest to use and involves almost no setup.
You can download Xming here[LINK TO XMING].
When the installer finishes, run the Xming server. This doesn't do anything that you can see, but starts the X11 environment on top of Windows.
Now you need PuTTY, the SSH client. You can download PuTTY here[LINK TO PUTTY].
Now that you have installed PuTTY, run the executable. In the left hand category listing for the settings, click on the X11 tab and enable X11 forwarding.
Type in the host name or IP of the remote machine and connect.
Type "firefox" in the command line of your PuTTY shell (this assumes you have Firefox on your system).
This should pop the Firefox browser!
Now that you can get the remote Firefox instance to show on your Windows machine, you can run Selenium through PuTTY and debug on the fly with the command:
[shell]
java -jar (PATH-TO)/selenium-server.jar -trustAllSSLCertificates - htmlSuite BROWSER URL (PATH-TO)/SUITE (PATH-TO)/LOG
[/shell]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment