How to do UI Automation of Metro-Style Apps?

Orion Edwards picture Orion Edwards · May 1, 2012 · Viewed 9.1k times · Source

I've downloaded and installed the windows 8 consumer preview, and I'd like to figure out how to use the UI Automation API's to get data from metro style applications.

Background: I have a lot of automated tests which use the Microsoft UI Automation API's to interact with applications. The scripts are written in IronRuby against .NET 4

Initially, I'd simply like to check if the start menu is visible (and if so, close it)

According to Microsoft, the normal UI Automation API's should be able to access and control metro style applications, but the problem is, I can't figure out how my code can actually access the UI of metro applications? Our normal way of viewing UI automation data is using UISpy, however when I run UI spy under windows 8 and bring up a metro app, there is no mention of it... it seems like metro apps (including the start screen) are walled off from the desktop.

If I can't find the metro apps in UISpy, how can I find what their automation ID's are, and how could I find them from my automated test scripts?

Answer

Steve Rowe picture Steve Rowe · May 3, 2012

A few resources on UI automation which works in Metro style apps:

  • Here is a sample demonstrating it.

  • Here is a blog post explaining it.

  • This is a forum thread on the subject.

    There is nothing about the app that stops traditional UI automation from working correctly. You may have to get updated tools to view the Metro style apps. Some ship with the Consumer Preview. Look for inspect.exe.