Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 11 additions & 9 deletions dotnet/src/webdriver/SeleniumManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,27 +36,28 @@ public static class SeleniumManager
{
private static readonly ILogger _logger = Log.GetLogger(typeof(SeleniumManager));

private static readonly string BinaryFullPath = Environment.GetEnvironmentVariable("SE_MANAGER_PATH");
private static string? _binaryFullPath;
private static string BinaryFullPath => _binaryFullPath ??= GetBinaryFullPath();

private static readonly JsonSerializerOptions _serializerOptions = new() { PropertyNameCaseInsensitive = true, TypeInfoResolver = SeleniumManagerSerializerContext.Default };

static SeleniumManager()
private static string GetBinaryFullPath()
{

if (BinaryFullPath == null)
string? binaryFullPath = Environment.GetEnvironmentVariable("SE_MANAGER_PATH");
if (binaryFullPath == null)
{
var currentDirectory = AppContext.BaseDirectory;
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
BinaryFullPath = Path.Combine(currentDirectory, "selenium-manager", "windows", "selenium-manager.exe");
binaryFullPath = Path.Combine(currentDirectory, "selenium-manager", "windows", "selenium-manager.exe");
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
{
BinaryFullPath = Path.Combine(currentDirectory, "selenium-manager", "linux", "selenium-manager");
binaryFullPath = Path.Combine(currentDirectory, "selenium-manager", "linux", "selenium-manager");
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
{
BinaryFullPath = Path.Combine(currentDirectory, "selenium-manager", "macos", "selenium-manager");
binaryFullPath = Path.Combine(currentDirectory, "selenium-manager", "macos", "selenium-manager");
}
else
{
Expand All @@ -65,10 +66,11 @@ static SeleniumManager()
}
}

if (!File.Exists(BinaryFullPath))
if (!File.Exists(binaryFullPath))
{
throw new WebDriverException($"Unable to locate or obtain Selenium Manager binary at {BinaryFullPath}");
throw new WebDriverException($"Unable to locate or obtain Selenium Manager binary at {binaryFullPath}");
}
return binaryFullPath;
}

/// <summary>
Expand Down