Alex Stone
Alex Stone

Reputation: 47348

iOS8 - is there an example of UIAutomation framework from code?

I've been reading about UI automation using instruments, and the old documentation suggested that this is done using a javascript library to access frontmost app, then access UI view hierarchy.

I see that an iOS8 device has "Enable UI automation" option in the developer menu in settings. I also see that there's some documentation on the UIAutomation framework in iOS8, which seems to me like it allows to do UIAutomation from code.

Are there examples of using iOS8 UIAutomation framework from code that I can look at to understand if this is the framework for me?

I see this screen when looking for the info on UIAutomation framework, and I think it confused me into thinking that it is available in Obj-c or Swift, because of buttons on top. Can someone confirm that this framework is NOT available in either swift or Obj-c and is still a javascript framework?

.

enter image description here

Upvotes: 4

Views: 2348

Answers (3)

Ian
Ian

Reputation: 11810

We have UIAutomation working in iOS 8 using the Illuminator framework (which I wrote), and use it in our CI. It is a set of extensions to the Javascript that UIAutomation provides.

Currently, Javascript is the only language for UIAutomation that Apple supports.

Upvotes: 1

user3521372
user3521372

Reputation: 21

You should look into Subliminal. It's a testing framework which is built on top of UIAutomation that allows you write your tests in Objective C or Swift.

https://github.com/inkling/Subliminal

Upvotes: 2

idStar
idStar

Reputation: 10794

I believe UIAutomation is still a JavaScript only testing framework. We would have heard otherwise at WWDC or in the release notes, if any other language was supported.

Concrete evidence of this however, is that the "Automation" Instrument used when profiling an app has no language drop downs to indicate another language is possible (like say, you do when creating a new class in Xcode and there's a drop-down for Swift and Objective-C).

If you use the automatic recording functionality built into the Automation Instrument, the code you see is JavaScript. The lack of options to select another language is telling. Instruments did get a minor visual tweak with Xcode 6 too, and this fact did not change.

The UIAutomation framework, sadly doesn't seem to get a lot of love of late (not much of anything has changed since the release in 2010 with iOS4, leading some to speculate there's a major revamp in the works or it's being forgotten).

To see what JavaScript code looks like that's aimed at writing tests for iOS, check out Alex Vollmer's Tuneup JS library: http://www.tuneupjs.org. His library provides a higher level abstraction, while still in JavaScript, over Apple's UIAutomation JavaScript classes.

He has a sample project linked there that runs tests on Apple's own UICatalog example application.

Using a library like Tuneup JS is a better way to go than the more primitive JavaScript classes that Apple provides, which are really just a starting point.

Upvotes: 2

Related Questions