I have a need to launch multiple browser instances / tabs in succession but using Process.Start(url) I am finding that not every URL is launched.
for (int i = 0; i < n; i++)
{
var p = Process.Start("http://localhost/#" + i.ToString());
}
For any value n > 1 I find that only the last URL is opened in the browser (I’m testing with IE as the default browser). If I add a Thread.Sleep(1000) after Process.Start then I see a variety of behavior: sometimes all n are created; sometimes a subset.
The following does work as expected, but assumes IE (would rather use the default browser) and launches n browser instances rather than n tabs:
for (int i = 0; i < n; i++)
{
var p = Process.Start("iexplore.exe", "http://localhost/#" + i.ToString());
}
I would prefer to get it working with the default browser behavior, but need it to be deterministic.
Ended up with the following, still not ideal (launches multiple browser windows), incorporating the command-line arg parsing solution Split string containing command-line parameters into string[] in C#
}