Search code examples
iphoneiosloggingxcode-instruments

Having custom logs on instruments iOS stdout from automation script


I am automating my tests using the instruments CLI.

Now, the tests require starting another process once some specific action in my app is completed.

i.e lets say the application does

singin --> create account --> post an update --> singout

Once the signout is done, I want to take a memory snapshot of my app, for which I would use the top/ps command.

What I want to do is, log something specific on the output once the singout action is done. e.g "Unique String ....... Singout complete ..... Unique String"

Another script would keep checking the output for logs and see if this string occurred and start some other process when it does.

Now the actual question, would doing a console.log(string) in my automation javascript put in on the stdout of instruments? If now what command (or API) can I use to have custom logs on the stdoud of instruments CLI?


Solution

  • I think this is what you're searching for:

    UIALogger.logDebug("a log message");

    Put this in your script, and a log message will get written on Instruments' Editor Log. I didn't get it in the Trace Log yet however.

    You can find more information on this in this documentation page: ~/Library/Developer/Shared/Documentation/DocSets/com.apple.adc.documentation.AppleiOS6.0.iOSLibrary.docset/Contents/Resources/Documents/index.html#documentation/DeveloperTools/Reference/UIAutomationRef/Introduction/Introduction.html

    Language & Utilities > UI Automation JavaScript Reference

    You may also look at the UIALogger Class Reference: Core Services Layer > UIAutomation > UIALogger Class Reference

    And you may want to give a look to IMAT which seems to provide a great deal of automatization nirvana too!