2

So, below is my basic code to try out Browsermob Proxy, and the output generated. The issue is with the output, which appear to be (1) incomplete in number and (2) not as detailed as I would manually check the network statistics in Dev tools (Firefox or Chrome).

Is it possible to have more detailed info in the HAR file? I would like to know, for example, if a specific Javascript has been loaded (or is there a better solution to this?).

        // Supply the path to the Browsermob Proxy batch file
        Server server = new Server(@"C:\Users\Frederik\Desktop\SeleniumTestje\browsermob-proxy-2.1.0-beta-6\bin\browsermob-proxy.bat");
        server.Start();

        Client client = server.CreateProxy();
        client.NewHar("google");

        var seleniumProxy = new Proxy { HttpProxy = client.SeleniumProxy };
        var profile = new FirefoxProfile();

        profile.SetProxyPreferences(seleniumProxy);
        // Navigate to the page to retrieve performance stats for
        IWebDriver driver = new FirefoxDriver(profile);
        driver.Navigate().GoToUrl("http://www.google.co.uk");

        // Get the performance stats
        HarResult harData = client.GetHar();
        foreach(Entry e in harData.Log.Entries)
        {
            Console.WriteLine(e.Request.Url, e.Request.Headers);
        }

Output in console:

http://ocsp.digicert.com/
http://ocsp.digicert.com/
http://ocsp.digicert.com/
http://www.google.co.uk/
http://clients1.google.com/ocsp
http://clients1.google.com/ocsp
http://clients1.google.com/ocsp
http://clients1.google.com/ocsp
FDM
  • 578
  • 5
  • 14

2 Answers2

0

I had the same issue with Fiddlercore but I have found a solution for that: Fiddlercore - Requested resource URL's are generic (OSCP-related) instead of actual resource

FDM
  • 578
  • 5
  • 14
0

I ran into this issue as well. It ended up being Chrome's networking tools enables its own cache by default, so BrowserMobProxy is not aware of all of the requests.

To fix the automated .har so that it is identical to a manual one, select the Disable Cache checkbox in the network tools. More info here: Disabling Chrome cache for website development

John K
  • 31
  • 3