Skip to main content

Dec 19, 2008 - 3 minute read - Selenium

How to run Selenium-RC in a virtual machine

A tale of VMWare vs VirtualPC

One issue that I have with selenium and running tests through IE is the little popup dialog saying “The web page you are viewing is trying to close the window. do you want to close this window?”

Our tests use openWindow and then close them frequently.

I wrote a little AutoIt script to sit in the background and poll for that dialog and close it when it appears.

But sometimes the AutoIt script makes it difficult for me to use the PC at the same time as the scripts run, so I decided to use VirtualPC to run the Selenium-RC server. And that would surely solve my problems? But oh no, then my problems really began…

The once commercial (and I bought it) VirtualPC now has free status - download it and use it for Free.

So I used it to:

  • Create a new Windows machine.
  • Install the browsers,
  • Install Java,
  • Installed selenium,
  • Copy across my AutoIt script,
  • Got the IP address of the VirtualPC using “ipconfig -all” .

I then amended my test setup on my host machine to use the IP address of the VirtualPC as an argument in the DefaultSelenium constructor.

And finally started selenium-RC from a command prompt in VirtualPC (I tend to open a command window with the Microsoft Power ToyOpen Command Window Here”)

java -jar selenium-server.jar

As ever I title the command window so I can find the server easily in the TaskBar.

Start up my test and voila… Hmm…. Selenium test won’t connect to the server on the Virtual PC.

Issue with Selenium? Issue with VirtualPC setup? I’ll check… ping the virtual PC… no response.

Oh, OK - I’ll switch off the Firewall and enable pings from the advanced settings.

Still no response.

Hmmm… I can connect to the internet from the virtualPC. I can ping my host PC from the virtual PC. I don’t know why this won’t work.

Time to check with Google - and I see other people have experienced the same problem but none of the proffered solutions worked for me - time to get radical.

So I used the VMWare converter to turn the VirtualPC image into a VMWare image for the free VMWare player.

VMWare worked out of the box. I suspect that this happened because VMWare installs a ‘virtual ethernet card’ in your machine but I had to use Shared Network Connection in VirtualPC. So obviously not everyone will experience this problem.

Virtual PC has a lot going for it:

  • free,
  • you can create your own machine images,
  • Microsoft give away some Compatibility images for compatibility testing.

Sadly for this one thing, on this one environment, it failed to meet my needs.

So if you want to run Selenium-RC Server in a virtual machine you have multiple options, VMWare player and VirtualPC as the most obvious. I didn’t need to go as far as using VirtualBox, but if I ever need a free solution for Mac I will try that.

Engage voice-over: “But whatever you choose to use kids. Never forget… Testing and Virtualization - It’s good.”

Related Links:

You will need a Github account to comment. Or you can contact me with your comment.

I reserve the right to delete spam comments e.g. if your comment adds no value and its purpose is simply to create a backlink to another site offering training, or courses, etc.