Marcos
Marcos

Reputation: 4643

Understanding Selenium + browsermob-proxy + protractor + AngularJS

What I have: several integration test specs written in Jasmine for my AngularJS app (they navigate through my entire app)

What I want: perform a network monitoring of my app and export the data using HAR

Naive solution: just write a script which receives an URL and export the data using HAR. It's easy, but it's not automatic (I need to provide the urls manually)

Enhance solution: automate the process mentioned. A script that navigates through all the pages of my app and extracts the network data for each. But since I'm already navigating through all the pages of my app via integration tests (protractor + Jasmine) I want to just "plug-in" the part about exporting the network traffic.

I've found this How can I use BrowserMob Proxy with Protractor?, and I was checking out the example provided here example, but I'm not quite sure how it works.

This is my protractor file config:

var Proxy = require('browsermob-proxy').Proxy;
...

protractorConf = exports.base = {
    //... more things

    onPrepare: function() {
        ... more things....
        browser.params.proxy = new Proxy({ // my selenium config for browsermob
            selHost: '10.243.146.33',
            selPort: 9456
        });
    //... more things
    }
}

And in one of my integration tests specs (it's CoffeeScript btw):

beforeEach ->
  browser.get BASE_URL
  browser.params.proxy.doHAR 'some/page/of/my/app', (err, data) ->
    if err
      console.log err
    else
      console.log data

But I'm getting as I've said ECONNREFUSED error. I'm quite lost about the integration about Selenium with Protractor and brosermob.

Any ideas or alternatives? Thanks!

Upvotes: 3

Views: 861

Answers (0)

Related Questions