Start Instruments from the command line

有些话、适合烂在心里 提交于 2019-12-06 04:13:05

问题


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.


回答1:


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:

instruments -t '/Applications/Xcode.app/Contents/Applications/Instruments.app/Contents/PlugIns/AutomationInstrument.xrplugin/Contents/Resources/Automation.tracetemplate' \
    -w 'iPhone 5s' \
    '/Users/sohail/Library/Developer/CoreSimulator/Devices/7232A640-A9D2-4626-A2AD-37AFFF706718/data/Containers/Bundle/Application/E71B915E-051D-4BEF-9083-34416D02EC91/RoadRunnerRadar.app' \
    -e UIASCRIPT '/Users/sohail/Developer/clients/acme/roadrunnerradar/ACMERoadRunnerRadarAutomationTests/TestRunner.js' \
    -e UIARESULTSPATH '/Users/sohail/Developer/clients/acme/roadrunnerradar/ACMERoadRunnerRadarAutomationTests/TestResults/'

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:

instruments -t '/Applications/Xcode.app/Contents/Applications/Instruments.app/Contents/PlugIns/AutomationInstrument.xrplugin/Contents/Resources/Automation.tracetemplate' \
    -w '8532A640-A9C2-4626-A2AD-37AFFF706799' \
    'RoadRunnerRadar' \
    -e UIASCRIPT '/Users/sohail/Developer/clients/acme/roadrunnerradar/ACMERoadRunnerRadarAutomationTests/TestRunner.js' \
    -e UIARESULTSPATH '/Users/sohail/Developer/clients/acme/roadrunnerradar/ACMERoadRunnerRadarAutomationTests/TestResults/'

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.




回答2:


This worked for me.

I did the ps command to see which processes are running. I found that instruments was still running. I then did killall instruments and that killed the instruments process. I then did my instruments command and it worked perfect after that.




回答3:


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.




回答4:


try this

instruments -t /Applications/Xcode.app/Contents/Applications/Instruments.app/Contents/PlugIns/AutomationInstrument.bundle/Contents/Resources/Automation.tracetemplate  <path to your app> -e UIASCRIPT /Users/t-rbudhbhatti/Desktop/Scripts/FT5/SearchByRoute.js -e UIARESULTSPATH /Users/t-rbudhbhatti/Desktop/Scripts/FT5/SearchByRouteResult

instead of app name, you should give the complete path to your app.




回答5:


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

instruments -t /Applications/Xcode.app/Contents/Applications/Instruments.app/Contents/PlugIns/AutomationInstrument.bundle/Contents/Resources/Automation.tracetemplate -w {deviceId} {appname} -e UIASCRIPT /Path/to/Script.js


来源:https://stackoverflow.com/questions/15410465/start-instruments-from-the-command-line

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!