---
title: Selenium automated browser testing with C# and NUnit.
description: |-
  In this blog post we'll highlight how easy it is to start testing websites with .NET framework 4 or .NET framework 3 and C#.
  NUnit is built for all...
source_url:
  html: https://testingbot.com/blog/2012/01/08/selenium-automated-browser-testing-with-c-and-nunit
  md: https://testingbot.com/blog/2012/01/08/selenium-automated-browser-testing-with-c-and-nunit.md
---

# Automated testing with C sharp and NUnit

By [Jochen D.](https://testingbot.com/about/jochen-d)2012-01-08

 Share on Facebook 

 Share on Twitter 

 Post on Reddit 

 Share link 

In this blog post we'll highlight how easy it is to start testing websites with .NET framework 4 or .NET framework 3 and C#. NUnit is built for all .NET languages and is basically a unit testing framework. It's written in C# and integrates nicely with .NET and its features/syntax.

You can use NUnit with Visual Studio or MonoDevelop. In this example we'll use MonoDevelop simply because it's supported on multiple platforms. If you don't have MonoDevelop yet, you can get it [here](https://monodevelop.com/).

After installing MonoDevelop, create a new C# NUnit Library Project.

We can now start running unit tests with C#. To use Selenium in your unit tests, you'll need to download the official [C# Selenium client](https://www.selenium.dev/downloads/). Once you've unzipped the file, you'll have DLL files (in net40 and net35 folders, we're using .NET 4 so net40 folder). You need to add these DLL files to your NUnit project.

In MonoDevelop click `Project - Edit References`. Browse to your unpacked folder and select all the DLL files, click the add button.

You can now use the Selenium library in your unit test. In its basic form, a unit test looks like:

```csharp
using NUnit.Framework;
using System;
using Selenium;
using System.Web;
using System.Text;
using System.Net;
using OpenQA.Selenium;
using OpenQA.Selenium.Remote;

namespace Test
{
  [TestFixture()]
  public class Test
  {
    private IWebDriver driver;

        [SetUp]
        public void Init()
        {
            DesiredCapabilities capabilities = DesiredCapabilities.InternetExplorer();
            capabilities.SetCapability(CapabilityType.Version, "8");
      capabilities.SetCapability("api_key", "...");
            capabilities.SetCapability("api_secret", "...");

            driver = new RemoteWebDriver(
                new Uri("http://hub.testingbot.com:4444/wd/hub/"), capabilities);
        }

        [Test]
        public void TestCase()
        {
            driver.Navigate().GoToUrl("http://www.google.com");
            StringAssert.Contains("Google", driver.Title);
        }

        [TearDown]
        public void Cleanup()
        {
            driver.Quit();
        }
  }
}
```

The `DesiredCapabilities capabilities = DesiredCapabilities.InternetExplorer();` indicates we want to run our test on an Internet Explorer browser.

The CapabilityType.Version means we want to run it on version 8 of Internet Explorer. Don't forget to set the api\_key and api\_secret values to the key and secret you received from us (available in our member area).

Every testcase we want to build should have a [Test] annotation above its function and indicate to the driver the URL that the browser should open. For example in our TestCase function we send Selenium the command to navigate to the Google website. We then assert (verify/test) that the title of the current page (Google's Homepage) is Google (which it is).

To run this test, click the `Run` menu item and click `Run`. The test will now run on our Grid and should give back results in moments.

Run your Selenium tests in C# for free on our browsers with our [free trial account](https://testingbot.com/users/sign_up). If you should have questions or remarks, please leave a comment.

[← Previous post Selenium 2.16.1, ChromeDriver 18.0.995.0 and C# with NUnit](https://testingbot.com/blog/2012/01/06/selenium-2-16-1-chromedriver-18-0-995-0-and-c-with-nunit) [Next post → Receive SMS alerts when a Selenium test fails](https://testingbot.com/blog/2012/01/11/receive-sms-alerts-when-a-selenium-test-fails)

## Sidebar

### TestingBot Cloud Testing

Run automated, manual and visual tests on remote browsers and devices. Sign up for a free trial.

[Free Trial](https://testingbot.com/users/sign_up)

### Latest articles

[![Announcing AI Test Insights](https://testingbot.com/assets/blog/2026/ai-insights.jpg)](https://testingbot.com/blog/ai-test-insights)

#### Announcing AI Test Insights

Use AI Insights to quickly discover why an automated test...

[Read: Announcing AI Test Insights](https://testingbot.com/blog/ai-test-insights)

[![Selenium vs Playwright 2026](https://testingbot.com/assets/blog/2026/selenium-vs-playwright-2026.jpg)](https://testingbot.com/blog/selenium-vs-playwright)

#### Selenium vs Playwright 2026

Comparing Selenium vs Playwright - which is the best test...

[Read: Selenium vs Playwright 2026](https://testingbot.com/blog/selenium-vs-playwright)

[![Maestro Physical Device Testing](https://testingbot.com/assets/blog/2026/maestro-physical.jpg)](https://testingbot.com/blog/maestro-physical-device-testing)

#### Maestro Physical Device Testing

Maestro testing in parallel on physical Android and iOS d...

[Read: Maestro Physical Device Testing](https://testingbot.com/blog/maestro-physical-device-testing)

## Related Articles

[![Selenium 20th birthday](https://testingbot.com/assets/blog/2024/selenium20.webp)](https://testingbot.com/blog/selenium-20-years "Selenium 20th birthday")

### [Selenium 20th birthday](https://testingbot.com/blog/selenium-20-years)

Celebrate Selenium's 20th birthday. An overview of the years.

[Read article →](https://testingbot.com/blog/selenium-20-years)

[![Announcing AI Test Insights](https://testingbot.com/assets/blog/2026/ai-insights.jpg)](https://testingbot.com/blog/ai-test-insights "Announcing AI Test Insights")

### [Announcing AI Test Insights](https://testingbot.com/blog/ai-test-insights)

Use AI Insights to quickly discover why an automated test failed.

[Read article →](https://testingbot.com/blog/ai-test-insights)

[![Selenium vs Playwright 2026](https://testingbot.com/assets/blog/2026/selenium-vs-playwright-2026.jpg)](https://testingbot.com/blog/selenium-vs-playwright "Selenium vs Playwright 2026")

### [Selenium vs Playwright 2026](https://testingbot.com/blog/selenium-vs-playwright)

Comparing Selenium vs Playwright - which is the best test framework for your usecase?

[Read article →](https://testingbot.com/blog/selenium-vs-playwright)

[![Selenium WebDriver BiDi](https://testingbot.com/assets/blog/2024/bidi.webp)](https://testingbot.com/blog/webdriver-bidi "Selenium WebDriver BiDi")

### [Selenium WebDriver BiDi](https://testingbot.com/blog/webdriver-bidi)

WebDriver BiDi support is now available on TestingBot. Learn how to use this exciting new improvement with your Selenium tests.

[Read article →](https://testingbot.com/blog/webdriver-bidi)

## More by Jochen D.

[![Announcing AI Test Insights](https://testingbot.com/assets/blog/2026/ai-insights.jpg)](https://testingbot.com/blog/ai-test-insights "Announcing AI Test Insights")
### [Announcing AI Test Insights](https://testingbot.com/blog/ai-test-insights)

Use AI Insights to quickly discover why an automated test failed.

[![Maestro Physical Device Testing](https://testingbot.com/assets/blog/2026/maestro-physical.jpg)](https://testingbot.com/blog/maestro-physical-device-testing "Maestro Physical Device Testing")
### [Maestro Physical Device Testing](https://testingbot.com/blog/maestro-physical-device-testing)

Maestro testing in parallel on physical Android and iOS devices.

[![tvOS Physical Device Testing](https://testingbot.com/assets/blog/2025/appletv.jpg)](https://testingbot.com/blog/tvos-automated-testing "tvOS Physical Device Testing")
### [tvOS Physical Device Testing](https://testingbot.com/blog/tvos-automated-testing)

Run automated tvOS tests on physical AppleTV devices.

[See all posts by Jochen D. →](https://testingbot.com/about/jochen-d)

## Ready to start testing?
[Start a free trial](https://testingbot.com/users/sign_up)
