iOS Reference Library Apple Developer
Search

UIAElement Class Reference

Overview

The UIAElement class is the superclass for all user interface elements.

Tasks

Determining Element Positioning

Determining and Manipulating Element Hierarchy

Gestures and Actions

These methods allow you to effect the common gestures and actions a user can perform through the user interface. Options are available for use with some of these methods to give you flexibility in defining and varying the attributes of the gesture or action to be performed.

Determining Element State

Use these methods to determine whether an element is still valid.

Identifying Elements

Logging Element Information

Methods

activityIndicators

Returns a UIAElementArray of UIAActivityIndicator objects contained by the specified object.

(UIAElementArray) activityIndicators()

ancestry

Returns a UIAElementArray of objects that are parent to the specified object.

(UIAElementArray) ancestry()

buttons

Returns a UIAElementArray of UIAButton objects contained by the specified object.

(UIAElementArray) buttons()

checkIsValid

Returns the specified elements’ current validity status.

(Boolean) checkIsValid()

Discussion

Use this method to determine whether the user interface element represented by the specified UIAElement currently exists. This requires a call to the underlying Accessibility framework to ensure the validity of the result.

See Also
  • isValid

doubleTap

Double-taps the specified element.

(undefined) doubleTap()

dragInsideWithOptions

Drags within the bounds of an element.

(undefined) dragInsideWithOptions(Object options)

Parameters
options

A dictionary that specifies characteristics of the gesture. Valid keys are as follows:

touchCount

The number of touches to use in the specified gesture. (Effectively, the number of fingers a user would use to make the specified gesture.) The default touch count value is 1.

duration

The length of hold time for the specified gesture. The default duration value for a tap is 0. The default value for touch-and-hold gestures (such as drag, pinch open, and pinch close) is 1.

startOffset

The first offset to use for a multiple-point gesture. The default value is {x:0.0, y:0.0}. See the discussion for details.

endOffset

The last offset to use for a multiple-point gesture. The default value is {x:0.0, y:0.0}. See the discussion for details.

Discussion

You can use offsets to achieve finer precision in specifying the hitpoint within the rect for the specified element. The offset comprises a pair of x and y values, each ranging from 0.0 to 1.0. These values represent, respectively, relative horizontal and vertical positions within the rect, with {x:0.0, y:0.0} as the top left and {x:1.0, y:1.0} as the bottom right. Thus, {x:0.3, y:0.6} specifies a position just below and to the left of center, and {x:1.0, y:0.5} specifies a position centered vertically at the far right.

This example performs a slow drag within the target element from left edge to right edge, just below the top:

target.dragInsideWithOptions({startOffset:{x:0.0, y:0.1}, endOffset:{x:1.0, y:0.1}, duration:1.5});

elements

Returns a UIAElementArray of objects contained by the specified object.

(UIAElementArray) elements()

flickInsideWithOptions

Flicks within the bounds of an element.

(undefined) flickInsideWithOptions(Object options)

Parameters
options

A dictionary that specifies characteristics of the gesture. Valid keys are as follows:

touchCount

The number of touches to use in the specified gesture. (Effectively, the number of fingers a user would use to make the specified gesture.) The default touch count value is 1.

startOffset

The first offset to use for a multiple-point gesture. The default value is {x:0.0, y:0.0}. See the discussion for details.

endOffset

The last offset to use for a multiple-point gesture. The default value is {x:0.0, y:0.0}. See the discussion for details.

Discussion

You can use offsets to achieve finer precision in specifying the hitpoint within the rect for the specified element. The offset comprises a pair of x and y values, each ranging from 0.0 to 1.0. These values represent, respectively, relative horizontal and vertical positions within the rect, with {x:0.0, y:0.0} as the top left and {x:1.0, y:1.0} as the bottom right. Thus, {x:0.3, y:0.6} specifies a position just below and to the left of center, and {x:1.0, y:0.5} specifies a position centered vertically at the far right.

This example performs a flick just above the bottom edge of the target element, from center to right edge:

target.flickInsideWithOptions({startOffset:{x:0.5, y:0.9}, endOffset:{x:1.0, y:0.9}});

hasKeyboardFocus

Returns true if the specified element is the receiver of keyboard input.

(Boolean) hasKeyboardFocus()

hitpoint

Returns the screen position to tap for the specified element.

(Point) hitpoint()

images

Returns a UIAElementArray of UIAImage objects contained by the specified object.

(UIAElementArray) images()

isEnabled

Returns the enabled status of the specified element.

(Boolean) isEnabled()

isValid

Returns the specified element’s validity status as of the most recent access.

(Boolean) isValid()

Discussion

Use this method to determine whether the user interface element represented by the specified UIAElement existed as of the last attempt to access it. To be certain that the element exists, use checkIsValid instead.

See Also
  • checkIsValid

isVisible

Returns true if the user interface element represented by the specified element is visible on screen.

(Boolean) isVisible()

links

Returns a UIAElementArray of UIALink objects contained by the specified object.

(UIAElementArray) links()

logElement

Logs information about this element

(undefined) logElement()

logElementTree

Logs information about this element and all of its sub-elements.

(undefined) logElementTree()

name

Returns a string containing the name attribute of the element.

(String) name()

pageIndicators

Returns a UIAElementArray of UIAPageIndicator objects contained by the specified object.

