@@ -97,7 +97,7 @@ public static string DriverPath(DriverOptions options)
9797 argsBuilder . AppendFormat ( CultureInfo . InvariantCulture , " --browser-version {0}" , options . BrowserVersion ) ;
9898 }
9999
100- string browserBinary = BrowserBinary ( options ) ;
100+ string browserBinary = options . BinaryLocation ;
101101 if ( ! string . IsNullOrEmpty ( browserBinary ) )
102102 {
103103 argsBuilder . AppendFormat ( CultureInfo . InvariantCulture , " --browser-path \" {0}\" " , browserBinary ) ;
@@ -112,31 +112,23 @@ public static string DriverPath(DriverOptions options)
112112 }
113113 }
114114
115- return RunCommand ( binaryFullPath , argsBuilder . ToString ( ) ) ;
116- }
117-
115+ Dictionary < string , object > output = RunCommand ( binaryFullPath , argsBuilder . ToString ( ) ) ;
116+ string browserPath = ( string ) output [ "browser_path" ] ;
117+ string driverPath = ( string ) output [ "driver_path" ] ;
118118
119- /// <summary>
120- /// Extracts the browser binary location from the vendor options when present. Only Chrome, Firefox, and Edge.
121- /// </summary>
122- private static string BrowserBinary ( DriverOptions options )
123- {
124- ICapabilities capabilities = options . ToCapabilities ( ) ;
125- string [ ] vendorOptionsCapabilities = { "moz:firefoxOptions" , "goog:chromeOptions" , "ms:edgeOptions" } ;
126- foreach ( string vendorOptionsCapability in vendorOptionsCapabilities )
119+ try
127120 {
128- IDictionary < string , object > vendorOptions = capabilities . GetCapability ( vendorOptionsCapability ) as IDictionary < string , object > ;
129-
130- if ( vendorOptions != null && vendorOptions . TryGetValue ( "binary" , out object browserBinaryPath ) )
131- {
132- return browserBinaryPath as string ;
133- }
121+ options . BinaryLocation = browserPath ;
122+ options . BrowserVersion = null ;
123+ }
124+ catch ( NotImplementedException e )
125+ {
126+ // Cannot set Browser Location for this driver and that is ok
134127 }
135128
136- return null ;
129+ return driverPath ;
137130 }
138131
139-
140132 /// <summary>
141133 /// Executes a process with the given arguments.
142134 /// </summary>
@@ -145,7 +137,7 @@ private static string BrowserBinary(DriverOptions options)
145137 /// <returns>
146138 /// the standard output of the execution.
147139 /// </returns>
148- private static string RunCommand ( string fileName , string arguments )
140+ private static Dictionary < string , object > RunCommand ( string fileName , string arguments )
149141 {
150142 Process process = new Process ( ) ;
151143 process . StartInfo . FileName = binaryFullPath ;
@@ -187,12 +179,11 @@ private static string RunCommand(string fileName, string arguments)
187179 }
188180
189181 string output = outputBuilder . ToString ( ) . Trim ( ) ;
190- string result ;
182+ Dictionary < string , object > result ;
191183 try
192184 {
193185 Dictionary < string , object > deserializedOutput = JsonConvert . DeserializeObject < Dictionary < string , object > > ( output , new ResponseValueJsonConverter ( ) ) ;
194- Dictionary < string , object > deserializedResult = deserializedOutput [ "result" ] as Dictionary < string , object > ;
195- result = deserializedResult [ "message" ] as string ;
186+ result = deserializedOutput [ "result" ] as Dictionary < string , object > ;
196187 }
197188 catch ( Exception ex )
198189 {
0 commit comments