UIAutomation has been around since iOS 4.0, however up until now there has been no easy way to run tests from the command line.
This has limited our ability to integrate UIA tests into our automatic test system.
The good news is that it now appears to be possible in iOS 5.
It’s actually fairly simple using the new instruments command line interface.
Check out the commands below to target both the device and the Simulator.
instruments -w <device_udid> -t /Developer/Platforms/iPhoneOS.platform/Developer/Library/Instruments/PlugIns/AutomationInstrument.bundle/Contents/Resources/Automation.tracetemplate <application.app> -e UIASCRIPT <script.js> -e UIARESULTSPATH <output_results_path>
instruments -t /Developer/Platforms/iPhoneOS.platform/Developer/Library/Instruments/PlugIns/AutomationInstrument.bundle/Contents/Resources/Automation.tracetemplate <full_path_to_application> -e UIASCRIPT <script.js> -e UIARESULTSPATH <output_results_path>
What’s more, this interface now even appears to print out all your logs to stdout.
This is going to make adoption of UIAutomation much easier for automatic build systems and as a part of other automated test systems.