Skip to content
jaykz52 edited this page Mar 27, 2012 · 6 revisions

Functions in the data module are used to interrogate elements that are UIAutomation-aware, as well as the properties of the application itself. This module is powerful when combined with a testing framework such as jasmine or tuneup_js!

Selector functions

.name()

Get the first matched element's name value.


.label()

Get the first matched element's label value.


.value()

Get the first matched element's value.


.isFocused()

Returns whether or not the first matched element has keyboard focus.


.isValid(certain = false)

Checks for the existance of the first matched element.

This method takes an optional arg that specifies whether to use UIAElement's isValid() or checkIsValid() function. pass true to invoke the more rigorous checkIsValid()

Non-selector functions

mechanic.version()

Gets the build version of the application.


mechanic. bundleId()

Gets the application's bundle ID (in reverse DNS style).


mechanic.prefs(prefsOrKey)

Gets or sets application preferences.

This function can act as a getter or setter depending on the arg passed to it. To get a particular preference by key, simply pass in the key. To modify the a preference's value, an object literal of key/value pairs can be passed in. The object literal will be iterated over and each preference will be set accordingly. For example, the following code will set the name preference to 'John' and the hardDelete preference to true:

$.prefs({ name: 'John', hardDelete: true });