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

    [TestClass()]
public class SeleniumTest


Added Initialization and Cleanup methods



        [TestInitialize()]
public void MyTestInitialize()
{

}

[TestCleanup()]
public void MyTestCleanup()
{

}


Added my test method



        [TestMethod()]
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

2 comments:

  1. Hi Amir, I too want to do the same excercise. Can you please elaborate the process and attach some screenshots for reference. Appreciate your help.

    Thanks,
    Sharath

    ReplyDelete
  2. Hi Sharath
    I have added another post with more details and screen shots, a step by step example
    http://amir-shenodua.blogspot.com/2013/04/running-selenium-tests-from-visual.html

    ReplyDelete