Wednesday, April 11, 2012

Running selenium tests from visual studio

I was doing some testing using selenium, the way I was running tests at the beginning is through NUnit,  I thought to give it a try to use the visual studio to run the tests instead.

In visual studio 2010, I created a test project, added a new class file to it, named it selenium test

Added the basic test functions and attributes

the class attribute, and changed the class to be public

public class SeleniumTest

Added Initialization and Cleanup methods

public void MyTestInitialize()


public void MyTestCleanup()


Added my test method

public void TheApplyByQIDWebControlTest()


Next I took my initial cs file generated from Selenium IDE, opened it, mapped from NUnit functions to VS test functions, so code in [SetUp] went to [TestInitialize()] , code from [TearDown] went to [TestCleanup()] , code from [Test] went to the [TestMethod()]

I also added reference to selenium .NET dlls, built the project with no errors

Next I opened the Test View, my test method appeared in it, I clicked on run, the test started and I was able to run selenium test from visual studio