我有一套Coded UI测试,我正在为IE 8中的Web应用程序运行。我可以运行任何单独的测试而不会出错。当我尝试一次运行多个测试时,只有第一个测试运行没有错误;一旦尝试第二次测试,我收到以下错误:
“无法使用已与其基础RCW分离的COM对象。”
这是堆栈跟踪。我应该补充一点,我已经用我自己的定义UI元素的类替换了默认的UIMap:
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.BrowserWindow.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
提前致谢! -James
答案 0 :(得分:1)
将以下行添加到窗口中。
this.SearchConfigurations.Add(SearchConfiguration.AlwaysSearch);
例如,
打开Adobe Acrobat窗口
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
}
}
这将解决问题,我希望。