Skip to content

Commit 8fb8fd7

Browse files
committed
[dotnet] toggle Selenium Manager execution output on exit code
1 parent d2838e1 commit 8fb8fd7

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

dotnet/src/webdriver/SeleniumManager.cs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,7 @@ public static string DriverPath(string driverName)
6060
if (binaryFile == null) return null;
6161

6262
var arguments = "--driver " + driverName;
63-
var output = RunCommand(binaryFile, arguments);
64-
return output.Replace("INFO\t", "").TrimEnd();
63+
return RunCommand(binaryFile, arguments);
6564
}
6665

6766
/// <summary>
@@ -117,14 +116,15 @@ private static string RunCommand(string fileName, string arguments)
117116
process.StartInfo.RedirectStandardError = true;
118117

119118
StringBuilder outputBuilder = new StringBuilder();
120-
119+
int processExitCode;
120+
121121
DataReceivedEventHandler outputHandler = (sender, e) => outputBuilder.AppendLine(e.Data);
122122

123123
try
124124
{
125125
process.OutputDataReceived += outputHandler;
126126
process.ErrorDataReceived += outputHandler;
127-
127+
128128
process.Start();
129129

130130
process.BeginOutputReadLine();
@@ -138,17 +138,19 @@ private static string RunCommand(string fileName, string arguments)
138138
}
139139
finally
140140
{
141+
processExitCode = process.ExitCode;
141142
process.OutputDataReceived -= outputHandler;
142143
process.ErrorDataReceived -= outputHandler;
143144
}
144145

145-
string output = outputBuilder.ToString();
146+
string output = outputBuilder.ToString().Trim();
146147

147-
if (!output.StartsWith("INFO")) {
148+
if (processExitCode > 0)
149+
{
148150
throw new WebDriverException($"Invalid response from process: {fileName} {arguments}\n{output}");
149151
}
150152

151-
return output;
153+
return output.Replace("INFO\t", "");
152154
}
153155
}
154156
}

0 commit comments

Comments
 (0)