Elad Zohar is a Customer Success Manager at BlazeMeter, leading the EMEA and APJ regions. He has 10 years of experience in the fields of development, project management and DevOps. Elad holds a B.Sc in computer science.

Become a JMeter and Continuous Testing Pro

Start Learning

Test Your Website Performance NOW!

arrow Please enter a URL with http(s)
Sep 13 2017

How to Run C# Selenium Tests with NUnit and Taurus

Are you a .NET developer who wants to utilize Open Source tools for continuous testing? No problem! Now, Taurus, an automation-friendly open source framework for Continuous Testing, can run NUnit C# scripts. Selenium C# users can now utilize the advantages of continuous testing and continuous integration.


This is possible now that Taurus 1.9.5 supports NUnit, through a dedicated executor. With NUnit (a unit-testing framework for all .Net languages) and Mono (an open source implementation of Microsoft's .NET Framework), orchestrated by Taurus, you can now easily build and execute C# Selenium scripts. Nuget and XBuild (Mono) compile the script into binaries, and then these binaries are run by Taurus through Mono. This whole process can be run through one YAML file! Then, you can integrate the test with Jenkins or another CI tool.


This blog post will show how to run a C# script through Taurus. The complete example is available at the Taurus GitHub Repository.


Here is the complete YAML file:


- module: shellexec
  - nuget restore SeleniumSuite/packages.config -SolutionDirectory .
  - xbuild /p:Configuration=Release SeleniumSuite.sln
- executor: selenium
  iterations: 10
	script: SeleniumSuite/bin/Release/SeleniumSuite.dll  # assembly containing test suites  


The first part tells Taurus to run external tools. This is done through the ShellExec module, which prepares Nuget and XBuild to compile the C# script. You can use this script part as is, if you download the example we provided from GitHub. Please note that using this Taurus ability requires Mono 4 and Nuget to be installed, and of course Taurus.


The second part tells Taurus to execute the binaries created in the first step by Mono and Nuget, for 10 times, from the path SeleniumSuite/bin/Release/SeleniumSuite.dll


When running C# scripts, set the executor as Selenium. When doing so, the Selenium executor automatically detects the test types and runs them by using one of the test runners JUnit, NUnit, TestNG, Mocha, etc. You can configure the number of iterations according to your needs.


Now let’s take a look at the source code of our script. The C# script has four simple steps:

  1. Initialize – Creates a new ChromeDriver object.
  2. IndexPage – Browse to blazedemo.com and Assert page title
  3. ReservePage – Browse to reservation page and Assert page title
  4. AfterTest – Tear down ChromeDriver


using System;
using NUnit.Framework;
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;
using OpenQA.Selenium.Firefox;

namespace SeleniumSuite
    public class Test
		IWebDriver driver = null;

		public void Initialize()
			driver = new ChromeDriver();

		public void IndexPage()
			Assert.AreEqual(driver.Title, "BlazeDemo");

		public void ReservePage()
			Assert.AreEqual(driver.Title, "BlazeDemo - reserve");

		public void AfterTest()
			if (this.driver != null)


Change the C# script according to your needs. Make sure you save it in the Selenium Suite folder (in this example).


That’s it! You can now run your tests with Taurus. Once your tests are run through Taurus, they can be automated and integrated with Jenkins or any other CI tool, like Bamboo or TeamCity. Then they can be run with all of your other tests, including load tests, enabling you to shift left while developing.


Learn more Taurus from this free webinar “Using Taurus to Automate JMeter and Selenium Tests“.

arrow Please enter a URL with http(s)

Interested in writing for our Blog?Send us a pitch!