lfe*_*445 5 automation node.js webdriver-io browsermob-proxy
我正在尝试使用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));
}
Run Code Online (Sandbox Code Playgroud)
创建了HAR文件,但是条目中没有记录有关网络请求的任何信息。
我想念什么?代理在8080上运行,硒在4444上运行
| 归档时间: |
|
| 查看次数: |
305 次 |
| 最近记录: |