Reputation: 346
I'm using Visual Studio 2010 Ultimate - visual c# - codedUI.
I'm putting together some automated testing for a client (smoke testing, regression testing, etc.) however the application I'm trying to do the test automation for isn't being cooperative. I've automated all of the client's web apps with no issues, but with their desktop application, I can't seem to get any unique identifier between any of the controls.
Here's a sample codedUI recording where I go through a tree structure in the application - I highlight several different items in the list, expand a list, click on an item, browse the window that launches etc.
/// <summary>
/// SomeRecordedMethod
/// </summary>
public void SomeRecordedMethod()
{
#region Variable Declarations
WinTitleBar uINavigatorTitleBar = this.UISomeRandomCompanyWindow.UINavigatorWindow.UINavigatorTitleBar;
WinEdit uIObjectdescEdit = this.UISomeRandomCompanyWindow.UINavigatorWindow.UIDw_navigatorClient.UIObjectdescEdit;
WinClient uICalendar1Client = this.UISomeRandomCompanyWindow.UIMaintainCalendar1Window.UIItemWindow.uICalendar1Client;
#endregion
// Click 'Navigator' title bar
Mouse.Click(uINavigatorTitleBar, new Point(241, 9));
// Click 'objectdesc' text box
Mouse.Click(uIObjectdescEdit, new Point(19, 11));
// Click 'objectdesc' text box
Mouse.Click(uIObjectdescEdit, new Point(39, 10));
// Double-Click 'objectdesc' text box
Mouse.DoubleClick(uIObjectdescEdit, new Point(37, 11));
// Double-Click 'objectdesc' text box
Mouse.DoubleClick(uIObjectdescEdit, new Point(20, 11));
// Double-Click 'objectdesc' text box
Mouse.DoubleClick(uIObjectdescEdit, new Point(42, 5));
// Double-Click 'objectdesc' text box
Mouse.DoubleClick(uIObjectdescEdit, new Point(61, 11));
// Click 'Calendar [1]' client
Mouse.Click(uICalendar1Client, new Point(632, 141));
// Click 'Calendar [1]' client
Mouse.Click(uICalendar1Client, new Point(671, 200));
// Click 'Calendar [1]' client
Mouse.Click(uICalendar1Client, new Point(675, 301));
// Click 'Calendar [1]' client
Mouse.Click(uICalendar1Client, new Point(686, 396));
// Click 'Calendar [1]' client
Mouse.Click(uICalendar1Client, new Point(686, 544));
// Click 'Calendar [1]' client
Mouse.Click(uICalendar1Client, new Point(478, 547));
// Click 'Calendar [1]' client
Mouse.Click(uICalendar1Client, new Point(579, 552));
// Click 'Calendar [1]' client
Mouse.Click(uICalendar1Client, new Point(579, 552));
}
Notice the multiple instances of 'objectdesc' and 'Calendar [1]'. Every duplicate occurance is a different control, but the action recording isn't picking that up.
When I try to run the test I obviously get: Microsoft.VisualStudio.TestTools.UITest.Extension.UITestControlNotFoundException: The playback failed to find the control with the given search properties.
I'm new to test automation in Visual Studio, so I'm not sure what options I have at this point. Any advice would be greatly appreciated.
Thank you
Upvotes: 1
Views: 1678
Reputation: 14038
For many controls the new Point(x,y)
argument to Mouse.Click()
is not needed but is provided for items that have two or more parts, eg a button that can be clicked but that also has a drop-down list. The (x,y) values in the code you show suggest that all that Coded UI is seeing is a big control, ie the whole calendar or the whole uIObjectdescEdit and not the fields within it.
I suspect the application uses some custom controls that do not support Coded UI. Find out from the developers how the application is written, what technologies (eg WPF, Windows Forms, MFC, etc) were used and what custom controls were used. Then check the answers against the compatibility lists on Microsoft's Coded UI web pages. If custom controls were used then you may need to repeat the question to the authors of those controls.
Upvotes: 2