I have been trying to implement network throttling with Selenium-WebDriver based on the snippet available here in this post. https://stackoverflow.com/a/56526094/2122388
Re-posting the code from above link:
protected void networkThrotting() throws IOException {
Map map = new HashMap();
map.put("offline", false);
map.put("latency", 5);
map.put("download_throughput", 500);
map.put("upload_throughput", 1024);
CommandExecutor executor = ((ChromeDriver)driver).getCommandExecutor();
Response response = executor.execute(
new Command(((ChromeDriver)driver).getSessionId(), "setNetworkConditions", ImmutableMap.of("network_conditions", ImmutableMap.copyOf(map)))
);
}
It throws as exception like org.openqa.selenium.UnsupportedCommandException: setNetworkConditions
. With my debugging, found like there is no definition for setNetworkConditions
in AbstractHttpCommandCodec
but found setNetworkConnection
. SO tried changing this as below:
protected void networkThrotting() throws IOException {
Map map = new HashMap();
map.put("offline", false);
map.put("latency", 5);
map.put("download_throughput", 500);
map.put("upload_throughput", 1024);
CommandExecutor executor = ((ChromeDriver)driver).getCommandExecutor();
Response response = executor.execute(
new Command(((ChromeDriver)driver).getSessionId(), "setNetworkConnection", ImmutableMap.of("network_connection", ImmutableMap.copyOf(map)))
);
}
It does not throw any exception and let the test pass, but there is no change in the network speed as intended. I am using Selenium 3.x and Chrome 100.x.
So any input here is much appreciated.