3

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.

  • What I should put as the host and port for the proxy?
  • I'm using Selenium, and I've specified the host and port for it, but I'm getting ECONNREFUSED errors.

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!

Community
  • 1
  • 1
Marcos
  • 4,607
  • 7
  • 29
  • 57
  • What are those `selHost` and `selPort` in your code? Your example link doesn't show any host or port codes in it. If you are trying to connect to webdriver using that address, then probably you should remove it and try as protractor can instantiate the webdriver's instance to work on itself. Thanks – Girish Sortur Oct 27 '15 at 17:17
  • `selHost` and `selPort` are the host and port used by Selenium. I get this when executing `grunt protractor`: `Selenium standalone server started at http://10.243.146.33:58620/wd/hub` The host is fixed, but since the port changes from time to time, I've specified it in my protractor config file (`seleniumPort` field) – Marcos Oct 28 '15 at 06:56

0 Answers0