Unintelligible

Tuesday, July 28, 2009

Installing Selenium-RC as a Windows service

Installing Windows as a service is reasonably straightforward - based on the instructions for Fitnesse, which unfortunately seem to have been deleted from the Fitnesse wiki, but which have been reproduced here.

There are two parts to doing this - the first, registering the service using srvany.exe (which wraps any executable as a service), and the second, adding the keys to the registry to tell srvany.exe how to launch Selenium-RC. srvany.exe is a part of the Windows Resource Kit, if you don’t have it already you will need to download it from Microsoft.

The following will register the Selenium service - on the command line (all in one line):

"C:\Program Files\Windows Resource Kits\Tools\instsrv.exe" SeleniumRC
"C:\Program Files\Windows Resource Kits\Tools\srvany.exe" -a [myuser] -p [mypass]

This is assuming the Windows Resource Kit has been installed to its default location, “C:\Program Files\Windows Resource Kits”. Also, note that the user supplied needs to have the Log On As Service permissions assigned.

Now, add the following keys to the registry - this text can simply be copied-and-pasted to a .reg file, then double-clicked to add the entries to the registry:

Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\SeleniumRC\Parameters]
"Application"="java.exe"
"AppDirectory"="C:\\Program Files\\selenium-server-1.0.1"
"AppParameters"="-Xrs -jar selenium-server.jar"

You should now be able to start the service - if you get an error about the service failing to start due to a logon issue, make sure that the user you are using to run the service has been granted Log On As A Service permission (editing the service logon credentials in the Services MMC snap-in and saving the changes will cause this to happen automatically.)

posted by Nick at 10:08 pm - filed in testing, windows  

4 Comments »

  1. Thanks for this!

    Have you tried starting the SeleniumRC service on a port other than the default (4444)? I’m trying to pass in the parameter -port 8888 without any luck. I tried adding it to the registry key:

    AppParameters”=”-Xrs -jar selenium-server.jar -port 8888″

    But it doesn’t seem to get picked up. (How can I view console output?)

    Neither does it when I add it to the service properties Start parameters. Then the system tells me the service was started and stopped because it may not have had any work to do.

    Comment by Dave Dumaresq — October 20, 2009 @ 5:50 pm

  2. Hi,

    I must admit I haven’t tried starting it on anything other than the default port - but I would have thought it should work.

    The first thing to try would be to start the service from the command line using the arguments you’re setting in the registry; so, in your case:

    cd “C:\\Program Files\\selenium-server-1.0.1″
    java -Xrs -jar selenium-server.jar -port 8888

    If that doesn’t start correctly, it should give you an error message with the cause.

    HTH -

    Comment by Nick — October 20, 2009 @ 6:55 pm

  3. Thanks for this post. It saved me a lot of time.

    Comment by Raj — January 13, 2010 @ 12:12 am

  4. Thanks for the post!

    I ran into the same problem (the parameters) and solved it by using a BAT-file containing the whole command line:

    Windows Registry Editor Version 5.00
    [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\SeleniumRC\Parameters]
    “Application”=”C:\\Path\To\My\BAT\File”

    Comment by Kostia — January 22, 2010 @ 12:08 am

RSS feed for comments on this post. TrackBack URI

Leave a comment