Answered by:
Error running the Coded UI test

Question
-
Hi,
I am trying to run an coded ui test. It ran till a certain point but after that it gives the following error:
"Test method ScanClient.CodedUITest1.CodedUITestMethod1 threw exception:
Microsoft.VisualStudio.TestTools.UITest.Extension.UITestControlNotFoundException: The playback failed to find the control with the given search properties. Additional Details:
TechnologyName: 'MSAA'
ControlType: 'Window'
Name: 'ECM Scan Module - Index Document'
ClassName: 'WindowsForms10.Window'
---> System.Runtime.InteropServices.COMException: Error HRESULT E_FAIL has been returned from a call to a COM component."What does this mean and how can I avoid this.
Thanks,
TAG
Monday, August 8, 2011 5:20 PM
Answers
-
bi-tester,
This means your playback was unable to loacate an MSAA (Winforms) type Window with a title of "ECM Scan Module - Index Document". The class which this control belongs to is referred to as WindowsForms10.Window in code. Due to this being a Window, it is likely you have a window with a dynamic title (i.e. it changes depending on cirumstance).
I am going to assume this is the case, to fix this you have a couple options depending on your scenario.
UI Element not found due to Dynamic window name but containing Static name portion:
By default, Coded UI playback will search for the Window Title of the window which a given recorded UI element was found in. To overcome this, add a default constructor which adds a new search property in the UIMap.cs file which is throwing the UIElement not found exception.
public partial class UIMap{ public UIMap() { this.UIWindow.SearchProperties.Add(UIWindow.PropertyNames.Name,"SomethingStatic", PropertyExpressionOperator.Contains); }
You may also use this method to add the possible names your window can have (recommended if it is a small number, using PropertyExpressionOperator.Equals instead of PropertyExpressionOperator.Contains)
This can also be done using the Coded UI test editor
See:
Coded UI Test Editor in Visual Studio 2010 Feature Pack 2
http://windotnet.blogspot.com/2011/07/coded-ui-test-editor-is-visual-studio.html
Disregarding Window Title as search property:
You can use the sample provided on Gautam Goenka's blog to remove the Window Title as a search property.
See:
Configure search properties used by recorder\code generation
Cheers,
Paul
- Marked as answer by bi-tester Monday, August 8, 2011 8:08 PM
Monday, August 8, 2011 6:50 PM
All replies
-
bi-tester,
This means your playback was unable to loacate an MSAA (Winforms) type Window with a title of "ECM Scan Module - Index Document". The class which this control belongs to is referred to as WindowsForms10.Window in code. Due to this being a Window, it is likely you have a window with a dynamic title (i.e. it changes depending on cirumstance).
I am going to assume this is the case, to fix this you have a couple options depending on your scenario.
UI Element not found due to Dynamic window name but containing Static name portion:
By default, Coded UI playback will search for the Window Title of the window which a given recorded UI element was found in. To overcome this, add a default constructor which adds a new search property in the UIMap.cs file which is throwing the UIElement not found exception.
public partial class UIMap{ public UIMap() { this.UIWindow.SearchProperties.Add(UIWindow.PropertyNames.Name,"SomethingStatic", PropertyExpressionOperator.Contains); }
You may also use this method to add the possible names your window can have (recommended if it is a small number, using PropertyExpressionOperator.Equals instead of PropertyExpressionOperator.Contains)
This can also be done using the Coded UI test editor
See:
Coded UI Test Editor in Visual Studio 2010 Feature Pack 2
http://windotnet.blogspot.com/2011/07/coded-ui-test-editor-is-visual-studio.html
Disregarding Window Title as search property:
You can use the sample provided on Gautam Goenka's blog to remove the Window Title as a search property.
See:
Configure search properties used by recorder\code generation
Cheers,
Paul
- Marked as answer by bi-tester Monday, August 8, 2011 8:08 PM
Monday, August 8, 2011 6:50 PM -
Hi Paul,
Thank you for your reply, but I am sorry I am not able to solve this problem.
I have tried to change the search properties but I dont know which one I should choose.
Can you explain this in steps?
Thanks,
TAG
Monday, August 8, 2011 8:08 PM