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 can use multi−threading in one browser with the help of TestNG framework. TestNG provides the feature of parallel execution which works on the concept of Java multi−threading. To execute tests based on various parameters, the TestNG has an XML file where we have the configurations.
In parallel testing, we test different modules or applications on multiple browsers in parallel rather than one by one. The parallel test execution is different from sequential testing, where we test different modules or functionalities one after the other.
Thread count is basically a number of instances running to execute multiple tests simultaneously or in parallel. The attribute thread-count allows the user to specify how many threads should be run for this execution.
What is Cross Browser Testing in Selenium? Cross browser testing refers to testing a website in multiple browsers like IE, Chrome, Firefox to check its efficacy on each. Cross-browser compatibility is the ability of the website or web application to function across different browsers and operating systems.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With