I followed this site to get started with UI Automation. http://blog.manbolo.com/2012/04/08/ios-automated-tests-with-uiautomation#1.2
I am trying to start Instruments from the command line. Unfortunately I get an error:
2013-03-14 14:06:36.376 instruments[17854:1207] Connection to the remote device lost while launching target. Aborting...
2013-03-14 14:06:36.378 instruments[17854:1207] Recording cancelled : At least one target failed to launch; aborting run
Instruments Trace Error : Failed to start trace.
This is the command I used:
instruments -w {deviceId} -t /Applications/Xcode.app/Contents/Applications/Instruments.app/Contents/PlugIns/AutomationInstrument.bundle/Contents/Resources/Automation.tracetemplate {appname} -e UIASCRIPT /Path/to/Script.js
Currently I am using Xcode 4.6.
I was having the same problem, I had done following changes and worked fine for me:
Changed the location of -w udid in given command, put it after path of tracetemplate and before path of app, i.e. this should be just like
I'd suggest you take a look at Jonathan's screen-shooter, which he explains about on: http://cocoamanifest.net/articles/2013/01/ui-screen-shooter.html. This really helped me to understand a lot about the simulator, running instruments from the command line and more. Like Jonathan explained, you will need to build the app first, to have something to run.
Get his sources here: https://github.com/jonathanpenn/ui-screen-shooter and see if that works for you. Then work your way back to a simple script that will build the app, put it in a convenient location and run instruments using the app and the desired template.
In 2014 with Xcode 6.0.1, you would do something like this for running UIAutomation tests on the simulator, naming your simulator after the -w switch:
If you want to run this on your device, instead of 'iPhone 5s' like I have in the snippet above for running on the simulator, you'd provide the UDID of your device. You can then omit the long app path I've given above, and just provide the name of the app. Instruments will be able to find it on the device.
Using my example from above, but modified for a hypothetical device, this would look like:
This is not verified with an on device invocation, so please test it. There's a bit of flexibility with parameter ordering.
I do have a verified UI Automation Runner script that works really well for Xcode 6.0.1 and the simulator.
This worked for me.
I did the
ps
command to see which processes are running. I found that instruments was still running. I then didkillall instruments
and that killed the instruments process. I then did my instruments command and it worked perfect after that.try this
instead of app name, you should give the complete path to your app.