Saturday, October 31, 2009

Web user interface testing? Selenium!

Working on a web based user interface? New or existing? Need automated testing? No problem: Use Selenium. Yes, it's Java-based but that's no reason for not using it. It also works for web development based on .NET. Selenium is nothing new for most .NET base developers. Still it might be worthwhile to have a brief look at how to integrate it with your solution. So here are the basic steps to make it work. First, of course, you need to download Selenium from here. The version that you most likely want to use is Selenium RC. Once downloaded, installation is very simple:
  1. Create a folder for Selenium. I typically use c:\bin\selenium (I hate typing double quotes and stuff for command lines if folder names contain spaces)
  2. From the archive extract 'Selenium-Server-...' and 'Selenium-dotnet-client-driver-...' into the folder you create in step 1.
  3. Open a command prompt in the 'Selenium-Server-...' folder.
  4. Execute the command 'java -jar selenium-server.jar'
That's it. Your selenium server is now running and waiting for your tests to be executed. Next you'll need to write some tests using your favorite unit testing tool, e.g. csUnit. You'll need to add Selenium's client driver assemblies to your test project. The one you'll need is called 'ThoughtWorks.Selenium.Core.dll' which you can find in the 'Selenium-dotnet-client-driver-...' folder you created earlier. Once adding the required reference writing the test is pretty simple. You can find some examples to start with here.

0 comments:

Post a Comment

All comments, questions and other feedback is much appreciated. Thank you!