@@ -35,7 +35,7 @@ namespace OpenQA.Selenium
3535 public class DriverFinder
3636 {
3737 private readonly DriverOptions options ;
38- private Dictionary < string , string > ? paths ;
38+ private Dictionary < string , string > paths = new Dictionary < string , string > ( ) ;
3939
4040 /// <summary>
4141 /// Initializes a new instance of the <see cref="DriverFinder"/> class.
@@ -104,7 +104,7 @@ public bool TryGetBrowserPath([NotNullWhen(true)] out string? browserPath)
104104 /// <exception cref="NoSuchDriverException">If one of the paths does not exist.</exception>
105105 private Dictionary < string , string > BinaryPaths ( )
106106 {
107- if ( paths is not null && ! string . IsNullOrWhiteSpace ( paths [ SeleniumManager . DriverPathKey ] ) )
107+ if ( paths . ContainsKey ( SeleniumManager . DriverPathKey ) && ! string . IsNullOrWhiteSpace ( paths [ SeleniumManager . DriverPathKey ] ) )
108108 {
109109 return paths ;
110110 }
@@ -115,18 +115,23 @@ private Dictionary<string, string> BinaryPaths()
115115
116116 if ( File . Exists ( driverPath ) )
117117 {
118+ paths . Add ( SeleniumManager . DriverPathKey , driverPath ) ;
118119 }
119120 else
120121 {
121122 throw new NoSuchDriverException ( $ "The driver path is not a valid file: { driverPath } ") ;
122123 }
123124
124- if ( ! File . Exists ( browserPath ) )
125+ if ( File . Exists ( browserPath ) )
126+ {
127+ paths . Add ( SeleniumManager . BrowserPathKey , browserPath ) ;
128+ }
129+ else
125130 {
126131 throw new NoSuchDriverException ( $ "The browser path is not a valid file: { browserPath } ") ;
127132 }
128133
129- return paths = binaryPaths ;
134+ return paths ;
130135 }
131136
132137 /// <summary>
0 commit comments