@@ -92,9 +92,12 @@ public static string DriverPath(DriverOptions options)
92
92
93
93
if ( options . Proxy != null )
94
94
{
95
- if ( options . Proxy . SslProxy != null ) {
95
+ if ( options . Proxy . SslProxy != null )
96
+ {
96
97
argsBuilder . AppendFormat ( CultureInfo . InvariantCulture , " --proxy \" {0}\" " , options . Proxy . SslProxy ) ;
97
- } else if ( options . Proxy . HttpProxy != null ) {
98
+ }
99
+ else if ( options . Proxy . HttpProxy != null )
100
+ {
98
101
argsBuilder . AppendFormat ( CultureInfo . InvariantCulture , " --proxy \" {0}\" " , options . Proxy . HttpProxy ) ;
99
102
}
100
103
}
@@ -137,24 +140,46 @@ private static Dictionary<string, object> RunCommand(string fileName, string arg
137
140
process . StartInfo . RedirectStandardError = true ;
138
141
139
142
StringBuilder outputBuilder = new StringBuilder ( ) ;
143
+ StringBuilder errorOutputBuilder = new StringBuilder ( ) ;
140
144
141
145
DataReceivedEventHandler outputHandler = ( sender , e ) => outputBuilder . AppendLine ( e . Data ) ;
146
+ DataReceivedEventHandler errorOutputHandler = ( sender , e ) => errorOutputBuilder . AppendLine ( e . Data ) ;
142
147
143
148
try
144
149
{
145
150
process . OutputDataReceived += outputHandler ;
151
+ process . ErrorDataReceived += errorOutputHandler ;
146
152
147
153
process . Start ( ) ;
148
154
149
155
process . BeginOutputReadLine ( ) ;
156
+ process . BeginErrorReadLine ( ) ;
150
157
151
158
process . WaitForExit ( ) ;
152
159
153
160
if ( process . ExitCode != 0 )
154
161
{
155
162
// We do not log any warnings coming from Selenium Manager like the other bindings as we don't have any logging in the .NET bindings
156
163
157
- throw new WebDriverException ( $ "Selenium Manager process exited abnormally with { process . ExitCode } code: { fileName } { arguments } \n { outputBuilder } ") ;
164
+ var exceptionMessageBuilder = new StringBuilder ( $ "Selenium Manager process exited abnormally with { process . ExitCode } code: { fileName } { arguments } ") ;
165
+
166
+ if ( ! string . IsNullOrEmpty ( errorOutputBuilder . ToString ( ) ) )
167
+ {
168
+ exceptionMessageBuilder . AppendLine ( ) ;
169
+ exceptionMessageBuilder . Append ( "Error Output >>" ) ;
170
+ exceptionMessageBuilder . AppendLine ( ) ;
171
+ exceptionMessageBuilder . Append ( errorOutputBuilder ) ;
172
+ }
173
+
174
+ if ( ! string . IsNullOrEmpty ( outputBuilder . ToString ( ) ) )
175
+ {
176
+ exceptionMessageBuilder . AppendLine ( ) ;
177
+ exceptionMessageBuilder . Append ( "Standard Output >>" ) ;
178
+ exceptionMessageBuilder . AppendLine ( ) ;
179
+ exceptionMessageBuilder . Append ( outputBuilder ) ;
180
+ }
181
+
182
+ throw new WebDriverException ( exceptionMessageBuilder . ToString ( ) ) ;
158
183
}
159
184
}
160
185
catch ( Exception ex )
@@ -164,6 +189,7 @@ private static Dictionary<string, object> RunCommand(string fileName, string arg
164
189
finally
165
190
{
166
191
process . OutputDataReceived -= outputHandler ;
192
+ process . ErrorDataReceived -= errorOutputHandler ;
167
193
}
168
194
169
195
string output = outputBuilder . ToString ( ) . Trim ( ) ;
0 commit comments