anchor.diff:  = Tracking tests' network statistics with Docker
   :hp-tags: browsermob-proxy, webdriver, allure, docker, harviewer, java, testng
   :published_at: 2016-07-18
  -==== Browsermob Proxy Docker image
  +== Browsermob Proxy Docker image
   To be able to use the following example, you'll need to build link:https://github.com/sskorol/docker-browsermob-proxy[docker-browsermob-proxy^] first. This base Docker image contains latest (2.1.1) link:https://github.com/lightbody/browsermob-proxy[Browsermob Proxy (BMP)] version.
  -==== Docker configuration
  +== Docker configuration
   Raising newly built image would be quite simple with a help of `docker-compose`. Here's a sample BMP / Selenium Grid configuration, which will help you to link all containers together:
   [source,YAML]
   ----
  
positive.code: })();
  ----
  Note that `{{link}}` is a mandatory reference to the HAR file, produced while test execution. I left `{{height}}` option configurable as well, as default value is quite low, and you may want to manage it by yourself depending on screen resolution.
  ==== HAR storage
  A bit painful topic. I've already played with link:https://github.com/pavel-paulau/harstorage[harstorage] project, but it seems quite unstable with latest version of BMP, and requires pretty old software dependencies.
  
  To avoid dependencies hell and configuration overhead, we'll use much easier approach. Produced HAR files will be stored on a lightweight Web Server, e.g. link:https://www.lighttpd.net[lighttpd], and then referenced in code while HAR template generation.
  ==== REST Browsermob Proxy client
  To establish connection with `docker-browsermob-proxy` image via REST we need to find out its internal IP address first. Here's a script, which could help us:
  [source,bash]
  ----
  
negative.code:  - chromenode:node_ch
  ----
  If you missed my link:http://qa-automation-notes.blogspot.com/2016/04/docker-selenium-and-bit-of-allure-how.html[article] about `docker-selenium` customization, you can pull above images from appropriate link:https://github.com/sskorol/docker-selenium[fork].
  == HAR viewer
  To provide extensive network statistics in test results reports, we'll use one of the best link:http://www.softwareishard.com/blog/har-viewer[HAR Viewer], which supports really nice embedded mode.
  
  Java implementation requires both front-end and backend involvement. You may already know that link:http://allure.qatools.ru[Allure] supports `html` attachments. To be able to use embedded HAR Viewer, we need to create our own template first. This could be done using link:https://github.com/spullara/mustache.java[mustache] library.
  