I have a suite of Coded UI tests that I am running for a web application in IE 8. I can run any individual test without error. When I try to run more than one test at a time, only the first test runs without error; as soon as the second test is attempted, I receive the following error:
"COM object that has been separated from its underlying RCW cannot be used."
And here's the stack trace. I should add that I've replaced the default UIMap with my own classes defining the UI elements:
System.Variant.MarshalHelperConvertObjectToVariant(Object o, Variant& v)
System.StubHelpers.ObjectMarshaler.ConvertToNative(Object objSrc, IntPtr pDstVariant)
Microsoft.VisualStudio.TestTools.UITest.Playback.Engine.IRPFPlayback.ScreenElementFromNativeElement(Object varNativeElement, String technologyName)
Microsoft.VisualStudio.TestTools.UITest.Playback.ScreenElement.FromNativeElement(Object nativeElement, String technologyName)
Microsoft.VisualStudio.TestTools.UITest.Playback.ScreenElement.FromTechnologyElementInternal(IUITechnologyElement technologyElement)
Microsoft.VisualStudio.TestTools.UITest.Playback.ScreenElement.FromTechnologyElement(IUITechnologyElement element)
Microsoft.VisualStudio.TestTools.UITesting.UITestControl..ctor(IUITechnologyElement element, UITestControl searchContainer)
Microsoft.VisualStudio.TestTools.UITesting.Brows开发者_开发百科erWindow.get_CurrentDocumentWindow()
Microsoft.VisualStudio.TestTools.UITesting.SearchHelper.GetUITestControlRecursive(Boolean useCache, Boolean alwaysSearch, ISearchArgument searchArg, IList`1 windowTitles, Int32& timeLeft)
Microsoft.VisualStudio.TestTools.UITesting.SearchHelper.GetUITestControlRecursive(Boolean useCache, Boolean alwaysSearch, ISearchArgument searchArg, IList`1 windowTitles, Int32& timeLeft)
Microsoft.VisualStudio.TestTools.UITesting.SearchHelper.GetElement(Boolean useCache, ISearchArgument searchArg)
Microsoft.VisualStudio.TestTools.UITesting.SearchHelper.Search(ISearchArgument searchArg)
Microsoft.VisualStudio.TestTools.UITesting.UITestControl.FindInternal()
Microsoft.VisualStudio.TestTools.UITesting.UITestControl.Find()
Microsoft.VisualStudio.TestTools.UITesting.UITestControl.GetProperty(String propertyName)
Microsoft.VisualStudio.TestTools.UITesting.UITestControl.GetPropertyInternal[T](String propertyName)
Microsoft.VisualStudio.TestTools.UITesting.UITestControl.get_Exists()
VerifySuccessfulLogon()[...]LogOnPage.cs: line 97
AttemptLogOn()[...]WebUITest.cs: line 111
Thanks in advance! -James
Add the following line to the window.
this.SearchConfigurations.Add(SearchConfiguration.AlwaysSearch);
For example,
To Open Adobe Acrobat Window
public class UIAdobeAcrobatProWindow : WinWindow
{
public UIAdobeAcrobatProWindow()
{
#region Search Criteria
this.SearchProperties.Add(new PropertyExpression(WinWindow.PropertyNames.Name, "Adobe Acrobat Pro", PropertyExpressionOperator.Contains));
**this.SearchConfigurations.Add(SearchConfiguration.AlwaysSearch);**
this.SearchProperties[WinWindow.PropertyNames.ClassName] = "AcrobatSDIWindow";
#endregion
}
}
This will fix the problem, I hope.
精彩评论