Introduction to UI Automation

Source: Internet
Author: User

Reprinted, Source Address: http://blog.csdn.net/ffeiffei/article/details/6637418

Ms ui automation (Microsoft User Interface automation: UIA) is. net framework3.0 was released together. Although there are various new terms and technologies coming out of the 21st century almost every day, it seems somewhat outdated. A few days ago, a project was ready for use and it was reorganized:

What is Ms UI automation?

Ms ui automation is a substitute for msaa technology: Giving controls and applications better accessibility (accessible), about software accessibility, for more information, see <engineering software for accessibility>. This book, combined with Ms UIA, describes how to make software accessible throughout the entire lifecycle of software development. Back to Ms UIA, in short, it is a few DLL, providing a set of APIs and interfaces, and their corresponding modes, so that software developers can follow this mode to implement the corresponding interface, thus, the software user (not only the customer, but also the tester wants to write some automated test code to complete the business logic related to the program) can better use the software.

Compared with the original msaa: UIA has re-designed a set of architecture and defined a set of unified models for traditional winform and new WPF; its APIs are also relatively simple to use. net Framework 3.0 together, there is also a uispy tool to help you use UIA.

UIA Architecture

Ms uia clearly defines two role: UIA provider is the software itself, mainly the software development personnel according to the corresponding mode to implement the relevant interface, UIA client is an automated script and related dynamic Ive technology applications. From the tester's perspective, it mainly calls the corresponding API to implement the automated test script.

UIA provider: The developer determines the control behavior and implements the corresponding UIA control pattern. For standard controls, UIA is supported by default. For custom controls, you need to implement the behavior of the control corresponding to the interface defined by UIA.

UIA client: the UIA client is much simpler. You only need to call the relevant uia api to complete the automated test script.

For a simple relationship between the two, refer:

UIA mainly has four dll: uiautomationprovider. DLL, which defines interfaces for various behaviors. For example, if a custom control is provided, developers think that it needs to support the dock behavior and implement the idockprovider interface. Uiautomaitonclient. dll defines various control modes, as well as auxiliary condition search classes for better locating controls. Uiautomationcore. dll is used to support the communication between UIA provider and client. Uiautomationclientssideproviders. dll is mainly used to support standard controls of traditional winform. For more information about the relationship, see:

 

Tree Model of UIA

In UIA, every part of the program UI is considered as an automationelement class, which is a tree structure. Desktop is considered as the root of the UIA tree of every Windows based app, from the class definition, we can also see that an automationelement class has a static rootelement attribute.

In the tree structure, a total of three view models are raw view, control view, and content view. Raw view provides the most information, which is also the basis of other views. It is closest to the programming structure of the program. Control view is a subset of raw view, it is most close to the UI structure that the end user can perceive, but does not contain some UIs that cannot interact with the user, such as the listview header and toolbar. Content view is a subset of control view. It only contains controls that can directly interact with users with real information. For example, to accept textbox input on the keyboard, select ComboBox with different values; controls such as lable are not included. You can open uispy to view the differences between the three views for an application. This gives you a more intuitive understanding.

 

UIA Control Pattern

UIA defines a total of 38 pattern types, representing common control behaviors. They also provide specific functional attributes. For UIA provider, what is done is to define the behavior related to the control, find the pattern corresponding to the behavior, and implement the pattern. for the client, access the relevant methods and attributes, to achieve automation. If a control requires valuepattern, the provider and client correspond to the following:

Clients

Provider

Description

Valuepattern

Ivaluepattern

Set or get value

 

UIA Properties

Each property is identified by a number and name. The provider uses a Number ID to determine the property request. The client uses the automationproperty class to obtain the content of a specific property.

 

Events of UIA

UIA uses the subscription model instead of the previous broadcast event model. Four event types are defined: Property Change, Element Action, structure change, and Global Desktop change.

 

Relationship between several key classes

If you use UIA for automated testing, the most commonly used classes are automatonelement, various pattern, and several auxiliary search condition. They are all in the uiautomationclent. DLL system. windows. under Automation namespace:

In the automationelement class, various common control attributes, events, and rootelements are defined. Each attribute is of the automationproperty type, and each event is of the automationevent type, they all inherit from the automationidentifier class.

For each pattern, common methods and attributes supported by the pattern are defined.

 

Several learning links for UIA

Msdn: http://msdn.microsoft.com/en-us/library/ms753107.aspx

An article from msdn also has a detailed example: http://msdn.microsoft.com/en-us/magazine/cc163288.aspx

There is also a blog, hand-held Introduction How to Do automated testing with UIA: http://www.cnblogs.com/kangyi/archive/2009/09/08/1549411.html

Introduction to UI Automation

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.