iOS Developer Library

Developer

UIAHost Class Reference

Options
Deployment Target:

On This Page

UIAHost

Inherits From


Not Applicable

Conforms To


Not Applicable

Import Statement


Not Applicable Not Applicable

Availability


Available in iOS 5.0 and later

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.

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

    Declaration

    JavaScript

    (object) performTaskWithPathArgumentsTimeout(path, args, timeout)

    Parameters

    path

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

    args

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

    timeout

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

    Discussion

    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("/bin/echo", ["Hello World"], 5);
    • UIALogger.logDebug("exitCode: " + result.exitCode);
    • UIALogger.logDebug("stdout: " + result.stdout);
    • UIALogger.logDebug("stderr: " + result.stderr);

    Availability

    Available in iOS 5.0 and later