“ setNetworkConditions”在量角器e2e测试中说没有功能 [英] "setNetworkConditions" in protractor e2e tests says not a function
本文介绍了“ setNetworkConditions”在量角器e2e测试中说没有功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试使用
driver.setNetworkConditions({ offline : true });
在我的代码中,但显示失败:_protractor.browser.driver .setNetworkConditions不是函数
。
in my code, but it says that Failed: _protractor.browser.driver.setNetworkConditions is not a function
.
这是我访问它的代码。
import { browser } from 'protractor';
describe('disable browser network', () => {
"use strict";
let browserA = browsers.a;
it('should disable chrome network', () => {
browserA.ignoreSynchronization = true;
browser.driver.setNetworkConditions({ offline: true });
//..... my other functionality here
});
afterAll(() => {
browserA.quit();
});
});
推荐答案
我找到了解决方案,实际上我只需要全局更新我的npm量角器包
I have found the solution to this, actually I just had to update my npm protractor package globally
npm install protractor -g
还有另外一件事是将 package.json
中的量角器的软件包版本更新为 5.2.0
,然后再次运行 npm install
命令更新 node_modules
and one more thing was to update the package version of protractor to 5.2.0
in package.json
and again run the npm install
command to update the node_modules
然后这东西工作得很好
browser.driver.setNetworkConditions({
offline: true, //I needed to set it offline intentionally
latency: 150,
download_throughput: 450 * 1024,
upload_throughput: 150 * 1024
});
这篇关于“ setNetworkConditions”在量角器e2e测试中说没有功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文