Skip to content

Commit c68ecfe

Browse files
authored
Merge branch 'trunk' into trunk
2 parents 21e44ed + 66dbd3c commit c68ecfe

File tree

4 files changed

+55
-18
lines changed

4 files changed

+55
-18
lines changed

MODULE.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ bazel_dep(name = "protobuf", version = "21.7", dev_dependency = True, repo_name
1717
# Required for rules_rust to import the crates properly
1818
bazel_dep(name = "rules_cc", version = "0.0.9", dev_dependency = True)
1919

20-
bazel_dep(name = "rules_dotnet", version = "0.15.1")
20+
bazel_dep(name = "rules_dotnet", version = "0.16.0")
2121
bazel_dep(name = "rules_java", version = "7.11.1")
2222
bazel_dep(name = "rules_jvm_external", version = "6.3")
2323
bazel_dep(name = "rules_nodejs", version = "6.3.0")

dotnet/src/webdriver/BUILD.bazel

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ csharp_library(
5555
framework("nuget", "Microsoft.Bcl.AsyncInterfaces"),
5656
framework("nuget", "System.Threading.Tasks.Extensions"),
5757
framework("nuget", "System.Memory"),
58+
framework("nuget", "System.Text.Encodings.Web"),
5859
framework("nuget", "System.Text.Json"),
5960
],
6061
)
@@ -119,6 +120,7 @@ csharp_library(
119120
framework("nuget", "Microsoft.Bcl.AsyncInterfaces"),
120121
framework("nuget", "System.Threading.Tasks.Extensions"),
121122
framework("nuget", "System.Memory"),
123+
framework("nuget", "System.Text.Encodings.Web"),
122124
framework("nuget", "System.Text.Json"),
123125
],
124126
)

dotnet/src/webdriver/SeleniumManager.cs

Lines changed: 50 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
using System.Runtime.InteropServices;
2525
using System.Text;
2626
using System.Text.Json;
27-
using System.Text.Json.Nodes;
27+
using System.Text.Json.Serialization;
2828

2929
namespace OpenQA.Selenium
3030
{
@@ -38,6 +38,8 @@ public static class SeleniumManager
3838

3939
private static readonly string BinaryFullPath = Environment.GetEnvironmentVariable("SE_MANAGER_PATH");
4040

41+
private static readonly JsonSerializerOptions _serializerOptions = new() { PropertyNameCaseInsensitive = true, TypeInfoResolver = SeleniumManagerSerializerContext.Default };
42+
4143
static SeleniumManager()
4244
{
4345

@@ -86,10 +88,12 @@ public static Dictionary<string, string> BinaryPaths(string arguments)
8688
argsBuilder.Append(" --debug");
8789
}
8890

89-
var output = RunCommand(BinaryFullPath, argsBuilder.ToString());
90-
Dictionary<string, string> binaryPaths = new Dictionary<string, string>();
91-
binaryPaths.Add("browser_path", (string)output["browser_path"]);
92-
binaryPaths.Add("driver_path", (string)output["driver_path"]);
91+
var smCommandResult = RunCommand(BinaryFullPath, argsBuilder.ToString());
92+
Dictionary<string, string> binaryPaths = new()
93+
{
94+
{ "browser_path", smCommandResult.BrowserPath },
95+
{ "driver_path", smCommandResult.DriverPath }
96+
};
9397

9498
if (_logger.IsEnabled(LogEventLevel.Trace))
9599
{
@@ -108,7 +112,7 @@ public static Dictionary<string, string> BinaryPaths(string arguments)
108112
/// <returns>
109113
/// the standard output of the execution.
110114
/// </returns>
111-
private static JsonNode RunCommand(string fileName, string arguments)
115+
private static SeleniumManagerResponse.ResultResponse RunCommand(string fileName, string arguments)
112116
{
113117
Process process = new Process();
114118
process.StartInfo.FileName = BinaryFullPath;
@@ -174,47 +178,76 @@ private static JsonNode RunCommand(string fileName, string arguments)
174178
}
175179

176180
string output = outputBuilder.ToString().Trim();
177-
JsonNode resultJsonNode;
181+
182+
SeleniumManagerResponse jsonResponse;
183+
178184
try
179185
{
180-
var deserializedOutput = JsonSerializer.Deserialize<Dictionary<string, JsonNode>>(output);
181-
resultJsonNode = deserializedOutput["result"];
186+
jsonResponse = JsonSerializer.Deserialize<SeleniumManagerResponse>(output, _serializerOptions);
182187
}
183188
catch (Exception ex)
184189
{
185190
throw new WebDriverException($"Error deserializing Selenium Manager's response: {output}", ex);
186191
}
187192

188-
if (resultJsonNode["logs"] is not null)
193+
if (jsonResponse.Logs is not null)
189194
{
190-
var logs = resultJsonNode["logs"];
191-
foreach (var entry in logs.AsArray())
195+
foreach (var entry in jsonResponse.Logs)
192196
{
193-
switch (entry.GetPropertyName())
197+
switch (entry.Level)
194198
{
195199
case "WARN":
196200
if (_logger.IsEnabled(LogEventLevel.Warn))
197201
{
198-
_logger.Warn(entry.GetValue<string>());
202+
_logger.Warn(entry.Message);
199203
}
200204
break;
201205
case "DEBUG":
202206
if (_logger.IsEnabled(LogEventLevel.Debug))
203207
{
204-
_logger.Debug(entry.GetValue<string>());
208+
_logger.Debug(entry.Message);
205209
}
206210
break;
207211
case "INFO":
208212
if (_logger.IsEnabled(LogEventLevel.Info))
209213
{
210-
_logger.Info(entry.GetValue<string>());
214+
_logger.Info(entry.Message);
211215
}
212216
break;
213217
}
214218
}
215219
}
216220

217-
return resultJsonNode;
221+
return jsonResponse.Result;
222+
}
223+
}
224+
225+
internal class SeleniumManagerResponse
226+
{
227+
public IReadOnlyList<LogEntryResponse> Logs { get; set; }
228+
229+
public ResultResponse Result { get; set; }
230+
231+
public class LogEntryResponse
232+
{
233+
public string Level { get; set; }
234+
235+
public string Message { get; set; }
236+
}
237+
238+
public class ResultResponse
239+
{
240+
[JsonPropertyName("driver_path")]
241+
public string DriverPath { get; set; }
242+
243+
[JsonPropertyName("browser_path")]
244+
public string BrowserPath { get; set; }
218245
}
219246
}
247+
248+
[JsonSerializable(typeof(SeleniumManagerResponse))]
249+
internal partial class SeleniumManagerSerializerContext : JsonSerializerContext
250+
{
251+
252+
}
220253
}

java/src/org/openqa/selenium/remote/service/DriverFinder.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,8 @@ private List<String> toArguments() {
156156
arguments.add(proxy.getSslProxy());
157157
} else if (proxy.getHttpProxy() != null) {
158158
arguments.add(proxy.getHttpProxy());
159+
} else if (proxy.getProxyAutoconfigUrl() != null) {
160+
arguments.add(proxy.getProxyAutoconfigUrl());
159161
}
160162
}
161163
return arguments;

0 commit comments

Comments
 (0)