The UIAElementArray class supports operations with arrays containing multiple UIAElement objects. You can search the array by name or key/value pairs, or by custom criteria that you specify using a predicate. For detailed information about using predicates, see Predicates Programming Guide.
UIAElementArray supports the traditional shorthand syntax for accessing items in native JavaScript objects:
dot reference by element name, for example:
var okButton = buttons.OK;
bracket reference by index, for example:
var firstElement = elements[0];
bracket reference by element name, for example:
var helloWorldText = staticTexts["Hello World"];
It is important to note one potentially confusing limitation in using bracket references by element name. If the name of an element happened to be a number, JavaScript would interpret that name as an index, likely yielding incorrect results. For example, consider this array:
var elements = ["DoIt", "Cancel", "1"];
If you attempt to access the third element by name with the bracket reference syntax:
elements()["1"]
it is actually treated as a reference to the first element, yielding the first element (named “DoIt”) instead. In cases where this problem might occur, you should use the dot reference syntax instead:
elements().firstWithName("1")
Returns the number of user interface elements the UIAElementArray
represents.
(Number) length
Returns the first element in the array with this name.
(UIAElement) firstWithName(String name)
A string whose value is the name of the element match on.
Returns the first element in the array matching the given criteria.
(UIAElement) firstWithPredicate(PredicateString predicateString)
A predicate specifying the criteria to match.
For detailed information about predicate matching, see Predicate Programming Guide.
Returns the first element in the array with a value that matches the property key.
(UIAElement) firstWithValueForKey(NotTyped value, String key)
Returns all elements in the array matching the given; predicate matching follows the same rules as NSPredicate.
(UIAElementArray) withPredicate(PredicateString predicateString)
Returns all elements in the array with a value that matches the property key.
(UIAElementArray) withValueForKey(NotTyped value, String key)
A string specifying the value that the specified property, if it exists, should match.
A string specifying the property to test for.
UIAElementNil
Returned by a function with return type UIAElement
or UIAElementArray
if the requested element is not available after the timeout
grace period you specify. This mechanism allows your scripting expressions to complete even if an intermediate function in the expression fails temporarily during the grace period. For example, the following code does not raise an exception if the navigation bar does not exist; instead it returns UIAElementNil
.
|
Last updated: 2010-06-01