BrowserMob with Selenium for Performance Test

BrowserMob Proxy

BrowserMob Proxy is a simple utility that help to capture the performance data from browsers and also to manipulate the network traffic. We can integrate BrowserMob utility with our selenium webdriver to get performance related data since Browsermob proxy is one of the proxy that has been closely integrated with Selenium Webdriver.

Features:

The proxy is programmatically controlled via a REST interface or being embedded directly inside Java-based programs. It captures performance data in the HAR format.

HAR(HTTP Archive) is a online tool visualizing. HAR is produced by the HTTP tracking tools, these files captures the details of the client/server communication and this can be used for Performance analysis.

You can view the HAR file contents by uploading the HAR extension file in the below website
http://pcapperf.appspot.com/

Selenium WebDriver - Browsermob Proxy Integration

I would like to explain how to integrate Selenium Webdriver with browsermob proxy using java.

Softwares required:

1. Latest Selenium Jar file from Selenium website.
2. Download the Browermob proxy zip file from the website "https://github.com/webmetrics/browsermob-proxy/downloads"
3. Mozilla Firefox version supported by Selenium


Steps:

1. Unzip the Browsermob-proxy zip file and save it in local folder.(Say BrowsermobFolder)
2. Create new project in Eclipse ide, lets say SampleProgram.
3. In eclipse, right click on the project and choose 'Properties'.
4. Navigate to 'Java Build Path' and select the 'Libraries' tab.
5. Click on the 'Add External Jar' option.
6. Add all the jar dependencies of Selenium and Browsermob-proxy jar.
7. Run browsermob-proxy.bat file which is in the bin directory of BrowsermobFolder. Refer Step1
8. Now, create a new class and copy and paste the code mentioned in the link.

Execute the code. You can observe that the program has launched Firefox browser with the website URL "http://Yahoo.com" and also created the HAR file in the user mentioned path.(In our case, the path defined in the vairable "strFilePath").

You can view the results which is in HAR file format by uploading the generated HAR File in the below website
http://pcapperf.appspot.com/

Soon, you can expect code to convert the HAR contents into User Accessible format like .PNG or .JPEG

Please let me know if you have any queries.

Popular posts from this blog

Selenium Webdriver Interview Questions with Answer

Selenium IDE Interview Questions with Answer

DLL to Jar file conversion