RSS

UI Automation Library

20 Mar

Original article here.

MSDN article explain how to automate test windows UI applications using UI Automation Library.

// .. Launch Calc Process

Process[] processes = Process.GetProcessesByName("calc");

AutomationElement _mainWindow=
  AutomationElement.FromHandle(processes[0].MainWindowHandle);

AutomationElement lButton =_mainWindow.FindFirst(
        TreeScope.Children,
        new PropertyCondition(AutomationElement.NameProperty, "1"));

((InvokePattern)(lButton .GetCurrentPattern(InvokePattern.Pattern))).Invoke();

AutomationElement lScreen = _mainWindow.FindFirst(
          TreeScope.Children,
          new PropertyCondition(AutomationElement.ControlTypeProperty,
          ControlType.Edit));

string lDisplayText =
  (string)lScreen.GetCurrentPropertyValue(ValuePattern.ValueProperty);

Assert.Equals("1",lDisplayText);

processes [0].Close();

 
Leave a comment

Posted by on March 20, 2009 in Dotnet/C#

 

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: