编码的ui - 无法对文本框执行“SetProperty”

时间:2012-11-11 10:04:26

标签: c# wpf coded-ui-tests

我正在为WPF应用程序编写一个编码的ui。 该项目包含大约30个测试,并且在测试初始化​​时我有提交Login的方法。 问题是在某些情况下我得到错误:

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:

1 个答案:

答案 0 :(得分:0)

此问题与IE有关。您可能希望通过卸载IE的更新版本来暂时考虑解决方法 为此,
(1)打开关于IE
(2)点击“自动卸载IE新版本更新”复选框
(3)点击“确定”。
此新版本(KBxxxxxxxx)将作为已安装更新的Windows安全更新提供。您可能需要暂时考虑解决方法,但请注意,您将卸载重要的安全更新。