-
Notifications
You must be signed in to change notification settings - Fork 84
Expand file tree
/
Copy pathBaseChromeConfig.cs
More file actions
67 lines (58 loc) · 2.03 KB
/
Copy pathBaseChromeConfig.cs
File metadata and controls
67 lines (58 loc) · 2.03 KB
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
using System;
using System.Runtime.InteropServices;
using WebDriverManager.Helpers;
using Architecture = WebDriverManager.Helpers.Architecture;
namespace WebDriverManager.DriverConfigs.Impl
{
public abstract class BaseChromeConfig : IDriverConfig
{
public abstract string GetLatestVersion();
public abstract string GetMatchingBrowserVersion();
protected abstract string GetUrl(Architecture architecture);
public virtual string GetName()
{
return "Chrome";
}
public virtual string GetUrl32()
{
return GetUrl(Architecture.X32);
}
public virtual string GetUrl64()
{
return GetUrl(Architecture.X64);
}
public virtual string GetBinaryName()
{
var isWindows = true;
#if NETSTANDARD
isWindows = RuntimeInformation.IsOSPlatform(OSPlatform.Windows);
#endif
var suffix = isWindows ? ".exe" : string.Empty;
return $"chromedriver{suffix}";
}
protected string GetRawBrowserVersion()
{
#if NETSTANDARD
if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
{
return RegistryHelper.GetInstalledBrowserVersionOsx("Google Chrome", "--version");
}
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
{
return RegistryHelper.GetInstalledBrowserVersionLinux(
"google-chrome", "--product-version",
"chromium", "--version",
"chromium-browser", "--version",
"chrome", "--product-version");
}
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
return RegistryHelper.GetInstalledBrowserVersionWin("chrome.exe");
}
throw new PlatformNotSupportedException("Your operating system is not supported");
#else
return RegistryHelper.GetInstalledBrowserVersionWin("chrome.exe");
#endif
}
}
}