LambdaTestAutomation Testing ● NUnit with Selenium: NUnit Testing Framework to Run Tests on Online Selenium Grid

NUnit with Selenium: NUnit Testing Framework to Run Tests on Online Selenium Grid

LambdaTest offers support with Selenium WebDriver to help you instantly execute your automation test scripts. LambdaTest is a cloud-based, cross browser testing tool offering a Selenium grid consisting 2000+ browsers and browser versions running on real operating systems to pace up automation testing of your web-app or website. In this topic, you will learn how to automate your website testing using NUnit Selenium on LambdaTest.

In this topic you will be learning:

  1. How to run a sample Selenium script with NUnit testing framework on LambdaTest Automation.
  2. How to specify which browsers to run the test on.
  3. How to run your test cases in parallel to reduce build times.
  4. How to test your locally hosted pages.

Prerequisites For Running NUnit Selenium Tests

Download and Install Selenium WebDriver from the official website

  • Make sure you work with latest version of C#.
  • .Net framework to deliver guidelines while developing a range of application using C#.
  • Download Selenium WebDriver Language Binding for C# and extract them to appropriate folder.
  • A .NET Core SDK of 2.1 or greater version.
  • You would also need Lambda Tunnel binary file for testing your locally hosted or privately hosted projects.

Getting Started With NUnit Testing Framework and LambdaTest

The first step in using LambdaTest platform is to understand LambdaTest’s Selenium Grid capabilities. Our Selenium Grid uses remote webdriver instead of normal Selenium client browser drivers so if you are migrating from locally run Selenium, you would have to invoke LambdaTest Selenium remote webdriver. Next you need to specify in your code, which browser, browser versions, operating systems, and resolution you wish to run your test on, along with defining LambdaTest specific capabilities. You can checkout LambdaTest Capabilities Generator tool to understand more about how you can define running browser environments and leverage advanced LambdaTest capabilities.

First Test With NUnit Selenium

Let us begin with a simple Selenium Remote Webdriver test first. The C# script with NUnit testing framework below tests a simple to-do application with basic functionalities like mark items as done, add items in list, calculate total pending items etc. You can also find this at our NUnit GitHub repository.

Here is a code based for the same on NUnit testing framework.

You can use the Platform Configuration to specify the desired capabilities for any browser/platform combination you want for your test.

The Selenium Webdriver test would open a URL, mark the first two items in the list as done, add an item in the list, and return the total number of pending item. Your results would be displayed on the test console (or command-line interface if you are using terminal/cmd) and on LambdaTest dashboard. LambdaTest Dashboard will help you view all your text logs, screenshots and video recording for your entire Selenium tests.

Executing The NUnit Selenium Tests

You would need to execute the below command in your terminal/cmd.

Going Into Details: What is NUnit Testing Framework?

NUnit testing framework is an open-source unit testing framework in C# which is derived from JUnit and dedicated for drafting as well as executing unit tests for all Microsoft.NET programming languages. NUnit is cross platform compatible and works efficiently with custom test runners. Test annotations used in NUnit Selenium not only helps to pace up your test execution but also helps in specifying numerous input in a single test. The major advantage of NUnit is its compatibility with Selenium based automation.

If you are already aware of NUnit testing framework or if you are planning on learning it soon then this topic would be resourceful for you to start performing automation testing with Selenium using NUnit on LambdaTest, a cross browser testing tool that offers a Selenium grid consisting a library of 2000+ browsers to provide you with wider test coverage.

In this topic, you will learn how to integrate LambdaTest Selenium cloud grid with your NUnit Selenium testing suite. We are also going to demonstrate automation testing for your locally hosted web pages using NUnit Selenium, so you are more relieved while migrating your web page live on the internet. We would also demonstrate execution of parallel testing for speeding up your effort on test builds.

Understanding & Configuring NUnit Desired Capabilities

As we said earlier the first step is to configure your test scripts to connect with LambdaTest Selenium automation gird. In the above mentioned C# code for NUnit Selenium, the first thing you would notice is the invoking of remote webdriver instead of the native browser webdrivers. So for example if you are planning to run on Firefox browser in your local machine, you would be using Firefox browser driver like this:

However, to run on LambdaTest Selenium grid, you would have to change it remote webdriver and at the same time pass capabilities related to browser, browser versions etc. In simple terms, it would look something like this:

In the C# code, we are passing browser, browser version, and operating system information, along with LambdaTest Selenium grid capabilities via capabilities object.

Our Capabilities Generator will automatically generate the program, based on your provided input. For Instance, if you select the below configurations:

Operating System
Windows 10
Google Chrome
Browser Version
1920 x 1080
Selenium Version

Then, LambdaTest Capabilities Generator will automatically generate the below program:

