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

Functions in the logging module can be used to provide feedback to the developer concerning the state of the application being automation with UIAutomation, or simply for debugging purposes.

Selector functions

.capture(imageName = Date.now + el.name())

Capture an image of each matched element.

$.fn.capture internally delegates to the mechanic.capture function. This function will capture a screenshot of each element using each's rect. It builds a unique screenshot name using the imageName specified concatenated with each element's name/label.

.log()

Log each matched element.

This function is a simple wrapper around UIAElement's logElement() function.


.logTree()

Log each matched element's element tree.

This function is a simple wrapper around UIAElement's logElementTree() function.

Non-selector functions

mechanic.capture(imageName = Date.now, rect = frontMostApp.mainWindow().rect())

Capture an image of the on-screen rect.

Both args to this function are optional. The captured image's name will simply default to the current datetime. The rect is an object literal of the form {x: 123, y: 45} and defaults to the window rect.


mechanic.log(message, level = "message")

Log the message at the level specified.

Valid log levels are "error", "warn", "debug", and "message". This function logs to the Instruments output.


mechanic.warn(message)

Log the message at the 'warn' level.


mechanic.debug(message)

Log the message at the 'debug' level.


mechanic.message(message)

Log the message at the 'message' level.