Monday July 08, 2013

✦ Taking Screenshots When Chaos Testing iOS Apps With UI AutoMonkey

I just made a quick update to the chaos testing tool, UI AutoMonkey. You can now specify an interval for the script to take screenshots while it is running.

Example Instruments run of the AutoMonkey taking screenshots

Spin up your application in Instruments with the Automation instrument like you normally would1. Import the UIAutoMonkey.js script into your trace document, then uncomment the configuration setting at the top of the script to set how often you want to take screenshots.

var UIAutoMonkey = {

config: {
  numberOfEvents: 1000,
  delayBetweenEvents: 0.05,    // In seconds

  // If the following line is uncommented, then screenshots are taken
  // every "n" seconds.
  screenshotInterval: 5,

The screenshotInterval configuration setting determines how many seconds occur between each shot. If you are running Instruments and UI AutoMonkey from the command line, then your screenshots are stored in the UIARESULTSPATH directory that you provided as an argument. If you are running through the Instruments GUI, then you can just click the “Export Traced Results” button in the left hand sidebar of the Automation instrument, pick where you want everything dropped and, boom. You’ve got screenshots of your app wilting under the unyielding onslaught of the UI AutoMonkey.

  1. Of course, if you’d like to know more about using the UI Automation to write tests for your iOS apps, I proudly recommend my book Test iOS Apps With UI Automation