2011-10-12 67 views
0

我有一套Coded UI測試,我在IE 8中爲Web應用程序運行。我可以無誤地運行任何單個測試。當我一次嘗試運行多個測試時,只有第一個測試運行沒有錯誤;只要嘗試第二次測試,我收到以下錯誤:嘗試在同一時間運行多個Coded UI測試時出錯

「已從其基礎RCW分離的COM對象無法使用。」

這裏是堆棧跟蹤。我要補充一點,我已經取代默認的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

你在做什麼多線程?定時器等 –

+0

我沒有在Coded UI測試中做任何多線程工作。在與Coded UI測試相同的項目中,我有一個使用System.Diagnostics.Stopwatch的性能測試,但是當我運行我的編碼UI測試時,該測試不會執行。不知道這是否會影響任何東西。 謝謝你的迴應! –

回答

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 
    } 
} 

這將解決這個問題,我希望。

相關問題