Is there any way to automatically generate har files? [closed]
Asked Answered
B

6

8

I'm trying to automate page load time testing. I'm imagining running a cron job every couple hours that will load various pages from my website, retrieve the associated har files, and process the data. The part I can't figure out is how to programatically generate har files ... the only way I know of now is manually through chrome developer tools. Does anyone know if this can be done, and if so how?

Bristle answered 8/5, 2012 at 18:36 Comment(0)
C
2

Have a look at the BrowserMob Proxy or run a private instance of WebPageTest and use WPT Monitor with it

Cordate answered 13/5, 2012 at 21:30 Comment(1)
Thanks Andy, WPT Monitor looks very promising!Bristle
S
5

We just did this recently with Firebug and NetExport:

http://www.softwareishard.com/blog/netexport/

You can configure NetExport to automatically export HAR files to a specified directory (compression optional). This has been useful for us in getting samples of resource loading data for particular web apps.

Strike answered 8/5, 2013 at 17:9 Comment(0)
C
2

Have a look at the BrowserMob Proxy or run a private instance of WebPageTest and use WPT Monitor with it

Cordate answered 13/5, 2012 at 21:30 Comment(1)
Thanks Andy, WPT Monitor looks very promising!Bristle
P
1

PhantomJS (headless Webkit-browser on Node.js) can export .har files directly.

This way you should be able to build a tool that returns a .har-file for a given URL...

Pocket answered 8/5, 2013 at 12:38 Comment(0)
P
1

Using the combination of Selenium Server, Browsermob-Proxy and Chromedriver (if you wish to use Chrome to do your tests) in a language binding of your choice (java, python, c#) is the best way to programatically generate an HAR file, imho.

I have written this little python tool that uses Browsermob proxy to generate HAR file headlessly using Chrome or Firefox. It also generates NavigationTimingAPI data that lets you get to the tiny details of page load time.

Pain answered 12/9, 2015 at 17:23 Comment(0)
S
0

If you can't run your own instance as Mr. Davies suggested you could use the REST API.

Marcel Duran has written a WebPageTest API wrapper for nodejs. Which can return a HAR from the resulting test. https://github.com/marcelduran/webpagetest-api

Seisin answered 25/9, 2014 at 16:46 Comment(0)
N
0

Har file reader API also available which will help you to parse the har file basically JSON format .

You can also get the details of each http/https request/response,etc for preparing metrics.

Notions answered 21/8, 2015 at 18:16 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.