Metro automation: getting the Start screen


Visit our Metro UI automation page. This post is deprecated

 

It might sound oddly, but the fact is that I’ve spent several hours in attempts to raise the Start screen. I tried moving the cursor over the lower left corner to get the ListItem, a small image of the Start screen. I tried to move cursor over the lower right corner and along the right side to get the desktop charm. I tries to use SendKeys to send Win (^{ESC}) or Win+C key combinations to the desktop. After all, I simply created an app that is running as another, non-privileged process and is able to send Ctrl+Esc. The solution looks overly complicated, nevertheless it works pretty well.

This was, as an example, one of my wrong solutions:


Get-UIADesktop | Get-UIAPane -Class 'Shell_TrayWnd' | Invoke-UIAControlClick -X 10 -Y 10 | Move-UIACursor -X -3 -Y 100;

Get-UIAListItem -Name 'Start screen' | Invoke-UIAListItemClick;

Okay, what is recommended:

1.) download the UIASendKeys.exe, placed separately for this time

2.) unpack it to a folder of your choice and run the application

It is to be run the whole test session.

3.) run UIAutomationSpy

4.) When you need to raise the Start screen (this can be needed frequently as it’s frightening of any movement over the desktop or flickering of applications that got some changes),  go to your working place, the Script tab, and type the following code:


Get-UIAWindow -n UIASendKeys | Get-UIAButton -Name Start* | Invoke-UIAButtonClick;

This raises the Start screen whenever you need it:

The idea behind this solution is the same that I used for testing of several products: run an application under test in another process and connect to it using inter-process communication (UIAutomation, in other words). This method is used in many test systems, NUnit is the first example that has been recalled.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: