[dotnet] toggle Selenium Manager execution output on exit code
@@ -60,8 +60,7 @@ public static string DriverPath(string driverName)
if (binaryFile == null) return null;
var arguments = "--driver " + driverName;
- var output = RunCommand(binaryFile, arguments);
- return output.Replace("INFO\t", "").TrimEnd();
+ return RunCommand(binaryFile, arguments);
}
/// <summary>
@@ -117,6 +116,7 @@ private static string RunCommand(string fileName, string arguments)
process.StartInfo.RedirectStandardError = true;
StringBuilder outputBuilder = new StringBuilder();
+ int processExitCode;
DataReceivedEventHandler outputHandler = (sender, e) => outputBuilder.AppendLine(e.Data);
@@ -138,17 +138,19 @@ private static string RunCommand(string fileName, string arguments)
}
finally
{
+ processExitCode = process.ExitCode;
process.OutputDataReceived -= outputHandler;
process.ErrorDataReceived -= outputHandler;
}
- string output = outputBuilder.ToString();
+ string output = outputBuilder.ToString().Trim();
- if (!output.StartsWith("INFO")) {
+ if (processExitCode > 0)
+ {
throw new WebDriverException($"Invalid response from process: {fileName} {arguments}\n{output}");
}
- return output;
+ return output.Replace("INFO\t", "");
}
}
}
