2

私はそのようなコードを書きました:

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 at System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32 errorCode、IntPtr errorInfo)at System.Runtime.InteropServices.Marshal.ThrowExceptionForHR(Int32 errorCode)at MS .Internal.Automation.UiaCoreApi.CheckError(Int32 hr)at MS.Internal.Automation.UiaCoreApi.UiaGetPropertyValue(SafeNodeHandle hnode、Int32 propertyId、Object&value)at System.Windows.Automation.AutomationElement.GetCurrentPropertyValue(AutomationProperty property、Boolean ignoreDefaultValue)at System.Windows.Automation.AutomationElement。DisplayClass4。<WaitForControlPropertyNotEqual>b_3(UITestControl ctrl)at Microsoft.VisualStudio.TestTools.UITesting.UITestControl.WaitForCondition [T](T conditionContext、Predicate 1 conditionEvaluator, Int32 millisecondsTimeout) at Microsoft.VisualStudio.TestTools.UITesting.UITestControl.WaitForControlCondition(Predicate1 conditionEvaluator、Int32 mmolsTimeout)at Microsoft.VisualStudio.TestTools.UITesting.UITestControl.WaitForControlPropertyNot文字列propertyName、Object propertyValue、Int32ミリ秒タイムアウト)

そのような行動をとることができる理由は何ですか?

よろしくお願いします!

4

1 に答える 1

2

このリンクに従って:

この例外は、UI テスト フレームワークが、使用できなくなった、またはアクセスできない UI 要素にアクセスしようとするとスローされます。そのため、アイテムを破棄したか、要素にアクセスできなくなってアクセスしようとしている可能性があります。AutomationElements の 1 つを初期化できなかった可能性がありますか?

于 2010-11-30T10:25:51.937 に答える