File tree Expand file tree Collapse file tree 1 file changed +31
-0
lines changed Expand file tree Collapse file tree 1 file changed +31
-0
lines changed Original file line number Diff line number Diff line change @@ -60,9 +60,40 @@ public static string DriverPath(DriverOptions options)
60
60
argsBuilder . AppendFormat ( CultureInfo . InvariantCulture , " --browser-version {0}" , options . BrowserVersion ) ;
61
61
}
62
62
63
+ string browserBinary = BrowserBinary ( options ) ;
64
+ if ( ! string . IsNullOrEmpty ( browserBinary ) )
65
+ {
66
+ argsBuilder . AppendFormat ( CultureInfo . InvariantCulture , " --browser-path \" {0}\" " , browserBinary ) ;
67
+ }
68
+
69
+
63
70
return RunCommand ( binaryFile , argsBuilder . ToString ( ) ) ;
64
71
}
65
72
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
+
66
97
/// <summary>
67
98
/// Gets the location of the correct Selenium Manager binary.
68
99
/// </summary>
You can’t perform that action at this time.
0 commit comments