I am using below code to simulate slow network condition. Issue is that except for switching between offline or online mode page load or any action is not getting slower even when the code has no errors. Any help is appreciated.
WebDriver augmentedDriver;
ChromiumNetworkConditions networkConditions;
public void switchToNetworkModeUsingAugmentor(String networkMode, String offline, final WebDriver driver) throws IOException {
if (augmentedDriver == null && networkConditions == null) {
augmentedDriver = new Augmenter().augment(driver);
networkConditions = new ChromiumNetworkConditions();
}
int currentDownloadThrouhput = networkConditions.getDownloadThroughput();
int currentUploadThrouhput = networkConditions.getUploadThroughput();
Duration currentLatency = networkConditions.getLatency();
Integer currentLatencyInSeconds = (int) currentLatency.getSeconds();
LOGGER.info("Current Download throughput {}", currentDownloadThrouhput);
LOGGER.info("Current Upload throughput {}", currentUploadThrouhput);
LOGGER.info("Current Latency in seconds {}", currentLatencyInSeconds);
if (networkMode.equalsIgnoreCase("Super Slow")) {
networkConditions.setDownloadThroughput(5000);
networkConditions.setUploadThroughput(5000);
networkConditions.setOffline(BooleanUtils.toBoolean(offline));
networkConditions.setLatency(Duration.ofMillis(15000));
} else if (networkMode.equalsIgnoreCase("Slow")) {
networkConditions.setDownloadThroughput(5000);
networkConditions.setUploadThroughput(5000);
networkConditions.setOffline(BooleanUtils.toBoolean(offline));
networkConditions.setLatency(Duration.ofMillis(10000));
}
((HasNetworkConditions) augmentedDriver).setNetworkConditions(networkConditions);
currentDownloadThrouhput = networkConditions.getDownloadThroughput();
currentUploadThrouhput = networkConditions.getUploadThroughput();
currentLatency = networkConditions.getLatency();
currentLatencyInSeconds = (int) currentLatency.getSeconds();
LOGGER.info("Current Download throughput {}", currentDownloadThrouhput);
LOGGER.info("Current Upload throughput {}", currentUploadThrouhput);
LOGGER.info("Current Latency in seconds {}", currentLatencyInSeconds);
}