Explore Courses Blog Tutorials Interview Questions
0 votes
in DevOps and Agile by (19.7k points)

I'm looking for the recommended/nicest way to make Selenium tests execute in several browsers one after another. The website I'm testing isn't big, so I don't need a parallel solution yet.

I have the usual test set-up methods with  [SetUp], [TearDown], and [Test]. The SetUp one, of course, instantiates a new ISelenium object with whatever browser I want to test with.

So what I want to do is programmatically say: this test will be run on Chrome, IE, and Firefox in sequence. How do I do that?


This might help a bit. We're using CruiseControl.NET to start the NUnit tests after a successful build. Is there any way to pass a parameter to the NUnit executable, and then use that parameter in the test? This way we could have NUnit run several times with different browser parameters.

1 Answer

0 votes
by (62.9k points)

NUnit 2.5+ now supports Generic Test Fixtures which make testing in multiple browsers very straightforward.

Running the following example will execute the GoogleTest twice, once in Firefox and once in IE.

using NUnit.Framework;

using OpenQA.Selenium;

using OpenQA.Selenium.Firefox;

using OpenQA.Selenium.IE;

using System.Threading;

namespace SeleniumTests




   public class TestWithMultipleBrowsers<TWebDriver> where TWebDriver : IWebDriver, new()


       private IWebDriver driver;


       public void CreateDriver () {

           this.driver = new TWebDriver();



       public void GoogleTest() {


           IWebElement query = driver.FindElement(By.Name("q"));

           query.SendKeys("Bread" + Keys.Enter);


           Assert.AreEqual("bread - Google Search", driver.Title);



If you are interested to learn Selenium on a much deeper level and want to become a professional in the testing domain, check out Intellipaat’s Selenium training

Browse Categories