Start tools from the command line

I went for 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 run Tools from the command line. Sorry, 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

I am currently using Xcode 4.6.

+4
source share
5 answers

In 2014, with Xcode 6.0.1, you would do something like this to run UIAutomation tests on a 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", as in the above snippet to work on the simulator, you must specify the UDID of your device. Then you can omit the long path of the application above and just specify the name of the application. Tools will be able to find it on the device.

Using my example above, but modified for a hypothetical device, it will look like this:

 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 checked when the device is called, so please check it. There is a bit of flexibility in ordering parameters.

I have a tested UI Automation Runner script that works fine for Xcode 6.0.1 and the simulator.

+5
source

I would advise you to take a look at Jonathan's screen-shooter, which he explains about: http://cocoamanifest.net/articles/2013/01/ui-screen-shooter.html . It really helped me understand the simulator, launching tools from the command line and much more. As Jonathan explained, you need to first create an application in order to run something.

Get his sources here: https://github.com/jonathanpenn/ui-screen-shooter and see if this works for you. Then go back to a simple script that will build the application, place it in a convenient place and launch the tools using the application and the desired template.

0
source

It worked for me.

I ran the ps command to see which processes are running. I found that the tools are still working. Then I did killall instruments and killed the instrument. Then I executed the command of my tools, and after that it worked perfectly.

0
source

try it

 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 the name of the application, you must specify the full path to your application.

0
source

I had the same problem, I made the following changes and worked fine for me:

The location of -w udid in the given command has been changed, place it after the tracetemplate path and to the application path, that is, it should be exactly the same as

 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 
0
source

Source: https://habr.com/ru/post/1469247/


All Articles