【发布时间】:2010-11-30 10:22:07
【问题描述】:
我写过这样的代码:
int timeOut = 300000; //milliseconds
string _displayTextProp = "DisplayText";
WpfText screenResult = MainWindow.UITableStatusControlCustom.ScreenResultLabelValue;
screenResult.WaitForControlExist(timeOut);
screenResult.WaitForControlPropertyNotEqual(_displayTextProp, null, timeOut);
screenResult.WaitForControlPropertyNotEqual(_displayTextProp, "0", timeOut);// (1)
在这个(1)方法中我得到了异常 UITestControlNotAvailableException
测试方法抛出异常:
Microsoft.VisualStudio.TestTools.UITest.Extension.UITestControlNotAvailableException:控件不可用或无效。 ---> System.Runtime.InteropServices.COMException:来自 HRESULT 的异常:0x80042002
在 System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32 错误代码,IntPtr 错误信息)
在 System.Runtime.InteropServices.Marshal.ThrowExceptionForHR(Int32 错误代码)
在 MS.Internal.Automation.UiaCoreApi.CheckError(Int32 小时)
在 MS.Internal.Automation.UiaCoreApi.UiaGetPropertyValue(SafeNodeHandle hnode,Int32 propertyId,Object& 值)
在 System.Windows.Automation.AutomationElement.GetCurrentPropertyValue(AutomationProperty 属性,布尔忽略默认值)
在 System.Windows.Automation.AutomationElement.GetCurrentPropertyValue(AutomationProperty 属性)
在 Microsoft.VisualStudio.TestTools.UITest.Extension.Uia.UiaUtility.GetAutomationPropertyValue[T](AutomationElement 元素,AutomationProperty 属性)
--- 内部异常堆栈跟踪结束 ---
在 Microsoft.VisualStudio.TestTools.UITest.Extension.Uia.UiaUtility.MapAndThrowException(SystemException e,IUITechnologyElement 元素)
在 Microsoft.VisualStudio.TestTools.UITest.Extension.Uia.UiaUtility.GetAutomationPropertyValue[T](AutomationElement 元素,AutomationProperty 属性)
在 Microsoft.VisualStudio.TestTools.UITest.Extension.Uia.UiaElement.GetAutomationPropertyValue[T](AutomationPropertyautomationProperty)
在 Microsoft.VisualStudio.TestTools.UITest.Extension.Uia.UiaElement.GetRequestedState(AccessibleStates requestedState)
在 Microsoft.VisualStudio.TestTools.UITest.Extension.UITechnologyElement.IsState(IUITechnologyElement 元素,AccessibleStates 状态)
在 Microsoft.VisualStudio.TestTools.UITesting.UITestControl.EnsureValid(布尔 waitForReady,布尔重新获取)
在 Microsoft.VisualStudio.TestTools.UITesting.UITestControl.GetPropertyValue(String propertyName)
在 Microsoft.VisualStudio.TestTools.UITesting.UITestControl.GetProperty(String propertyName)
在 Microsoft.VisualStudio.TestTools.UITesting.UITestControl.c_DisplayClass4.1 conditionEvaluator, Int32 millisecondsTimeout)
at Microsoft.VisualStudio.TestTools.UITesting.UITestControl.WaitForControlCondition(Predicate1 conditionEvaluator, Int32 毫秒超时)
在 Microsoft.VisualStudio.TestTools.UITesting.UITestControl.WaitForControlPropertyNotEqual(String propertyName, Object propertyValue, Int32 millisecondsTimeout)
什么原因会导致这种行为?
感谢您的提前!
【问题讨论】:
标签: .net automated-tests coded-ui-tests