Skip to content

Commit 4a1f340

Browse files
JohnChen0jimevans
authored andcommitted
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. Signed-off-by: Jim Evans <[email protected]>
1 parent 508a8b6 commit 4a1f340

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

dotnet/src/webdriver/Chrome/ChromeDriver.cs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -147,10 +147,10 @@ public ChromeDriver(ChromeDriverService service, ChromeOptions options, TimeSpan
147147
: base(new DriverServiceCommandExecutor(service, commandTimeout), ConvertOptionsToCapabilities(options))
148148
{
149149
// Add the custom commands unique to Chrome
150-
AddCustomChromeCommand(GetNetworkConditionsCommand, CommandInfo.GetCommand, "/session/{sessionId}/chromium/network_conditions");
151-
AddCustomChromeCommand(SetNetworkConditionsCommand, CommandInfo.PostCommand, "/session/{sessionId}/chromium/network_conditions");
152-
AddCustomChromeCommand(DeleteNetworkConditionsCommand, CommandInfo.DeleteCommand, "/session/{sessionId}/chromium/network_conditions");
153-
AddCustomChromeCommand(SendChromeCommand, CommandInfo.PostCommand, "/session/{sessionId}/chromium/send_command");
150+
this.AddCustomChromeCommand(GetNetworkConditionsCommand, CommandInfo.GetCommand, "/session/{sessionId}/chromium/network_conditions");
151+
this.AddCustomChromeCommand(SetNetworkConditionsCommand, CommandInfo.PostCommand, "/session/{sessionId}/chromium/network_conditions");
152+
this.AddCustomChromeCommand(DeleteNetworkConditionsCommand, CommandInfo.DeleteCommand, "/session/{sessionId}/chromium/network_conditions");
153+
this.AddCustomChromeCommand(SendChromeCommand, CommandInfo.PostCommand, "/session/{sessionId}/chromium/send_command");
154154
}
155155

156156
/// <summary>
@@ -187,7 +187,9 @@ public ChromeNetworkConditions NetworkConditions
187187
throw new ArgumentNullException("value", "value must not be null");
188188
}
189189

190-
this.Execute(SetNetworkConditionsCommand, value.ToDictionary());
190+
Dictionary<string, object> parameters = new Dictionary<string, object>();
191+
parameters["network_conditions"] = value.ToDictionary();
192+
this.Execute(SetNetworkConditionsCommand, parameters);
191193
}
192194
}
193195

0 commit comments

Comments
 (0)