【问题标题】:How to automate from protractor to set browser offline?如何从量角器自动化以将浏览器设置为离线?
【发布时间】:2016-11-18 13:31:00
【问题描述】:

我有一个场景,它必须在没有连接时进行测试。为了自动化这一点,我认为让浏览器脱机并测试场景是可行的。有人请帮助我在量角器执行测试期间如何将浏览器设置为离线?有没有办法从量角器访问浏览器首选项?

【问题讨论】:

标签: google-chrome firefox protractor ui-automation


【解决方案1】:

因为我看不到你用什么语言编码,所以我会假设它是 Java

这个函数关闭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))));

}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-05-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-08-30
    相关资源
    最近更新 更多