(UIAElementArray) pageIndicators()

parent

Returns the UIAElement object that contains the specified element.

(UIAElement) parent()

pickers

Returns a UIAElementArray of UIAPicker objects contained by the specified object.

(UIAElementArray) pickers()

progressIndicators

Returns a UIAElementArray of UIAProgressIndicator objects contained by the specified object.

(UIAElementArray) progressIndicators()

rect

Returns the position of the object on the main screen.

(Rect) rect()

scrollToVisible

Scrolls until the specified element is visible in a container view.

(undefined) scrollToVisible()

Discussion

Use this method with tables and web views.

scrollViews

Returns a UIAElementArray of UIAScrollView objects contained by the specified object.

(UIAElementArray) scrollViews()

searchBars

Returns a UIAElementArray of UIASearchBar objects contained by the specified object.

(UIAElementArray) searchBars()

secureTextFields

Returns a UIAElementArray of UIASecureTextField objects contained by the specified object.

(UIAElementArray) secureTextFields()

segmentedControls

Returns a UIAElementArray of UIASegmentedControl objects contained by the specified object.

(UIAElementArray) segmentedControls()

sliders

Returns a UIAElementArray of UIASlider objects contained by the specified object.

(UIAElementArray) sliders()

staticTexts

Returns a UIAElementArray of UIAStaticText objects contained by the specified object.

(UIAElementArray) staticTexts()

switches

Returns a UIAElementArray of UIASwitch objects contained by the specified object.

(UIAElementArray) switches()

tableViews

Returns a UIAElementArray of UIATableView objects contained by the specified object.

(UIAElementArray) tableViews()

tap

Taps the specified element.

(undefined) tap()

tapAndHold

Touches the specified element and holds for the specified duration.

(undefined) tapAndHold(Number duration)

Parameters
duration

The length of time to hold the touch on the element, in seconds.The default duration value for a tap is 0. The default value for touch-and-hold gestures (such as drag, pinch open, and pinch close) is 1.

textFields

Returns a UIAElementArray of UIATextField objects contained by the specified object.

(UIAElementArray) textFields()

textViews

Returns a UIAElementArray of UIATextView objects contained by the specified object.

(UIAElementArray) textViews()

touchWithOptions

Performs the specified gesture on the specified element using a dictionary to specify gesture attributes.

(undefined) touchWithOptions(Object options)

Parameters
options

A dictionary that specifies characteristics of the gesture. Valid keys are as follows:

tapCount

The number of taps that compose the specified gesture. The default value is 1 (single tap).

touchCount

The number of touches to use in the specified gesture. (Effectively, the number of fingers a user would use to make the specified gesture.) The default touch count value is 1.

duration

The length of hold time for the specified gesture. The default duration value for a tap is 0. The default value for touch-and-hold gestures (such as drag, pinch open, and pinch close) is 1.

offset

The offset to use for the specified tap gesture. The default offset value is {x:0.0, y:0.0}. See the discussion for details.

Discussion

For example, you could specify a triple tap with two fingers at the center of the screen (on an iPhone in portrait orientation), as follows:

target.tapWithOptions({x:160, y:240}, {touchCount:2, tapCount:3});

You can use offsets to achieve finer precision in specifying the hitpoint within the rect for the specified element. The offset comprises a pair of x and y values, each ranging from 0.0 to 1.0. These values represent, respectively, relative horizontal and vertical positions within the rect, with {x:0.0, y:0.0} as the top left and {x:1.0, y:1.0} as the bottom right. Thus, {x:0.3, y:0.6} specifies a position just below and to the left of center, and {x:1.0, y:0.5} specifies a position centered vertically at the far right.

twoFingerTap

Performs a two-finger (two-touch) tap on this element.

(undefined) twoFingerTap()

value

Returns a string containing a value attribute specific to the type of element.

(String) value()

Discussion

For example, a switch has a value of 1 for ON an 0 for OFF.

waitForInvalid

Waits for the specified element to become invalid.

(Boolean) waitForInvalid()

Discussion

Waits for the user interface element represented by the specified UIAElement to become invalid. Uses the current timeout value for the wait time interval.

webViews

Returns a UIAElementArray of UIAWebView objects contained by the specified object.

(UIAElementArray) webViews()

withName

Returns a UIAElement if its name attribute matches a specified string.

(UIAElement) withName(String name)

Parameters
name

A string containing the name to test for.

Discussion

Tests if the name attribute of the element has the given string value. If the match fails, the test is retried until the current timeout expires.

withPredicate

Returns a UIAElement if it matches specified criteria.

(UIAElement) withPredicate(PredicateString predicateString)

Parameters
predicateString

A string specifying the match criteria.

Discussion

Uses the specified predicate string to test for a match. If the match fails, the test is retried until the current timeout expires. See Predicate Programming Guide for information about using predicates.

withValueForKey

Returns a UIAElement if it has the specified property with the specified value.

(UIAElement) withValueForKey(NotTyped value, String key)

Parameters
value

A string specifying the value that the specified property, if it exists, should match.

key

A string specifying the property to test for.

Discussion

Tests if the element has a specified property with the specified value. If the match fails, the test is retried until the current timeout expires.




Last updated: 2010-05-27

Did this document help you? Yes It's good, but... Not helpful...