Coded UI TestWinEdit
类中存在错误/限制:在覆盖OnKeyDown
方法或订阅KeyDown
文本框中的事件时,无法使用该WinEdit.Text
属性。
也就是说,当你有这个...
private void myTextbox_KeyDown(object sender, KeyEventArgs e)
{
// ...
}
...这行不通:
var edit = new WinEdit(ancestor);
edit.SearchProperties[WinControl.PropertyNames.ControlName] = "myTextbox";
edit.Text = "New value"; // This doesn't work
我找到了在这里设置值的解决方法:
var edit = new WinEdit(ancestor);
edit.SearchProperties[WinControl.PropertyNames.ControlName] = "myTextbox";
Mouse.Click(edit);
System.Windows.Forms.SendKeys.SendWait("New value");
我的问题:有人知道读取值的解决方法吗?
var edit = new WinEdit(Window);
edit.SearchProperties[WinControl.PropertyNames.ControlName] = "myTextbox";
string actual = edit.Text; // This doesn't work