-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathWebDriverUtilities.cs
37 lines (22 loc) · 1.15 KB
/
WebDriverUtilities.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
using System.Diagnostics;
using System.IO;
namespace Gsemac.Net.WebDrivers {
public static class WebDriverUtilities {
public const string ChromeDriverExecutablePath = "chromedriver.exe";
public const string EdgeDriverExecutablePath = "msedgedriver.exe";
public const string GeckoDriverExecutablePath = "geckodriver.exe";
public static void KillWebDriverProcesses(string webDriverExecutablePath) {
if (string.IsNullOrWhiteSpace(webDriverExecutablePath))
return;
webDriverExecutablePath = Path.GetFullPath(webDriverExecutablePath);
string webDriverProcessName = Path.GetFileNameWithoutExtension(webDriverExecutablePath);
if (string.IsNullOrWhiteSpace(webDriverProcessName))
return;
foreach (Process process in Process.GetProcessesByName(webDriverProcessName)) {
string processExecutablePath = process.MainModule.FileName;
if (!string.IsNullOrWhiteSpace(processExecutablePath) && processExecutablePath.Equals(webDriverExecutablePath))
process.Kill();
}
}
}
}