I'm attempting to record network traffic in a har file using selenium, webdriver io and browsermob proxy
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));
}
The HAR file is created but without any information about network requests recorded in the entries.
What am i missing? The proxy is running on 8080 and selenium on 4444