@@ -46,24 +46,46 @@ public static class SeleniumManager
46
46
string ? binaryFullPath = Environment . GetEnvironmentVariable ( "SE_MANAGER_PATH" ) ;
47
47
if ( binaryFullPath == null )
48
48
{
49
- var currentDirectory = AppContext . BaseDirectory ;
49
+ SupportedPlatform ? platform = null ;
50
+
51
+ #if NET8_0_OR_GREATER
52
+ if ( OperatingSystem . IsWindows ( ) )
53
+ {
54
+ platform = SupportedPlatform . Windows ;
55
+ }
56
+ else if ( OperatingSystem . IsLinux ( ) || OperatingSystem . IsFreeBSD ( ) )
57
+ {
58
+ platform = SupportedPlatform . Linux ;
59
+ }
60
+ else if ( OperatingSystem . IsMacOS ( ) || OperatingSystem . IsMacCatalyst ( ) )
61
+ {
62
+ platform = SupportedPlatform . MacOS ;
63
+ }
64
+ #else
50
65
if ( RuntimeInformation . IsOSPlatform ( OSPlatform . Windows ) )
51
66
{
52
- binaryFullPath = Path . Combine ( currentDirectory , "selenium-manager" , "windows" , "selenium-manager.exe" ) ;
67
+ platform = SupportedPlatform . Windows ;
53
68
}
54
69
else if ( RuntimeInformation . IsOSPlatform ( OSPlatform . Linux ) )
55
70
{
56
- binaryFullPath = Path . Combine ( currentDirectory , "selenium-manager" , "linux" , "selenium-manager" ) ;
71
+ platform = SupportedPlatform . Linux ;
57
72
}
58
73
else if ( RuntimeInformation . IsOSPlatform ( OSPlatform . OSX ) )
59
74
{
60
- binaryFullPath = Path . Combine ( currentDirectory , "selenium-manager" , "macos" , "selenium-manager" ) ;
75
+ platform = SupportedPlatform . MacOS ;
61
76
}
62
- else
77
+ #endif
78
+
79
+ var currentDirectory = AppContext . BaseDirectory ;
80
+
81
+ binaryFullPath = platform switch
63
82
{
64
- throw new PlatformNotSupportedException (
65
- $ "Selenium Manager doesn't support your runtime platform: { RuntimeInformation . OSDescription } ") ;
66
- }
83
+ SupportedPlatform . Windows => Path . Combine ( currentDirectory , "selenium-manager" , "windows" , "selenium-manager.exe" ) ,
84
+ SupportedPlatform . Linux => Path . Combine ( currentDirectory , "selenium-manager" , "linux" , "selenium-manager" ) ,
85
+ SupportedPlatform . MacOS => Path . Combine ( currentDirectory , "selenium-manager" , "macos" , "selenium-manager" ) ,
86
+ _ => throw new PlatformNotSupportedException (
87
+ $ "Selenium Manager doesn't support your runtime platform: { RuntimeInformation . OSDescription } ") ,
88
+ } ;
67
89
}
68
90
69
91
if ( ! File . Exists ( binaryFullPath ) )
@@ -225,4 +247,11 @@ string BrowserPath
225
247
[ JsonSerializable ( typeof ( SeleniumManagerResponse ) ) ]
226
248
[ JsonSourceGenerationOptions ( PropertyNameCaseInsensitive = true ) ]
227
249
internal sealed partial class SeleniumManagerSerializerContext : JsonSerializerContext ;
250
+
251
+ internal enum SupportedPlatform
252
+ {
253
+ Windows ,
254
+ Linux ,
255
+ MacOS
256
+ }
228
257
}
0 commit comments