From Firefox, record new selenium test, for example for Google search
Export the test to C# web drive
This is how it looks like after export
Open visual studio, create new test project
By default the file UnitTest1.cs is created
Create a new cs file, name it for example GoogleSearch
Copy the code from the cs file generated by selenium and paste it in the file GoogleSearch.cs
Add reference in the project to Selenium .Net WebDriver, WebDriver.dll and WebDriver.Support.dl
Now the references added, you can see that the editor recognizes the selenium name spaces
using OpenQA.Selenium;
using OpenQA.Selenium.Firefox;
using OpenQA.Selenium.Support.UI;
Find and replace “TestFixture” to “TestClass”, “SetUp” to “TestInitialize()”, “Test” to “TestMethod”, “TearDown” to “TestCleanup()”
To run with Chrome, download chromedriver.exe from https://code.google.com/p/chromedriver/downloads/list, place it in the bin folder
Change the driver in the code to Chrome then run the test
driver = new OpenQA.Selenium.Chrome.ChromeDriver();
Running the test, chrome will open, and Google search page will be displayed, displaying search results then closed
This was a step by step example on running selenium test from visual studio