We already discussed hand coding Coded UI Test using WinControls in previous posts, in this post, we will discuss about hand coding CUIT with UITestControls.
We already discussed about UITestControl, stating this class is the base class for all the technologies like WinControl, HtmlControl etc
UITestControl provides properties and methods which are generic to controls across technologies
Here is the complete video of the topic discuss
Here is the code snippet discuss in the above video
public static void Button8Click()
{
//Instance for WinWindow
UITestControl calcWindow = new UITestControl();
calcWindow.TechnologyName = "MSAA";
calcWindow.SearchProperties[UITestControl.PropertyNames.Name] = "Calculator";
calcWindow.SearchProperties[UITestControl.PropertyNames.ClassName] = "CalcFrame";
//Button
UITestControl btn8 = new WinButton(calcWindow);
btn8.SearchProperties[UITestControl.PropertyNames.Name] = "8";
Mouse.Click(btn8);
UITestControl btn9 = new WinButton(calcWindow);
btn9.SearchProperties[UITestControl.PropertyNames.Name] = "9";
Mouse.Click(btn9);
UITestControl btnAdd = new WinButton(calcWindow);
btnAdd.SearchProperties[UITestControl.PropertyNames.Name] = "Add";
Mouse.Click(btnAdd);
UITestControl btn2 = new WinButton(calcWindow);
btn2.SearchProperties[UITestControl.PropertyNames.Name] = "2";
Mouse.Click(btn2);
UITestControl btn3 = new WinButton(calcWindow);
btn3.SearchProperties[UITestControl.PropertyNames.Name] = "3";
Mouse.Click(btn3);
UITestControl btnEquals = new WinButton(calcWindow);
btnEquals.SearchProperties[UITestControl.PropertyNames.Name] = "Equals";
Mouse.Click(btnEquals);
}
Thanks for reading the post and watching the video !!!
Please leave your comments to improve the post.
Thanks,
Karthik KK