June 5, 2016

Web Page Load Testing Using Selenium and BrowserMob Proxy

Web Page Load Testing Using Selenium and BrowserMob Proxy

Every high-performance organization uses one or the other performance measures and, often, are involved in devising new techniques and tools to deliver efficient performance systems. These tools are used to collect performance data to analyze and forecast the behavior of the system when it goes live and to eliminate all the issues that are minimizing its performance. In this post, we will look at one of the ways to collect performance data using an open-source tool: BrowserMob.

How to catch performance issues before they reach production?

The solution for such an issue is to re-purposing a Selenium script; we can run it through a proxy server and capture the HTTP traffic. This traffic gives an insight into application’s current performance status, to see whether the performance has degraded and to figure out the areas where the improvement is required if any.

BrowserMob Proxy is a useful tool which is closely integrated with Selenium and can work independently. It is used to capture performance data for web applications. It is used to manage browser behaviors and traffic in HAR (HTTP Archive format) such as blacklist and white-listing of the content, simulating network traffic and latency and rewriting HTTP requests and responses.

Web Performance data can also be manually captured by other tools like Firebug or Developer Tools. Using BrowserMob Proxy, we capture performance data in HAR format while running automated tests.

What is HAR Format?

HAR stands for HTTP Archive. It is a file format used by various HTTP session tools which help us to collect performance data. HAR file is produced by the HTTP tracking tools; these files capture the details of the client/server communication during the session, and this can be used for analysis of page load performance, object load time, object information, etc.

How to use BrowserMob Proxy?

  1. Download BrowserMob Proxy
  2. Start BrowserMob Proxy
  3. Create a new Project and import BrowserMob Proxy with Selenium Standalone Server Jar
  4. Run the script.
  5. After running the script, you will see the proxy server is started, and respective logs are generated.
  6. As the script stops, an HTTP achieve file is also generated with Performance Log of the desired web application.
  7. Now you can import that HAR file and see the results at http://pcapperf.appspot.com/. It will show the fetched performance data of that web application.

For implementing BrowserMob, we have to manage following software:

  • Selenium Web driver
  • BrowserMob proxy zip file http://opensource.webmetrics.com/browsermob-proxy/
  • Mozilla Firefox version supported by Selenium


server.start(): Starts the process running the proxy.

create_proxy(): Gets a client class that allows setting all the proxy details that you may need to.

Server.start(): This will start the BrowserMob proxy and then wait until it can interact with it.

url: Gets the URL that the proxy is running on. This is not the URL clients should connect to.

server.stop(): This will stop the process running the proxy.

How does HAR file looks like?



  • Loads the browser.
  • Capture all requests through the proxy server.
  • Saves the requests captured in a HARD file on disk.
  • Runs the HAR file through YSlow to get a numeric grade.
  • Asserts that the grade is above a certain level.

I hope this post will help you get started with BrowserMob and improve your application’s performance.

1 thought on “Web Page Load Testing Using Selenium and BrowserMob Proxy

Leave a Reply

%d bloggers like this: