I have a scenario where it has to be tested when there is no connection. To automate this i thought making browser as offline and to test the scenario is feasible. Someone please help me how do we set browser offline during execution of a test from protractor? is there a way to access browser preferences from protractor ?
Since I don't see what language you are coding in I'm gonna assume it's Java
this func turns off the wifi:
protected void disConnectInternet() throws IOException {
Map map = new HashMap();
map.put("offline", true);
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))));
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With