Looks like a C # question, not Selenium.
My logic would be that you get all the PID processes of a process called firefox
using the Process.GetProcessesByName Method , then start your FirefoxDriver
, then load the PID processes again, compare them to only start the PID. In this case, it does not matter how many processes were started by a particular driver (for example, Chrome starts several, only Firefox).
using System.Collections.Generic; using System.Diagnostics; using System.Linq; using Microsoft.VisualStudio.TestTools.UnitTesting; using OpenQA.Selenium.Firefox; namespace TestProcess { [TestClass] public class UnitTest1 { [TestMethod] public void TestMethod1() { IEnumerable<int> pidsBefore = Process.GetProcessesByName("firefox").Select(p => p.Id); FirefoxDriver driver = new FirefoxDriver(); IEnumerable<int> pidsAfter = Process.GetProcessesByName("firefox").Select(p => p.Id); IEnumerable<int> newFirefoxPids = pidsAfter.Except(pidsBefore);
source share