I was trying to use browsermob-proxy using this and this with webdriverio. It runs fine , but theres no har
file generated. I tried changing the below line
fs.writeFileSync('stuff.har', data, 'utf8');
to
fs.writeFile('/Users/abc/xyz/stuff.har', data, 'utf8');
in the below code (from above links)
var Proxy = require('browsermob-proxy').Proxy
, webdriverio = require("./node_modules/webdriverio/")
, fs = require('fs')
, proxy = new Proxy()
;
proxy.cbHAR('search.yahoo.com', doSeleniumStuff, function(err, data) {
if (err) {
console.error('ERR: ' + err);
} else {
fs.writeFileSync('stuff.har', data, 'utf8');
}
});
function doSeleniumStuff(proxy, cb) {
var browser = webdriverio.remote({
host: 'localhost'
, port: 4444
, desiredCapabilities: { browserName: 'firefox', seleniumProtocol: 'WebDriver', proxy: { httpProxy: proxy } }
});
browser
.init()
.url("http://search.yahoo.com")
.setValue("#yschsp", "javascript")
.submitForm("#sf")
.end(cb);
}
but still no har
file at the location is generated. What is missing here?