This is a CodedUI blog which serves as a - One stop solution blog for all CodedUI related information.
Hope you enjoy this.
If anyone has any information it can be shared and also if any improvements can be made please let me know.
Few of the topics can be found in other blogs. My main moto is to share knowledge and also collecting the information
Monday, 2 June 2014
Writing CodedUI code without recording and playback
Main uses of writing code without recording
and playback is we can define our own custom names for the objects, same as we
used to do in QTP. Which would be easy for us for updating or maintenance of
the code later.
I used to record and run the code. The
problem was because of the names generated by the tool, its bit hard for me to
know what window is what and which object it is actually referring it. After a
thorough process, here is my analysis.
Let us do this for clicking Equal button on the
The first step here is same
like in QTP, which is spying the object and knowing its hierarchy.
In the left hand side box, we see the
hierarchy for the Equal button. So for an Equal button to be defined, the
Calculator window and Item window are to be defined.
Now in the UIMap.cs let us define the Calculator window.
To know the properties of the UICalculatorWindow, simply select the control
and the properties are defined as shown below
partial class UIMap
public CalcWindow CalcWindow
this.mCalcWindow = new CalcWindow();
·CalcWindow is the main window. Now we
need to define the CalcWindow.
class CalcWindow : WinWindow
defining the search properties as seen in the builder.
As seen in the Figure2, the child for
the Calculator window is Item window. While recognizing the object in the
CodedUI, we see every button has got a window defined for it. So here we need
to define EqualItemwindow for the
Equal button. So this is done in the Calcwindow
class as shown above.
·The last step is defining the
the button the its parent EqualItemWindow
which is initialized in the CalcWindow class is to be defined as shown