Xcode Instruments CL multiple devices - ios

Under OSX Lion 10.7.x i am running xcode 4.3.1
I am trying to run multiple instances of instruments UI Automation in different terminal windows like:
bash-3.2$instruments -w <UDID>
-t Automation.tracetemplate /my.app
-e UIASCRIPT /test.js
-e UIARESULTSPATH /log
Problem is that if i start terminal1 and direct after this, let terminal2 run instrument. It stops the previous test in terminal1.
This used to work fine under 10.6.

Related

Having an issue Running instruments using terminal

I have used this below command to run automation template using instruments.
instruments -t /Applications/xcode5.0.2/Xcode.app/Contents/Applications/Instruments.app/Contents/PlugIns/AutomationInstrument.bundle/Contents/Resources/Automation.tracetemplate ~/Library/Application\ Support/iPhone\ Simulator/7.1/Applications/93F12976-0667-4180-904A-95ECA172C78C/myapp.app -e UIASCRIPT /Users/myUserName/Desktop/TestScript.js
This command is able to open the simulator and my app in the simulator but, its not running the TestScript.js file, because when this file is loaded into instruments its adding up escape sequences in my code, which is ruining my code and not allowing to run the script.
did anybody face this issue before?
Or any body has any suggestion on running instruments using terminal.

How can I set the path to Instruments on Appium?

I'm trying to run Appium for an iOS application, but it seems that the path to instruments is invalid. How can I set it? Is there an environment variable I should use? Or some argument? Even I could change that in the source code it would be useful for me :)
Here's the relevant part of the log I receive from Appium:
info: instruments is:
info: [INSTSERVER] Instruments socket server started at /tmp/instruments_sock
info: Spawning instruments with command: -t /usr/local/lib/node_modules/appium/app/uiauto/Automation.tracetemplate /var/folders/rd/z5t93lfj0cx0wm2_hqmthnkr0000gn/T/TestApp.app -e UIASCRIPT /usr/local/lib/node_modules/appium/app/uiauto/bootstrap.js -e UIARESULTSPATH /tmp/appium-instruments/
Thanks!
You can use sudo xcode-select --switch /path/to/Xcode.app to select which version of Xcode you'd like to use with appium.
Ok, After some digging in the code it appears Appium takes its "Instruments" path by using the command xcrun -find instruments.
xcrun itself has cache, so if you changed/removed xcode you should probably run
xcrun -kill-cache -find instruments
This will clear the cache, but will not necessarily point xcrun to the right path. In order to do so you should add the environment variable DEVELOPER_DIR to point to the Xcode developer directory, e.g. /Applications/Xcode.app/Contents/Developer.

UIAutomation through command line on a real device

I know starting from Xcode 4.2 it is possible to run UIAutomation scripts through command line. I've tried this and is working perfectly fine for me in simulator. I'd like to know how to get this run in an actual device.I searched and got the command for running on device as,
instruments -w <device_id> -t /Developer/Platforms/iPhoneOS.platform/Developer/Library/Instruments/PlugIns/AutomationInstrument.bundle/Contents/Resources/Automation.tracetemplate
application -e UIASCRIPT
script -e UIARESULTSPATH <results path>
What exactly should I give in the application, is it the path to ipa or something else?
Advance Thanks
You need to give it the path to the .ipa file. It actualy only needs the app name so you can just pass in the app name.
Very Important : The app needs to be installed on the device, Instruments will not install the app on the device, it will only run a installed app on the device

Instruments doesn't continue after running from command line

When I run Instruments from the command line using this script
instruments -w <DEVICE_ID> -t /Applications/Xcode.app/Contents/Applications/Instruments.app/Contents/PlugIns/AutomationInstrument.bundle/Contents/Resources/Automation.tracetemplate <PATH_TO_APP> -e UIASCRIPT <PATH_TO_SCRIPT> -e UIARESULTSPATH <RESULTS_PATH>
The app opens on the device but doesn't run the script.
The Terminal cursor moves to the next line and it looks like it just freezes
You need to sign your app with a Developer Profile. The app wont run from the command line if you sign it with a Enterprise Profile

Automation testing with instruments on device

I am trying to follow this post to run UIAutomation scripts on iOS devices from command line, but i can't make it work.
This is the command i am currently using :
instruments -t /Applications/Xcode.app/Contents/Applications/Instruments.app/Contents/PlugIns/AutomationInstrument.bundle/Contents/Resources/Automation.tracetemplate /Users/X/Library/Developer/Xcode/DerivedData/TestiPhoneAutomation2-dyufpxsavtdqkybpagcoawdudzid/Build/Products/Debug-iphoneos/TestiPhoneAutomation2.app -e UIASCRIPT "/Users/X/Workspaces/TestiPhoneAutomation/test2.js" -e UIARESULTSPATH "/Users/X/Workspaces/TestiPhoneAutomation2/" -w 80bf5b...UDID...dfb52543 -v
It works well on simulator (replacing the Debug-iphoneos by Debug-iphonesimulator, it also ignore the -w in this case), but if i launch it using an application compiled for device it crash (i tried with release and debug, i get the same result).
The error i'm getting is :
posix spawn failure; aborting launch (binary ==
/Users/X/Library/Developer/Xcode/DerivedData/TestiPhoneAutomation2-dyufpxsavtdqkybpagcoawdudzid/Build/Products/Debug-iphoneos/TestiPhoneAutomation2.app/TestiPhoneAutomation2).
2012-10-03 12:10:36.609 instruments[76151:1603] Recording cancelled :
At least one target failed to launch; aborting run Instruments Trace
Error : Failed to start trace.
I got this same error, but I didn't have multiple copies of Instruments running. I got this working by putting the -w UDID arguments before the application, and only using the name of the application (with the application already deployed to the device).
The command line I used is the following (with Xcode 4.6):
instruments -t /Applications/Xcode.app/Contents/Applications/Instruments.app/Contents/PlugIns/AutomationInstrument.bundle/Contents/Resources/Automation.tracetemplate -w <device_id> <app_name> -e UIASCRIPT <path_to_script> -e UIARESULTSPATH <path_to_results>
Pls check the sequence of UDID in command line in fact for all parameters also run on debug version of build only. Hope this works, because its working for me.
For anyone else having this problem, I'll explain what worked for me and how I solved this.
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.

Resources