Is it possible to run multiple browser instances in parallel?

I have a program that does some work in the browser. I would like to run several instances of this program. But as soon as the second program starts, the first one loses connection with the browser. the second takes control of the driver.

There are no problems with creating several browser instances inside one program.

  • This is because the port is one. you need different ports for communication - vitidev
  • @vitidev, logically, if port 0 is set, then it should choose a random free port. I even tried to manually search for a free port and set it via firefoxProfile.SetPreference ("webdriver_firefox_port", port); Everything is the same .... - Andrew

1 answer 1

Of course available.

This code launches 3 firefoxes, puts them on a sheet, with which you can work with later.

for (int i = 0; i < 3; i++) { WebDriver driver = new FirefoxDriver(); driver.get("http://ru.stackoverflow.com"); list.add(driver); } //some logic for (WebDriver d: list) { d.quit(); } 
  • And with several instances of the program with this code will start? :) I have no problems running multiple browser instances under the same program, I have problems launching several browser instances under different programs (even though it’s the same one running 2 times). - Andrew
  • Of course, run. Only if you want to work in parallel, then it will be necessary to launch it in the same way - Andrew Bystrov