我試圖創建一個運行我的應用程序的測試,然後在使用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「);」我有同樣的錯誤。 –