@@ -123,7 +123,7 @@ public FirefoxDriver()
123123 /// </summary>
124124 /// <param name="options">The <see cref="FirefoxOptions"/> to be used with the Firefox driver.</param>
125125 public FirefoxDriver ( FirefoxOptions options )
126- : this ( CreateService ( options ) , options , RemoteWebDriver . DefaultCommandTimeout )
126+ : this ( FirefoxDriverService . CreateDefaultService ( ) , options , RemoteWebDriver . DefaultCommandTimeout )
127127 {
128128 }
129129
@@ -186,12 +186,29 @@ public FirefoxDriver(FirefoxDriverService service, FirefoxOptions options)
186186 /// <param name="options">The <see cref="FirefoxOptions"/> to be used with the Firefox driver.</param>
187187 /// <param name="commandTimeout">The maximum amount of time to wait for each command.</param>
188188 public FirefoxDriver ( FirefoxDriverService service , FirefoxOptions options , TimeSpan commandTimeout )
189- : base ( new DriverServiceCommandExecutor ( service , commandTimeout ) , ConvertOptionsToCapabilities ( options ) )
189+ : base ( GenerateDriverServiceCommandExecutor ( service , options , commandTimeout ) , ConvertOptionsToCapabilities ( options ) )
190190 {
191191 // Add the custom commands unique to Firefox
192192 this . AddCustomFirefoxCommands ( ) ;
193193 }
194194
195+ /// <summary>
196+ /// Uses DriverFinder to set Service attributes if necessary when creating the command executor
197+ /// </summary>
198+ /// <param name="service"></param>
199+ /// <param name="commandTimeout"></param>
200+ /// <param name="options"></param>
201+ /// <returns></returns>
202+ private static ICommandExecutor GenerateDriverServiceCommandExecutor ( DriverService service , DriverOptions options , TimeSpan commandTimeout )
203+ {
204+ if ( service . DriverServicePath == null ) {
205+ string fullServicePath = DriverFinder . FullPath ( options ) ;
206+ service . DriverServicePath = Path . GetDirectoryName ( fullServicePath ) ;
207+ service . DriverServiceExecutableName = Path . GetFileName ( fullServicePath ) ;
208+ }
209+ return new DriverServiceCommandExecutor ( service , commandTimeout ) ;
210+ }
211+
195212 /// <summary>
196213 /// Gets a read-only dictionary of the custom WebDriver commands defined for FirefoxDriver.
197214 /// The keys of the dictionary are the names assigned to the command; the values are the
@@ -434,11 +451,6 @@ private static ICapabilities ConvertOptionsToCapabilities(FirefoxOptions options
434451 return options . ToCapabilities ( ) ;
435452 }
436453
437- private static FirefoxDriverService CreateService ( FirefoxOptions options )
438- {
439- return FirefoxDriverService . CreateDefaultService ( options ) ;
440- }
441-
442454 private void AddCustomFirefoxCommands ( )
443455 {
444456 foreach ( KeyValuePair < string , CommandInfo > entry in CustomCommandDefinitions )
0 commit comments