|
19 | 19 | using System; |
20 | 20 | using System.Collections.Generic; |
21 | 21 | using System.Diagnostics; |
| 22 | +using Newtonsoft.Json; |
| 23 | +using OpenQA.Selenium.Internal; |
22 | 24 |
|
23 | 25 | #if !NET45 && !NET46 && !NET47 |
24 | 26 | using System.Runtime.InteropServices; |
@@ -59,7 +61,7 @@ public static string DriverPath(string driverName) |
59 | 61 | var binaryFile = Binary; |
60 | 62 | if (binaryFile == null) return null; |
61 | 63 |
|
62 | | - var arguments = "--driver " + driverName; |
| 64 | + var arguments = "--driver " + driverName + " --output json"; |
63 | 65 | return RunCommand(binaryFile, arguments); |
64 | 66 | } |
65 | 67 |
|
@@ -144,13 +146,26 @@ private static string RunCommand(string fileName, string arguments) |
144 | 146 | } |
145 | 147 |
|
146 | 148 | string output = outputBuilder.ToString().Trim(); |
| 149 | + string result = ""; |
| 150 | + try |
| 151 | + { |
| 152 | + Dictionary<string, object> deserializedOutput = JsonConvert.DeserializeObject<Dictionary<string, object>>(output, new ResponseValueJsonConverter()); |
| 153 | + Dictionary<string, object> deserializedResult = deserializedOutput["result"] as Dictionary<string, object>; |
| 154 | + result = deserializedResult["message"] as string; |
| 155 | + } |
| 156 | + catch (Exception ex) |
| 157 | + { |
| 158 | + throw new WebDriverException($"Error deserializing Selenium Manager's response: {output}", ex); |
| 159 | + } |
| 160 | + |
| 161 | + // 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 |
147 | 162 |
|
148 | 163 | if (processExitCode != 0) |
149 | 164 | { |
150 | | - throw new WebDriverException($"Invalid response from process (code {processExitCode}): {fileName} {arguments}\n{output}"); |
| 165 | + throw new WebDriverException($"Invalid response from process (code {processExitCode}): {fileName} {arguments}\n{result}"); |
151 | 166 | } |
152 | 167 |
|
153 | | - return output.Replace("INFO\t", ""); |
| 168 | + return result; |
154 | 169 | } |
155 | 170 | } |
156 | 171 | } |
0 commit comments