node.js - 带有 WebdriverIO 和 Selenium 的 Browsermob 代理
问题描述
我正在尝试使用 selenium、webdriver io 和 browsermob 代理在 har 文件中记录网络流量
var webdriverio = require('webdriverio');
var Proxy = require('browsermob-proxy').Proxy
, fs = require('fs')
, proxy = new Proxy()
;
proxy.cbHAR('scratchpads.eu', doSeleniumStuff, function(err, data) {
console.log('running cb')
if (err) {
console.error('ERR: ' + err);
} else {
fs.writeFileSync('stuff.har', data, 'utf8');
}
});
const opts = {
desiredCapabilities: {
browserName: 'chrome',
},
host: 'localhost',
port: '4444',
protocol: 'http',
coloredLogs: true,
}
function doSeleniumStuff(proxy, cb) {
var browser = webdriverio.remote(opts);
browser
.init()
.url('http://scratchpads.eu')
.getTitle().then(function(title) {
console.log('Title was: ' + title);
})
.end().then(cb).catch(e => console.log(e));
}
HAR 文件已创建,但没有关于条目中记录的网络请求的任何信息。
我错过了什么?代理在 8080 上运行,硒在 4444 上运行
解决方案
推荐阅读
- php - 在没有索引的数组上调用值
- javascript - 当我尝试制作 ID 时;“无法读取未定义的属性‘长度’。”
- android - 相机应用程序翻转录制的视频
- python - 从循环中的数据创建列表
- amazon-web-services - 从 AWS CDK 创建具有自定义域名的 Cognito 用户池
- angular - 如何在Angular4中动态使用eval创建新组件
- android - DioError [DioErrorType.RESPONSE]:Http 状态错误 [400] 异常
- r - 如何使用 rmarkdown 使绘图图表适应页面宽度?
- generics - Reactor Kotlin 通用类型返回
- matlab - 解决 SIMULINK 模型中的代数环面临的挑战