Mobitest and WebPageTest are great tools (essentially the same tool underneath) that I often use but they have a few limitations:
- there’s a limited number of test locations so latency can complicate testing
Safari on OSX is OK but there seems to be no way of generating a HAR file from the waterfall view in developer tools.
These limitations sometimes frustrate me so I decided to write a generator that creates HAR files from Safari running on the iOS Simulator (actual physical iPhones and iPad support will hopefully come too).
The generator is a node application that uses the Safari remote debugging protocol to talk to Safari running on the iOS simulator.
Although the debugging commands for Safari are essentially the same as Chrome’s they’re wrapped up as binary plists in an undocumented RPC protocol.
If you want to know more about the communications side node-iosdriver is the repository you need.
- Clone ios-har-builder
- Run npm install to install dependencies
Load the iOS Simulator, launch Safari and then run the HAR builder from the OSX command line e.g.
There should now be a HAR file ready for import into HAR viewer etc.
It’s fresh code, and a bit rough and ready in places so I doubt these are the only issues, if you come across any more feel free to raise an issue on GitHub or better still send me a pull request!
- Cookies aren’t currently supported in the exported HAR file (this is just a matter of writing the code)
- Code needs cleaning up and refactoring in several places, particularly around the network events in client.js
- Host and Port parameters don’t work
- Only works on iOS Simulator (for now)
- Validation needs to be disabled to display the watefalls in the HAR viewer
- Limited timing information due to the lack of resource timing in Safari
For now ios-har-builder is a separate fork as there are some differences in behaviour between Chrome and Safari e.g. lack of navigation / resource timing in Safari, Safari wraps the WebKit debug protocol in RPC etc.