Skip to main content

Posts

Showing posts with the label SlowNetwork

What happens when you also need to test how your application behaves on a slow connection using Selenium?

Execute Selenium test suite on a slow network connection : public class SetNetworkConditions { public static WebDriver driver; @Test public static void setSlowNetwork () throws IOException { WebDriverManager.chromedriver().setup(); driver = new ChromeDriver(); driver.manage().window().maximize(); CommandExecutor executor = ((RemoteWebDriver) driver).getCommandExecutor(); // Setting the slow network conditions Map<String, Comparable> map = new HashMap<String, Comparable>(); map.put(“offline”, false); map.put(“latency”, 5); map.put(“download_throughput”, 5000); map.put(“upload_throughput”, 5000); Response response = executor.execute(new Command(((RemoteWebDriver) driver).getSessionId(), “setNetworkConditions”, ImmutableMap.of(“network_conditions”, ImmutableMap.copyOf(map)))); driver.get(“https://testersdigest.blogspot.com"); long navigationStart = (long) ((JavascriptExecutor) driver) .executeScript(“return window.performa