efl*_*lat 6 google-chrome google-chrome-devtools protractor
根据此问题,ChromeDevTools 的网络节流功能可在 ChromeDriver-2.26+ 中使用。如何在我们的量角器配置文件中指定它?
基于四处搜索,我在配置文件中尝试了一些变化。我已经向 chromeOptions添加了一个networkConnectionEnabled属性和一个prefs块,如下所示。(请注意,我没有同时执行它们。)
multiCapabilities: [
{
'browserName': 'chrome',
'platform': 'ANY',
'networkConnectionEnabled': {'type': 'GPRS'},
'chromeOptions': {
args: [
'--lang=en',
'--window-size=1280,1024'
],
prefs: {
'net.throttling_enabled': 'true,50,20'
}
}
}
],
Run Code Online (Sandbox Code Playgroud)
我根据我在此处找到的内容尝试的第二个选项(第 1983 行)。这些都不会改变量角器运行的行为,当我手动测试并设置节流时,会在我的代码中触发某个条件。
编辑:还尝试添加如下内容 underchromeOptions: mobileEmulation: {networkConnectionEnabled: true, networkThrottle: '2G'}
根据更改日志,在 Selenium 3.4.0 中添加了用于在 Chrome 中操作网络仿真的 API。它们在 Protract 5.2.0 或更新版本中可用。
网络条件可以配置如下:
browser.driver.setNetworkConditions({
offline: false,
latency: 5, // Additional latency (ms).
download_throughput: 500 * 1024, // Maximal aggregated download throughput.
upload_throughput: 500 * 1024 // Maximal aggregated upload throughput.
});
Run Code Online (Sandbox Code Playgroud)
这段代码应该放在函数protractor.conf.js内部onPrepare。
| 归档时间: |
|
| 查看次数: |
2655 次 |
| 最近记录: |