File tree Expand file tree Collapse file tree 1 file changed +21
-3
lines changed Expand file tree Collapse file tree 1 file changed +21
-3
lines changed Original file line number Diff line number Diff line change 24
24
using System . Runtime . InteropServices ;
25
25
#endif
26
26
27
+ using System . Text ;
28
+
27
29
namespace OpenQA . Selenium
28
30
{
29
31
/// <summary>
@@ -112,22 +114,38 @@ private static string RunCommand(string fileName, string arguments)
112
114
process . StartInfo . Arguments = arguments ;
113
115
process . StartInfo . UseShellExecute = false ;
114
116
process . StartInfo . RedirectStandardOutput = true ;
117
+ process . StartInfo . RedirectStandardError = true ;
115
118
116
- string output ;
119
+ StringBuilder outputBuilder = new StringBuilder ( ) ;
120
+
121
+ DataReceivedEventHandler outputHandler = ( sender , e ) => outputBuilder . AppendLine ( e . Data ) ;
117
122
118
123
try
119
124
{
125
+ process . OutputDataReceived += outputHandler ;
126
+ process . ErrorDataReceived += outputHandler ;
127
+
120
128
process . Start ( ) ;
121
- output = process . StandardOutput . ReadToEnd ( ) ;
129
+
130
+ process . BeginOutputReadLine ( ) ;
131
+ process . BeginErrorReadLine ( ) ;
132
+
122
133
process . WaitForExit ( ) ;
123
134
}
124
135
catch ( Exception ex )
125
136
{
126
137
throw new WebDriverException ( $ "Error starting process: { fileName } { arguments } ", ex ) ;
127
138
}
139
+ finally
140
+ {
141
+ process . OutputDataReceived -= outputHandler ;
142
+ process . ErrorDataReceived -= outputHandler ;
143
+ }
144
+
145
+ string output = outputBuilder . ToString ( ) ;
128
146
129
147
if ( ! output . StartsWith ( "INFO" ) ) {
130
- throw new WebDriverException ( $ "Invalid response from process: { fileName } { arguments } ") ;
148
+ throw new WebDriverException ( $ "Invalid response from process: { fileName } { arguments } \n { output } ") ;
131
149
}
132
150
133
151
return output ;
You can’t perform that action at this time.
0 commit comments