Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
UIA shipped with .Net 3.0 did not receive the attention it really deserves . UIA can be used to automate native windows applications , WPF applications as well as Silverlight applications . There are two things one must consider when automating
- Reference to the Automation Element
- The user pattern to be invoked
That's all . The AutomationElement.RootElement represents the desktop , all other UI elements are children of the desktop . We need to search the tree to find the required automation element . The tree hierarchy can be found by a tool called UISpy that comes as a part of Windows SDK . Then we need to determine what pattern is to be used , eg combobox uses ExpandCollapse Pattern , textbox uses TextPattern and button uses Invoke pattern . (MSDN has all information )
Lets see how its done using 2 simple automation actions
Action 1 : Opening notepad and putting some junk text in it
|
Action 2 : Walk through all the elements in a Silverlight page
The XAML file of the Silverlight page is as follows
|
The code for automating it is as follows
|