The*_*ght 5 testing selenium multithreading webdriver
如何同时使用2个FireFoxDrivers?Selenium是否支持多线程?
我有以下测试打开2个firefox浏览器,但两个导航只发生在第一个浏览器实例上!
[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();
}
Run Code Online (Sandbox Code Playgroud)
希望问题很清楚.
谢谢,