Skip to content

Commit f056d15

Browse files
committed
PR suggestions
1 parent d274da7 commit f056d15

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

dotnet/src/webdriver/SeleniumManager.cs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,9 @@ public static class SeleniumManager
3636
{
3737
private static readonly ILogger _logger = Log.GetLogger(typeof(SeleniumManager));
3838

39-
private static string? _binaryFullPath;
40-
private static string BinaryFullPath => _binaryFullPath ??= GetBinaryFullPath();
41-
4239
private static readonly JsonSerializerOptions _serializerOptions = new() { PropertyNameCaseInsensitive = true, TypeInfoResolver = SeleniumManagerSerializerContext.Default };
4340

44-
private static string GetBinaryFullPath()
41+
private static readonly Lazy<string> _lazyBinaryFullPath = new(() =>
4542
{
4643
string? binaryFullPath = Environment.GetEnvironmentVariable("SE_MANAGER_PATH");
4744
if (binaryFullPath == null)
@@ -71,7 +68,7 @@ private static string GetBinaryFullPath()
7168
throw new WebDriverException($"Unable to locate or obtain Selenium Manager binary at {binaryFullPath}");
7269
}
7370
return binaryFullPath;
74-
}
71+
});
7572

7673
/// <summary>
7774
/// Determines the location of the browser and driver binaries.
@@ -90,7 +87,7 @@ public static Dictionary<string, string> BinaryPaths(string arguments)
9087
argsBuilder.Append(" --debug");
9188
}
9289

93-
var smCommandResult = RunCommand(BinaryFullPath, argsBuilder.ToString());
90+
var smCommandResult = RunCommand(_lazyBinaryFullPath.Value, argsBuilder.ToString());
9491
Dictionary<string, string> binaryPaths = new()
9592
{
9693
{ "browser_path", smCommandResult.BrowserPath },
@@ -117,7 +114,7 @@ public static Dictionary<string, string> BinaryPaths(string arguments)
117114
private static SeleniumManagerResponse.ResultResponse RunCommand(string fileName, string arguments)
118115
{
119116
Process process = new Process();
120-
process.StartInfo.FileName = BinaryFullPath;
117+
process.StartInfo.FileName = _lazyBinaryFullPath.Value;
121118
process.StartInfo.Arguments = arguments;
122119
process.StartInfo.UseShellExecute = false;
123120
process.StartInfo.CreateNoWindow = true;

0 commit comments

Comments
 (0)