File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -60,9 +60,40 @@ public static string DriverPath(DriverOptions options)
6060 argsBuilder . AppendFormat ( CultureInfo . InvariantCulture , " --browser-version {0}" , options . BrowserVersion ) ;
6161 }
6262
63+ string browserBinary = BrowserBinary ( options ) ;
64+ if ( ! string . IsNullOrEmpty ( browserBinary ) )
65+ {
66+ argsBuilder . AppendFormat ( CultureInfo . InvariantCulture , " --browser-path \" {0}\" " , browserBinary ) ;
67+ }
68+
69+
6370 return RunCommand ( binaryFile , argsBuilder . ToString ( ) ) ;
6471 }
6572
73+
74+ /// <summary>
75+ /// Extracts the browser binary location from the vendor options when present. Only Chrome, Firefox, and Edge.
76+ /// </summary>
77+ private static string BrowserBinary ( DriverOptions options )
78+ {
79+ ICapabilities capabilities = options . ToCapabilities ( ) ;
80+ string [ ] vendorOptionsCapabilities = { "moz:firefoxOptions" , "goog:chromeOptions" , "ms:edgeOptions" } ;
81+ foreach ( string vendorOptionsCapability in vendorOptionsCapabilities )
82+ {
83+ try
84+ {
85+ Dictionary < string , object > vendorOptions = capabilities . GetCapability ( vendorOptionsCapability ) as Dictionary < string , object > ;
86+ return vendorOptions [ "binary" ] as string ;
87+ }
88+ catch ( Exception )
89+ {
90+ // no-op, it would be ideal to at least log the exception but the C# do not log anything at the moment
91+ }
92+ }
93+
94+ return null ;
95+ }
96+
6697 /// <summary>
6798 /// Gets the location of the correct Selenium Manager binary.
6899 /// </summary>
You can’t perform that action at this time.
0 commit comments