I would like to run my tests on multiple browsers but NOT in parallel. I want to provide a pop up to the user to choose which browser (IE, Chrome, Firefox) to execute all tests on when first started.

If I run the BrowserChoice as its own class in a different project, the code works. If I try to initialize it before a test in the same project with the selenium tests, it never executes and fails.


public static void BrowserChoice()
   int userInput;
   Console.Write("Which browser would you like to run tests with?\n");
   Console.Write("Press A for FireFox\n");
   Console.Write("Press B for ChromeDriver\n");
   Console.Write("Press C for Internet Explorer\n\n\n");
   userInput = Console.Read();

   if (userInput == 'A')
      Console.WriteLine("Firefox will execute the tests!\n");
      IWebDriver webDriver = new FirefoxDriver();
   else if (userInput == 'B')
      Console.WriteLine("Chrome will execute the tests!\n");
      IWebDriver webDriver = new ChromeDriver();
   else if (userInput == 'C')
      Console.WriteLine("Internet Explorer will execute the tests!\n");
      IWebDriver webDriver = new InternetExplorerDriver();
      Console.Write("User did not enter a valid input!");

Test Initialize Code:

public void Setup()
  • Do you have two separate projects? It looks to me like you do. A class library and a console application? – Brian Feb 21 at 15:16
  • Is it just that the IWebDriver object being instantiated is only within the scope of the if statement? Given it's a static method do you just need a static IWebDriver variable that gets returned to the caller? In my project I just added a Settings.Settings file that contains an option for which browser so I select it there before running the tests in each browser. – MWS Feb 26 at 4:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.