我试图创建一个运行我的应用程序的测试,然后在使用CodedUI.This领域的文字是我的代码:编码的UI:HRESULT E_FAIL已从调用返回至COM组件
var app = ApplicationUnderTest.Launch(@"C:\app.exe");
var loginEdit = new WinEdit();
loginEdit.SearchProperties.Add(WinEdit.PropertyNames.ControlName, "textEditLogin");
loginEdit.Text = "test005";
错误:System.NotSupportedException: SetProperty "Text" is not supported on control type: Window.
如果我用这个代码:
Keyboard.SendKeys(loginEdit, "test005");
我有错误:Microsoft.VisualStudio.TestTools.UITest.Extension.PlaybackFailureException: (Failed to get the message for an exception of type Microsoft.VisualStudio.TestTools.UITest.Extension.PlaybackFailureException due to an exception.) ---> System.Runtime.InteropServices.COMException: HRESULT E_FAIL has been returned from a call to a COM component
这是我WinEdit的属性: WinEdit
可能是什么问题呢?
这是一个WinWindow,而不是WinEdit。使用[基础教程](http://www.evoketechnologies.com/blog/windows-automation-testing-coded-ui/)来获得这个权利。 –
我真的不明白为什么那个控件是WinWindow? 由于此控件的ControlType是“编辑”。如果是WinWindow,我如何在这个控件中输入文本? –
当我更改loginEdit(WinWindow)的控制类型并尝试“Keyboard.SendKeys(loginEdit,”test005“);”我有同样的错误。 –