You can try the following code, Before opening the browser first we get the currently running browser processes(ex Chrome) and iterate through each process and compare the MainWindowTitle
.This property holds the title of the opened browser window. If the target URL (with title) is already running then the rest of the code is ignored.
private void OpenBrowser()
{
bool processStarted = false;
Process[] processes = Process.GetProcesses();
foreach (var item in processes)
{
if (item.MainWindowTitle.Equals("Google - Google Chrome", StringComparison.OrdinalIgnoreCase))
{
processStarted = true;
break;
}
}
if (!processStarted)
{
Process p = new Process();
ProcessStartInfo info = new ProcessStartInfo();
info.FileName = "chrome.exe";
p.StartInfo = info;
info.Arguments = "https://www.google.lk";
p.Start();
}
}