UIAHost Class Reference


The UIAHost class allows your script to exercise limited control over the Automation instrument process running on the host computer.

For an explanation of how to use this and related classes, see “Automating UI Testing” in Instruments User Guide.


Performing a Task on the Host Computer



Executes a task from the Automation instrument process running on the host.

(object) performTaskWithPathArgumentsTimeout(path, args, timeout)

The pathname of the code to run, relative to the root level of the host’s boot drive.


An array that specifies the arguments for the code to be run.


The length, in seconds, of the grace period in which the task is expected to execute, before script execution resumes.


The process executes from within the context of the Instruments application parent process. The code below runs the echo command to display “Hello World” with a grace period of 5 seconds.

The returned object contains the properties exitCode, stdout, and stderr. The example uses these properties to capture the exit code, standard output stream, and standard error stream, displaying each in a log message with a debug severity level.

var target = UIATarget.localTarget();
var host = target.host();
var result = host.performTaskWithPathArgumentsTimeout("/usr/bin/echo", ["Hello World"], 5);
UIALogger.logDebug("exitCode: " + result.exitCode);
UIALogger.logDebug("stdout: " + result.stdout);
UIALogger.logDebug("stderr: " + result.stderr);