Thursday, January 5, 2012

WebSite Performance data using Selenium

I wanted to export the Firebug's HTTP Traffic data shown in the Net panel if I crawl the page using Selenium . Why Selenium? There are other alternatives to get that data. However, I have two reasons for this approach.

1. I wanted to know what data from which URL. This will combine the data with URL. i.e. seeing what user will see. It is easier to debug instead of just seeing the requests.
2. Data from Firebug is better then alternatives.

It is easy to see that manually. How to automate that? By using NetExport Add-on by Jan Odvarko. It exports the data as HAR archive.

How to get that working in Selenium WebDriver?

      Create a profile for WebDriver using firefox -P -no-remote.Then, set the AutoExport option to true in Selenium. Below code does that

ProfilesIni allProfiles = new ProfilesIni();
FirefoxProfile profile = allProfiles.getProfile("<ProfileName>");
driver = new FirefoxDriver(profile);

Now it will export the HTTP traffic data whenever the page is refreshed or new page loaded. Use HARViewer to see the data.

Now comes the tricky part. How to export the data for Ajax requests? I don't know. Netexport exports data, if and when page is reloaded. It can be done, if Selenium can execute the chrome functions. I'm working on that.


raja's shared items

My "Testing" Bundle