15
Automatic Testing using the Coded UI Framework Lesson 5 UIMap Omer Karpas

Coded ui - lesson 5 - ui map

Embed Size (px)

Citation preview

Page 1: Coded ui - lesson 5 - ui map

Automatic Testing using the Coded UI Framework

Lesson 5 – UIMap

Omer Karpas

Page 2: Coded ui - lesson 5 - ui map

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.

Page 3: Coded ui - lesson 5 - ui map

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.

Page 4: Coded ui - lesson 5 - ui map

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

add all the relevant classes.

Page 5: Coded ui - lesson 5 - ui map

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

area.

Page 6: Coded ui - lesson 5 - ui map

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

Page 7: Coded ui - lesson 5 - ui map

Params Class Anatomy The Params Classes contain only Fields.

They group all the data that is changeable.

Examples:

Expected values

Paths

Etc..

Page 8: Coded ui - lesson 5 - ui map

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

Each class here is a single control mapping.

Page 9: Coded ui - lesson 5 - ui map

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

Page 10: Coded ui - lesson 5 - ui map

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.

Page 11: Coded ui - lesson 5 - ui map

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

Page 12: Coded ui - lesson 5 - ui map

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

Page 13: Coded ui - lesson 5 - ui map

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.

Page 14: Coded ui - lesson 5 - ui map

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

want to us it.

Page 15: Coded ui - lesson 5 - ui map

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.