@@ -60,8 +60,7 @@ public static string DriverPath(string driverName)
60
60
if ( binaryFile == null ) return null ;
61
61
62
62
var arguments = "--driver " + driverName ;
63
- var output = RunCommand ( binaryFile , arguments ) ;
64
- return output . Replace ( "INFO\t " , "" ) . TrimEnd ( ) ;
63
+ return RunCommand ( binaryFile , arguments ) ;
65
64
}
66
65
67
66
/// <summary>
@@ -117,14 +116,15 @@ private static string RunCommand(string fileName, string arguments)
117
116
process . StartInfo . RedirectStandardError = true ;
118
117
119
118
StringBuilder outputBuilder = new StringBuilder ( ) ;
120
-
119
+ int processExitCode ;
120
+
121
121
DataReceivedEventHandler outputHandler = ( sender , e ) => outputBuilder . AppendLine ( e . Data ) ;
122
122
123
123
try
124
124
{
125
125
process . OutputDataReceived += outputHandler ;
126
126
process . ErrorDataReceived += outputHandler ;
127
-
127
+
128
128
process . Start ( ) ;
129
129
130
130
process . BeginOutputReadLine ( ) ;
@@ -138,17 +138,19 @@ private static string RunCommand(string fileName, string arguments)
138
138
}
139
139
finally
140
140
{
141
+ processExitCode = process . ExitCode ;
141
142
process . OutputDataReceived -= outputHandler ;
142
143
process . ErrorDataReceived -= outputHandler ;
143
144
}
144
145
145
- string output = outputBuilder . ToString ( ) ;
146
+ string output = outputBuilder . ToString ( ) . Trim ( ) ;
146
147
147
- if ( ! output . StartsWith ( "INFO" ) ) {
148
+ if ( processExitCode > 0 )
149
+ {
148
150
throw new WebDriverException ( $ "Invalid response from process: { fileName } { arguments } \n { output } ") ;
149
151
}
150
152
151
- return output ;
153
+ return output . Replace ( "INFO \t " , "" ) ;
152
154
}
153
155
}
154
156
}
0 commit comments