Fix ChromeDriver NetworkConditions setter for .NET
The JSON object generated by the .NET version of ChromeDriver
NetworkConditions setter had incorrect format, and was rejected by
ChromeDriver. This commit fixes the format.
@@ -147,10 +147,10 @@ public ChromeDriver(ChromeDriverService service, ChromeOptions options, TimeSpan
: base(new DriverServiceCommandExecutor(service, commandTimeout), ConvertOptionsToCapabilities(options))
{
// Add the custom commands unique to Chrome
- AddCustomChromeCommand(GetNetworkConditionsCommand, CommandInfo.GetCommand, "/session/{sessionId}/chromium/network_conditions");
- AddCustomChromeCommand(SetNetworkConditionsCommand, CommandInfo.PostCommand, "/session/{sessionId}/chromium/network_conditions");
- AddCustomChromeCommand(DeleteNetworkConditionsCommand, CommandInfo.DeleteCommand, "/session/{sessionId}/chromium/network_conditions");
- AddCustomChromeCommand(SendChromeCommand, CommandInfo.PostCommand, "/session/{sessionId}/chromium/send_command");
+ this.AddCustomChromeCommand(GetNetworkConditionsCommand, CommandInfo.GetCommand, "/session/{sessionId}/chromium/network_conditions");
+ this.AddCustomChromeCommand(SetNetworkConditionsCommand, CommandInfo.PostCommand, "/session/{sessionId}/chromium/network_conditions");
+ this.AddCustomChromeCommand(DeleteNetworkConditionsCommand, CommandInfo.DeleteCommand, "/session/{sessionId}/chromium/network_conditions");
+ this.AddCustomChromeCommand(SendChromeCommand, CommandInfo.PostCommand, "/session/{sessionId}/chromium/send_command");
}
/// <summary>
@@ -187,7 +187,9 @@ public ChromeNetworkConditions NetworkConditions
throw new ArgumentNullException("value", "value must not be null");
}
- this.Execute(SetNetworkConditionsCommand, value.ToDictionary());
+ Dictionary<string, object> parameters = new Dictionary<string, object>();
+ parameters["network_conditions"] = value.ToDictionary();
+ this.Execute(SetNetworkConditionsCommand, parameters);
}
}