The most important capabilities to understand here are ‘browserName’, ‘versions’, and ‘platform’. They define which browser environment you wish to run the test on. Rest of the capabilities are important in test management and debugging. We have a inbuilt capabilities generator tool as well that you use to generate capabilities code for your test suite.

You can also checkout our documentation on Selenium Automation Capabilities to understand more about individual capabilities.

Advanced LambdaTest Capabilities

In addition to default Selenium Grid capabilities, LambdaTest also has platform specific capabilities like video recording of test runs, console logs of each test run, network logs of each test run, custom profiles for specific browsers, etc. Do checkout our documentations on LambdaTest Advanced capabilities as well.

Testing Locally Hosted Projects using NUnit Selenium

With LambdaTest, you can even perform cross browser testing on your locally stored web pages with the help of Lambda Tunnel. Lambda Tunnel establishes an SSH(Secure Shell) connection from your local machine to LambdaTest cloud servers. Test your website on local and identify bugs before your customer do it for you. Lambda Tunnel also allows you to perform cross browser testing of your locally hosted web pages through various IP addresses belonging to different parts of the globe. Lambda Tunnel also helps in testing those web-apps or websites that are only permissible inside your specific corporate firewall. Wish to know more about Lambda Tunnel?

Follow our documentation on Lambda Tunnel to know it all. OS specific instructions to download and setup tunnel binary can be found at the following links.

After downloading, open cmd(Command Prompt) / terminal and route the pointer to the same location where you extract the downloaded binary zip file. Then, type the below command and hit Enter to launch Lambda Tunnel.

For example, If you have the following:

Example Value
Login Email
Access Key

Then, the command would be:

The above command will set up Lambda Tunnel successfully! Now, for performing automation testing using C# with NUnit Selenium you need to add the below to your capabilities.

You may also use LambdaTest Capabilities Generator for providing you with the above capability

Tunnel Reference: For a full reference of all tunnel features we support, visit our tunnel page.

Mark Tests As Pass Or Fail

Based on the motive with which you aim to perform automation testing using C# and NUnit Selenium on LambdaTest’s Selenium grid cloud, you can mark an automation test as either pass or fail. This would depend upon the expected behavior for your test case. You can mark pass or fail using the below code fragment in your automation script:

Parallel Testing using NUnit Testing Framework

Parallel Testing is one of the most demanding features of LambdaTest Selenium Grid. By parallel testing, you can run more than one test case, simultaneously. This means that Parallel testing would allow you to execute numerous automation test cases altogether. So you execute a single test scenario across different browsers or could run different test scenarios across the same browser but with different browser versions. Wondering how many parallel test cases can you run? That depends entirely on the number of concurrent session under your opted plan.

For instance, if you have a bucket of 100 automated test cases, and the average time for execution of a single test is around 6 minutes. The time taken normally to completely execute all your test cases sequentially would be 600 minutes i.e. 10 hours. However, if you are opting for a plan which offers 2 concurrent sessions then you can perform 2 parallel test cases. This would divide your time in half as the total time taken through parallel testing with 2 concurrent sessions for the above scenario would be 300 minutes i.e. 5 hours. Similarly, if you have got 4 concurrent sessions with you then the time taken would be quarter with respect to sequential testing. This way you could fasten your release cycles as much as you want.

NUnit testing framework is really useful in running parallel tests. For instance, in our above example, you may notice that we are running our test on a single environment. If you want to cover multiple environments you would have to change the hard code every time. Or you would have to use arrays, or multi-threading or something similar.

With LambdaTest, you can pace up your test build activities by performing parallel automation testing using C# and NUnit Selenium. Boost quality assurance of your product by performing extensive and fast-paced automated cross browser testing process with LambdaTest parallel testing.

Check out the same code below to understand it better. You can also find it at our GitHub page here.

Parallel Testing Example

Here is the Constants file for parallel tests.

If you notice, with simple annotations and parameters, you can now run your test suite on multiple browsers every time, without changing the browsers parameters in code files every time.


To prevent over-exploitation of the platform we have added a capacity constraint on the number of tests that can be queued at our platform. Your maximum queue capacity will be dependent upon the number of concurrent sessions your LambdaTest account is eligible for. Below formula will help you calculate the maximum capacity for your queue.

Maximum Queueing Capacity

Maximum number of test cases that can be queued = n + 150

Here, n = number of concurrent sessions.

For example, if your LambdaTest account is eligible to avail 10 concurrent sessions. Then, your queue can have a maximum of 10 + 150 i.e. 160 queued test cases. Scheduling & Execution of these queued test cases will be automatically handled by LambdaTest for you

LambdaTest Queuing Policy: We have also added a limitation on the total amount of time a queued item will remain in queue before it gets timed out.

Queuing Timeout

There is also a limit on how long a test case can stay in the queue. If your test case stays in the queue for more than 15 minutes, the test case would be timed out and would not be executed.