Sendkeys(“{BACKSPACE}”) 将“B”插入到字符而不是退格
我在 Silverlight 项目中声明了一个文本框,其内容为“123456”,然后在编码 UI 测试中使用以下代码。首先,它搜索并单击文本框以设置焦点,然后尝试删除字符。
currencyPage.ClickEditByAutomationId("textBox");
Keyboard.SendKeys("{END}");
Keyboard.SendKeys("{BACKSPACE}");
Keyboard.SendKeys("{BACKSPACE}");
Keyboard.SendKeys("{BACKSPACE}");
Keyboard.SendKeys("{BACKSPACE}");
Keyboard.SendKeys("{BACKSPACE}");
这是我的文本框中生成的文本:123456BBBBB
我做错了什么?文本框的 XAML:
I have a TextBox declared in a Silverlight project with contents “123456” and then use the following code in a Coded UI test. First it searches and clicks the TextBox to set focus, and then tries to delete characters.
currencyPage.ClickEditByAutomationId("textBox");
Keyboard.SendKeys("{END}");
Keyboard.SendKeys("{BACKSPACE}");
Keyboard.SendKeys("{BACKSPACE}");
Keyboard.SendKeys("{BACKSPACE}");
Keyboard.SendKeys("{BACKSPACE}");
Keyboard.SendKeys("{BACKSPACE}");
This is the resulting text in my TextBox: 123456BBBBB
What am I doing wrong? XAML of the textbox:
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尝试
Try
尝试
Keyboard.SendKeys(@"{BACKSPACE}");
或Keyboard.SendKeys("{{BACKSPACE}}");
Try
Keyboard.SendKeys(@"{BACKSPACE}");
orKeyboard.SendKeys("{{BACKSPACE}}");