I want to run multiple windows of Chrome browser parallely. This works fine for 2 or sometimes 3 windows, but when I run 4 or more windows, browsers are opened but only one of them is running while others are just left blank.
Here is my code
IWebDriver[] driver = new IWebDriver[forms.Length];
initDriver(); // custom method to initialize driver array using ChromeDriver
...
List<Action> actions = new List<Action>();
int i = 0;
foreach (string form in forms)
{
actions.Add(() => OpenWebsiteAndTest(form, i));
i++;
}
using (var collection = new BlockingCollection<int>())
{
Parallel.Invoke(actions.ToArray());
}
private void OpenWebsiteAndTest(string formName, int index)
{
// below website is only opened in one of the browsers
driver[index].Navigate().GoToUrl("https://www.myurl.com");
...
doTests(formName); // custom method to automate the website and perform some tests
}
The problem is, OpenWebsiteAndTest
method is executed for only one of the browser instances and the code inside it is never executed for other windows
I think I'm either doing something wrong, or either doing it in a bad way. I want my application to open up to 9 windows and execute them simultaneously as per client's need.