Coded ui - lesson 5 - ui map

Post on 17-Jul-2015

211 views 1 download

Tags:

Transcript of Coded ui - lesson 5 - ui map

Automatic Testing using the Coded UI Framework

Lesson 5 – UIMap

Omer Karpas

UIMap files The UIMap file is acctually 3 files:

UIMap.uitest – is an xml file.

UIMap.cs

UIMap.Designer.cs

The file is an automatic generated file that is re-written each time the Coded UI Test Builder is used, thus it cannot be manually changed.

UIMap.Designer.cs Anatomy This file is empty until you record something with the

Coded UI Test Builder.

We will now analyze the UIMap.Designer.csgenerated in Lesson 3 – Calculator example.

UIMap.Designer.cs Anatomy The first section of the file is the Using area were we

add all the relevant classes.

UIMap.Designer.cs Anatomy The second section is the Methods (Implementation)

area.

UIMap.Designer.cs Anatomy The third section is the Parameters Methods.

Params Class Anatomy The Params Classes contain only Fields.

They group all the data that is changeable.

Examples:

Expected values

Paths

Etc..

UIMap.Designer.cs Anatomy The forth section is the Controls mapping area.

Each class here is a single control mapping.

Control Mapping Class Anatomy Lets analyze the Control Mapping Class structure.

Here we have two controls mapping the Calculator main window and the number 2 mapping

Control Mapping Class Anatomy We see that there is a small difference is their

Constractor. This is because the calculator main window is the first mapped object. Whereas the number 2 is searched under it, so it gets its “father” UITestControl to search under it.

Control Mapping Class Anatomy The class name should be a name that will help us

identify it easily.

The class inherits the base class of the control it is mapping. Examples:

abcButton : WinButton

abcWPFButton : WpfButton

abcWPFList : WpfList

Control Mapping Class Anatomy Search Criteria region is where we add all the

properties we have of the control until we can uniquely map it.

Examples:

WinButton.PropertyNames.ControlId

WpfButton.PropertyNames.AutomationId

Control Mapping Class Anatomy The Properties and Fields regions contains all the child Controls

Mapping Classes.

In our case we have here a property for the number 2 mapping class.

Control Mapping Class Anatomy This way we do not search for the control each time we

want to us it.

Control Mapping Class Anatomy Another type of Property is a lowest “son” Control. In

those cases we add the Search Criteria to Property.

In this case we search for a WinButton.