title: Capturing Selenium Automated Performance Metrics
body: <p>I am attempting to capture client/server response time as recorded by the browser using Selenium WebDriver.  My selenium test cases are written in Java.  I don't control the code in which I am testing and have tried a variety of solutions as laid out below but none of them meet my requirements 100%.</p>
  
  <p>At the end of the day, I am looking to be able to surround a test step with start() and stop() logic and save the client/server response time as recorded by the browser to a database for reporting.</p>
  
  <p>If I am missing something obvious, please suggest a different approach!</p>
  
  <p><strong>Things I've tried:</strong></p>
  
  <p>1.)  Manually surround the test step with start() and stop() timer logic.</p>
  
  <p>PROS:  Simplest solution and it works for both page loads and ajax calls.
  CONS:  Does not capture what the true response time from the browser and if there is unusually long wait time on the Selenium side, it falsely reports the numbers.  It also considers things like user input as part of the transaction which I don't want.  I don't necessarily control the Page Objects I am dealing with so it is not an easy work around.</p>
  
  <p>2.)  Using Navigation Timings API</p>
  
  <p>PROS:  This works great for page loads
  CONS:  Does not work for AJAX calls.  AJAX calls are simply added to the overall page load time and the getEvents() call is not available in Firefox for me to attempt to manually calculate the ajax time.</p>
  
  <p>3.)  Using Browser MOB</p>
  
  <p>PROS:  Can surround a transaction, not just a request and save it in HAB format.
  CONS:  I had high hopes for this but the numbers are not reported from a browser perspective and thus are just as inaccurate as (1).  There is also setup overhead creating a proxy server and the resulting HAB file does not have client/server response times broken down.</p>
  
  <p>4.)  Firefox and Networking Export plugin</p>
  
  <p>PROS:  Nice automated solution
  CONS:  The export functionality creates a new file for each request but can not aggregate multiple requests into a transaction.  There is also no way in which to specify the file name so it makes it impossible to attempt to read in the files which are simply appended with a timestamp.</p>
  
  <p>5.)  Relying on "framework" response times.</p>
  
  <p>PROS:  Works and at at least on the surface appears accurate.
  CONS:  Does not work across frameworks and thus can not be considered a scalable solution for a busy production site where multiple frameworks are in use.</p>
  
  <p><strong>Things I haven't tried:</strong></p>
  
  <p>1.)  Javascript injection</p>
  
  <p>PROS:  Perhaps I could inject javascript like the boomerang plugin into the site to measure response times.</p>
  
  <p>CONS:  May be difficult and I worry about losing my injection through page events which I may not be aware of or control.</p>
  
  <p>2.)  Relying on HTTPWatch plugin</p>
  
  <p>PROS:  Appears to do what I want
  CONS:  There is no Java plugin and I don't know if I am up for creating a COM based integration layer when I don't even know if it will suit my needs.  I do like the ability to start/stop transactions though vs. individual requests.</p>
  
  <p>3.) YSlow, Google Page Speed and WebPageTest</p>
  
  <p>PROS:  Seamless?
  CONS:  Non-starter since I am behind a firewall although I am intrigued on how they attach to the requests.</p>