Take the 2-minute tour ×

I'm trying to send some arguments to UI Automation scripts through the command-line where the scripts could grab those arguments and execute some specific test cases conditionally based on those received arguments. Is there a way to do this? I saw in the manual page for the instruments command that it mentioned something about arguments.

argument ~ Command line argument to be sent to the launched process (You may specify more than one)


... Or should I just split the conditional code into different files and have some external shell scripts to handle changing of the file name to be executed through the instruments command-line instead?

share|improve this question

2 Answers 2

up vote 0 down vote accepted

Alas, not at this time. The command line arguments get sent to the application itself (which is the launched process), but the automation script has no access to any command line arguments or even environment variables for that matter. Please file a bug report with Apple about this. The more they hear about it, the higher on their priority list it will go.

Your suggestion to have a shell script execute different automation scripts is what I do and it works well.

share|improve this answer

My workaround on this problem uses an exported environment variable and the UIATarget.localTarget().host().performTaskWithPathArgumentsTimeout(...) command to acquire that parameter.

  1. Export an environment variable in the shell

    export PARAM_TO_UIA="theParameterValue"

  2. Launch instruments from the same shell

  3. Acquire the parameter inside your UIAutomation script

    var result = target.host().performTaskWithPathArgumentsTimeout("/usr/bin/printenv" , ["PARAM_TO_UIA"], 5);

    var parameter = result.stdout.substring(0,result.stdout.length-1);

Last command removes '\n' from the end of the result.stdout string.

share|improve this answer

Your Answer


