Skip to main content

Posts

Showing posts from November, 2012

UiAutomator and Watchers: Adding Async Robustness to UI Automation

"I'm looking over your shoulder... only because I've got your back." ~ Stephen Colbert
After my recent UiAutomator review a user brought up an important question about the use of UiWatcher. The watchers serve as async guardians of the test flow, making sure the odd dialog window doesn't completely frustrate your tests. Having a tool that automatically watches your back when you're focused on the functional flow of your tests is awesome. 100% pure awesomesauce. Since the API documentation on watchers is scant and the UI Testing tutorial on the Android dev guide doesn't cover their use in depth, I figured I should add a post here that goes over a simple scenario demonstrating how to use this fundamentally important UI automation tool.

In my example code below, I'm using uiautomator to launch the API Demo app (meaning run this against an Emulator built in API level 17 - I used the Galaxy Nexus image included in the latest ADT and platform tools). The te…

UIAutomator Redux: WebViews still opaque

Last time I wrote a quick review of Android's new UIAutomator tool. In that review I tried to cover it as a comparison between Android's JUnit and MonkeyRunner tools which it seems to be designed to bridge. One area I left out of my review was whether it provides deep access within a webView. This question was brought up by a Google+ user in the Android Developers' post notifying us all of the release of these new tools and I figured it deserved some investigation.

My expectation was that WebViews would remain opaque to the tool since its construction of the XML of a given view hierarchy seems like an extension of Hierarchy Viewer and thus shared its limitations. My experiment was to use the Netflix app since it is a well known app and is built making very heavy use of Android's WebView. Netflix does this so that they can deliver updates to devices through a single app rather than customizing their apps for multiple screen sizes. When I first bought my Samsung Galaxy N…

UiAutomator.jar: What happened when Android's JUnit and MonkeyRunner got drunk and hooked up

"Drunkenness does not create vice; it merely brings it into view" ~Seneca
So Jelly Bean 4.2 landed with much fanfare and tucked in amongst the neat new OS and SDK features (hello, multi-user tablets!) was this little gem for testers: UiAutomator.jar. I have it on good authority that it snuck in amongst the updates in the preview tools and OS updates sometime around 4.1 with r3 of the platform. As a code-monkey of a tester, I was intrigued. One of the best ways Google can support developers struggling with platform fragmentation is to make their OS more testable so I hold high hopes with every release to see effort spent in that area. I have spent a couple days testing out the new UiAutomator API and the best way I can think of describing it is that Android's JUnit and MonkeyRunner got drunk and had a code baby. Let me explain what I mean before that phrase sinks down into "mental image" territory.

JUnit, for all its power and access to every interface, every s…