Search code examples
c#seleniumbrowsermob-proxy

Browsermob Proxy - HAR file not as complete as manual HAR?


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

Solution

  • 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