python-2.7selenium-webdriverbrowsermob

What do I do with HAR information


I am trying to collect network traffic data, I have setup a proof of concept, prior to integrating this with our test framework. I can get the har data, and it is coming back as a dictionary, Not really sure what to do with it after that? I assume I need to write it to a file so it can be uploaded, but do I save it as a .har or a .json?

server = Server("C:\\Users\\E003048\\Downloads\\browsermob-proxy-2.0-beta-9\\bin\\browsermob-proxy.bat")
server.start()
proxy = server.create_proxy()

profile = webdriver.FirefoxProfile()
profile.set_proxy(proxy.selenium_proxy())
driver = webdriver.Firefox(firefox_profile=profile)

proxy.new_har("Network Traffic")
driver.get("http://URL GOES HERE")
har_information = proxy.har
target_file = open("har_file.har", 'a')
target_file.write(str(har_information))
sleep(10)
proxy.close()
server.stop()
driver.quit()

I added to my script where it writes the har file, however when I plug it into a har viewer: http://www.softwareishard.com/har/viewer/ I am not getting anything. What else needs to be done?


Solution

  • HAR stands for HTTP Archive. This is a common format for recording HTTP tracing information. This file contains a variety of information, but for our purposes, it has a record of each object being loaded by a browser. Each of these objects’ timings is recorded.

    You can know more about HAR file specification here: http://www.softwareishard.com/blog/har-12-spec/

    And this page below lists many HAR parsing and visualizing tools: http://www.softwareishard.com/blog/har-adopters/