How to Configure Selenium RC for Use In C# NUnit Tests

When I set about integrating Selenium into my test suites, I found all the information I needed to do that with but had to hunt and peck through my google searches to find it.  So, as a point of reference, I figured I’d put what I needed to do all in one place:

Two main activities:

  1. Set up Selenium RC server in Windows
    • Download latest Java SE from and install
    • Create a folder named Selenium under your jdk or jre bin file (example: C:Program FilesJavajre1.6.0_05bin).
    • Download latest version of Selenium RC from and extract into your newly created folder
    • From the Command prompt run the following commands:
      • cd [your jdk/jre bin directory] (example: C:Program FilesJavajre1.6.0_05bin).
      • java -jar .Seleniumselenium-server.jar -interactive
      • If you see the following messages your Selenium server is alive and kickin’:
        Entering interactive mode… type Selenium commands here (e.g: cmd=open&1=http:/
  2. Place a reference to the ThoughtWorks.Selenium.Core.dll into your .NET test assembly
    • This

      can be found under the Selenium install directory (example: C:Program


Git ‘Er Done With Some Tests

Now, you’re up and ready to start writing NUnit tests using Selenium in C#.  By the way, you can record your tests using the Selenium IDE and export the tests to a number of languages, including C#:


Example Test Suite as Exported using the above:

using System;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using NUnit.Framework;
using Selenium;

namespace SeleniumTests
    public class NewTest
        private ISelenium selenium;
        private StringBuilder verificationErrors;
        public void SetupTest()
            selenium = new DefaultSelenium(“localhost”, 4444, “*chrome”, “http://sparkystestserver:48/”);
        public void TeardownTest()
            catch (Exception)
                // Ignore errors if unable to close the browser
           Assert.AreEqual(“”, verificationErrors.ToString());

        public void TheNewTest()
            selenium.Type(“loginname, sparky);
            selenium.Type(“password”, “mooseButt);
            Assert.AreEqual(“burp”, selenium.GetValue(“burpField”));

Hope that helps!


[Originally posted on 2/3/2009 at]

Qualities that Undergird Agile/XP Development