我正在为 WPF 应用程序编写一个编码的 ui。该项目包含大约 30 个测试,在测试初始化时我有提交登录的方法。问题是在某些情况下我收到错误:
Microsoft.VisualStudio.TestTools.UITest.Extension.PlaybackFailureException was unhandled by user code
Message=Cannot perform 'SetProperty of Text with value "admin"' on the control. Additional Details:
TechnologyName: 'UIA'
ControlType: 'Edit'
AutomationId: 'UserName'
大多数时候这个错误不会发生。
我很难找到错误一致性。
我可以说,如果我将重新启动代理服务并运行 30 测试 - 我将不会出现此错误。但如果我将运行 10 次测试 - 没有服务重新启动 - 再次运行 10 次测试,我将有可能重现错误。
完整的错误日志:
Microsoft.VisualStudio.TestTools.UITest.Extension.PlaybackFailureException was unhandled by user code
Message=Cannot perform 'SetProperty of Text with value "admin"' on the control. Additional Details:
TechnologyName: 'UIA'
ControlType: 'Edit'
AutomationId: 'UserName'
Source=Microsoft.VisualStudio.TestTools.UITesting
BasicMessage=Cannot perform 'SetProperty of Text with value "admin"' on the control.
HResult=-268111863
Action=SetProperty of Text with value "admin"
ObjectName=UserName
StackTrace:
at Microsoft.VisualStudio.TestTools.UITesting.Playback.MapAndThrowComException(COMException innerException, IPlaybackContext context)
at Microsoft.VisualStudio.TestTools.UITesting.Playback.MapAndThrowException(SystemException exception, IPlaybackContext context)
at Microsoft.VisualStudio.TestTools.UITesting.Playback.MapAndThrowException(SystemException exception, String actionName, UITestControl uiControl)
at Microsoft.VisualStudio.TestTools.UITesting.Playback.MapAndThrowException(SystemException exception, String actionName, Object parameterValue, UITestControl uiControl)
at Microsoft.VisualStudio.TestTools.UITesting.UITestControl.SetPropertyValue(String propertyName, Object propertyValue)
at Microsoft.VisualStudio.TestTools.UITesting.UITestControl.SetProperty(String propertyName, Object value)
at Microsoft.VisualStudio.TestTools.UITesting.WpfControls.WpfEdit.set_Text(String value)
InnerException: System.Runtime.InteropServices.COMException
Message=Exception from HRESULT: 0xF004F006
Source=Microsoft.VisualStudio.TestTools.UITest.Playback
ErrorCode=-268111866
StackTrace:
at Microsoft.VisualStudio.TestTools.UITest.Playback.Engine.IScreenElement.SetValueAsEditBox(String bstrNewValue, Int32 nSetValueAsEditBoxFlag)
at Microsoft.VisualStudio.TestTools.UITest.Playback.ScreenElement.SetValueAsEditBox(String value, Boolean isEncoded, Int32 flag)
at Microsoft.VisualStudio.TestTools.UITest.Playback.ScreenElement.SetValueAsEditBox(String value, Boolean isEncoded)
at Microsoft.VisualStudio.TestTools.UITesting.TechnologyElementPropertyProvider.SetValueAsEditBox(UITestControl uiControl, String value, Boolean isEncoded, Boolean useCopyPaste)
at Microsoft.VisualStudio.TestTools.UITesting.WpfPropertyProvider.SetEditProperty(String propertyName, Object value)
at Microsoft.VisualStudio.TestTools.UITesting.WpfPropertyProvider.SetPropertyValue(UITestControl uiControl, String propertyName, Object value)
at Microsoft.VisualStudio.TestTools.UITesting.UITestPropertyProvider.SetPropertyValueWrapper(UITestControl uiControl, String propertyName, Object value)
at Microsoft.VisualStudio.TestTools.UITesting.UITestControl.SetPropertyValue(String propertyName, Object propertyValue)
InnerException: