I'm using following code to iterate over a list of browsers executable paths and start each of them:
foreach (var browser in browsers)
{
var proc = new Process();
proc.StartInfo.FileName = browser.ExecutablePath;
proc.StartInfo.Arguments = "http://google.com";
proc.Start();
proc.WaitForExit();
Console.WriteLine(proc.ExitCode.ToString());
proc.Close();
}
What is should do is: it should open browser window with google.com loaded and stop the application until the window is closed. And it works fine for both IE and Firefox, but fails with Chrome.
For Chrome proc
is in Exit
state just after launching the browser, when the window is still active and visible.
I tried using some of chromium command line switches, including --new-window
and --single-process
but with no success.
Question is, how can I force Google Chrome to run in the process it is started in, so it would be possible to wait until window is closed?
Update
Just to clarify the question:
- I know why it does not work - it's because Chrome uses multiple processes for different things, like different tabs, plug-ins, etc.
- I tried to find the correct process looking on process tree, but found nothing.
- I can't just take the latest process created by chrome, because it may be the process created for a pluging the page requires, not the page itself.