Listen to this blog
If you want to run your Selenium script in different network conditions, you can do it using Chrome CommandExecutor.
Using Chrome Developer Tools, you can emulate different network conditions to check your app’s performance. If you want this to be implemented in automation testing, we have a command to do that. Let’s see with an example.
System.setProperty("webdriver.chrome.driver","drivers/chromedriver.exe"); ChromeDriver driver = new ChromeDriver(); CommandExecutor executor = driver.getCommandExecutor(); //Set the conditions Map<String, Object> map = new HashMap<String, Object>(); map.put("offline", false); map.put("latency", 5); map.put("download_throughput", 5000); map.put("upload_throughput", 5000); Response response = executor.execute(new Command(driver.getSessionId(),"setNetworkConditions", ImmutableMap.of("network_conditions", ImmutableMap.copyOf(map)))); driver.get("http://google.com");
Initially, we didn’t have this implementation in Java bindings to set network conditions. After a fix from Andrii Rohovets, GET_NETWORK_CONDITIONS, SET_NETWORK_CONDITIONS and DELETE_NETWORK_CONDITIONS are available to emulate network conditions in Selenium & Java.