15.9. iPhone Convenience API

[Important]iPhone-specific

The iPhone Convenience API is only available for the Squish for iPhone editions.

[Note]Terminology

The Squish documentation uses the term widget when referring to GUI objects. Mac OS X developers may be more familiar with the term view for this concept.

Here are some quick links to the iPhone Convenience API's functions:

clickObject(objectOrName);

clickObject(objectOrName, x, y);

This function performs a tap on the specified objectOrName widget.

By default the objectOrName widget is clicked in the middle, but this can be overridden by passing object-relative coordinates, x and y.

doubleClick(objectOrName);

doubleClick(objectOrName, x, y);

This function performs a double tap on the specified objectOrName widget.

By default the objectOrName widget is double-tapped in the middle, but this can be overridden by passing object-relative coordinates, x and y.

installEventHandler(eventName, handlerFunctionName);

This function installs a global event handler. The script function named in handlerFunctionName (which must be passed as a string, not as a function reference), will be called when an event of the eventName type occurs.

The eventName can be the name of any of the following event types:

When the AlertOpened event occurs, the function named in handlerFunctionName is called. The function is passed one argument—the alert object that was opened (i.e. an object of type UIAlertView).

For examples see How to Use Event Handlers (Section 14.8).

[Important]The AUT Must be Running

The installEventHandler function will only work if it is called after the AUT has been started (e.g., using the startApplication function).

selectPickerRowInComponent(objectOrName, row, componentIndex);

This function selects an item in the specified objectOrName UIPickerView object (a picker widget is a spinning-wheel control that allows users to choose things such as dates).

The row is the 0-based index position of the row that should be selected. The componentIndex is the 0-based index position of the component (or column) that contains the row.

touchAndDrag(objectOrName, x, y, dx, dy);

This function performs a dragging gesture (also known as a panning gesture). The gesture starts at position x and y relative to the objectOrName widget and continues for dx pixels to the righ (left if the amount is negative), and dy pixels down (up if the amount is negative).

type(objectOrName, text);

This function types the specified text (as if the user had entered the text using the on-screen keyboard) into the objectOrName editable widget. If the text is surrounded by angle brackets (<>), it is interpreted as a special key, e.g "<Return>". The input is case-sensitive, so type(object, "R") is different from type(object, "r").

Currently the following special keys are supported: