Automated Web Application Testing using Selenium and NUnit

A recent post on stackoverflow raised the question which tools to use for automated tests of web applications.

This question has been an interesting issue for me, as the largest web application I develop and maintain has over the years grown to some 300 aspx files.

Required software to implement tests using Selenium and NUnit:

Selenium Remote Control consists of an HTTP server component requiring Java (1.5 or higher) and a .Net client library. Method calls to the library issue commands to the Selenium server, which in turn sends these commands to the browser.

First, install Selenium IDE plugin for Firefox. You can use the IDE to record your actions in the browser, and replay these recorded actions. It also generates scripts of the recorded actions (called Test Cases) in HTML, C#, and other programming languages.

After installing Selenium Remote Control, the Selenium HTTP server can be started using the command line

c:\path\to\java.exe -jar c:\path\to\selenium-server.jar

Selenium server listens on port 4444 by default.

Install NUnit and create a Visual Studio project which references the nunit.framework.dll and Thoughtworks.Selenium.Core.dll libraries. Your project is now ready to compile the test cases generated by Selenium IDE.

(I recommend changing the browser string in the DefaultSelenium constructor to “*iexplore” for first experiments)

Run the NUnit GUI application and open the newly created assembly. The left-hand tree shows assemblies, namespaces, and test case names.

After starting the Selenium server, select a node and press Run. This will open a browser window which executes the commands defined in the test case. After completion, the browser will be closed again. (If you don’t see a browser window, use task manager to watch the list of processes)

4 Responses to Automated Web Application Testing using Selenium and NUnit

  1. […] Steps with Selenium and NUnit After installing Selenium and NUnit, I started my first experiments with the testing framework. Starting from the results of the […]

  2. theanh571 says:

    hi all, please help me now.
    I am considering to write a dynamic script how to get data from the sql database in login page. I am using .net 2005 and nunit with selenium script. Please please.

  3. theanh571,
    I described how to test web applications using selenium and nunit here:

    By the way it is possible to run Selenium right in Visual Studio:

  4. pooja says:

    I need help in learning selenium ide to test web based application

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: