4

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:

Aaron Axvig
  • 370
  • 1
  • 3
  • 9

2 Answers2

7

Try

Keyboard.SendKeys("{BACK}");
Attila Szasz
  • 3,033
  • 3
  • 25
  • 39
0

Try Keyboard.SendKeys(@"{BACKSPACE}"); or Keyboard.SendKeys("{{BACKSPACE}}");

Keith Adler
  • 20,880
  • 28
  • 119
  • 189