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.
CODE:
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();
}
else
{
Console.Write("User did not enter a valid input!");
Console.ReadLine();
Console.ReadLine();
}
}
Test Initialize Code:
[TestInitialize]
public void Setup()
{
XmlConfigurator.Configure();
Browser.BrowserChoice(driver);
driver.Navigate().GoToUrl(ConfigurationManager.AppSettings.Get("Url"));
driver.Manage().Window.Maximize();
}