public static void QuitBrowser() { switch (browser) { case "Chrome": { Process[] chromeDriverProcesses = Process.GetProcessesByName("chromedriver"); Process[] chromeInstances = Process.GetProcessesByName("chrome"); foreach (var chromeDriverProcess in chromeDriverProcesses) { chromeDriverProcess.Kill(); } foreach (Process p in chromeInstances) { p.Kill(); } } break; case "IE": { Process[] internetExplorerProcesses = Process.GetProcessesByName("InternetExplorerDriver"); Process[] IEInstances = Process.GetProcessesByName("iexplorer"); foreach (var internetExplorerProcess in internetExplorerProcesses) { internetExplorerProcess.Kill(); } foreach (Process p in IEInstances) { p.Kill(); } } break; case "Firefox": { Process[] FirefoxProcesses = Process.GetProcessesByName("FirefoxDriver"); Process[] FirefoxInstances = Process.GetProcessesByName("firefox"); foreach (var FirefoxProcess in FirefoxProcesses) { FirefoxProcess.Kill(); } foreach (Process p in FirefoxInstances) { p.Kill(); } } break; } }
public static void Close() { webDriver.Quit(); switch (browser) { case "Chrome": { Process[] chromeDriverProcesses = Process.GetProcessesByName("chromedriver"); foreach (var chromeDriverProcess in chromeDriverProcesses) { chromeDriverProcess.Kill(); } } break; case "IE": { Process[] internetExplorerProcesses = Process.GetProcessesByName("InternetExplorerDriver"); foreach (var internetExplorerProcess in internetExplorerProcesses) { internetExplorerProcess.Kill(); } } break; case "Firefox": { Process[] FirefoxProcesses = Process.GetProcessesByName("FirefoxDriver"); foreach (var FirefoxProcess in FirefoxProcesses) { FirefoxProcess.Kill(); } } break; } }