Я написал такой код:
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 errorCode, IntPtr errorInfo)
в System.Runtime.InteropServices.Marshal.ThrowExceptionForHR (Int32 errorCode)
в MS.Internal.Automation.UiaCoreApi.CheckError (Int32 ч)
в MS.Internal.Automation.UiaCoreApi.UiaGetPropertyValue (SafeNodeHandle hnode, Int32 propertyId, Object & value)
в System.Windows.Automation.AutomationElement.GetCurrentPropertyValue (свойство AutomationProperty, логическое значение ignoreDefaultValue)
в 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] (AutomationProperty AutomationProperty)
в Microsoft.VisualStudio.TestTools.UITest.Extension.Uia.UiaElement.GetRequestedState (AccessibleStates requiredState)
в 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. b _3 (UITestControl ctrl)
в Microsoft.VisualStudio.TestTools.UITesting.UITestControl.WaitForCondition [T] (T conditionContext, Predicate 1 conditionEvaluator, Int32 millisecondsTimeout)
at Microsoft.VisualStudio.TestTools.UITesting.UITestControl.WaitForControlCondition(Predicate
1 conditionEvaluator, Int32 millisecondsTimeout)
в Microsoft.VisualStudio.TestTools.UITesting.UITestControl.WaitForControlPropertyNotEqual (String propertyName, Object propertyValue, Int32 millisecondsTimeout)
В чем причина такого поведения?
Спасибо за продвижение!