How to work with 2 FireFoxDrivers simultaneously? Does Selenium support multithreading?
I have the below test which opens 2 firefox browsers but both navigations happen only on the first browser instance!
[Test]
public void TestMultithreading()
{
var tasks = new List<Task>
{
new Task(goToBbc),
new Task(goToGoogle)
};
tasks.ForEach(task => task.Start());
Task.WaitAll(tasks.ToArray());
}
private void goToBbc()
{
openBrowserAndGoTo("http://www.bbc.com");
}
private void goToGoogle()
{
openBrowserAndGoTo("http://www.google.com");
}
private void openBrowserAndGoTo(string url)
{
var webDriver = new FirefoxDriver();
webDriver.Manage().Timeouts().ImplicitlyWait(new TimeSpan(0, 1, 0));
webDriver.Navigate().GoToUrl(url);
Thread.Sleep(5000);
webDriver.Quit();
}
Hope the question is clear.
Thanks,
Selenium RC/WebDriver is intended to automate a browser. If you want to run multiple tests in parallel, you should look at running your scripts through Selenium Grid/RemoteDriver.