5

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

lfender6445
  • 25,940
  • 9
  • 95
  • 82
  • 1
    This is the exact same issue I'm currently facing. Please let me know if you manage to get it working. I will do the same if I get mine working. I've had success with getting what I need from the Java bindings but not Javascript. – Pan Aug 28 '18 at 05:58
  • If I have multiple functions, Like multiple feature files. then how it will work ? – wanderors Apr 15 '20 at 05:52

0 Answers0