This project is read-only.

Keyboard input does not work for WPF application

May 28, 2010 at 4:52 PM
Hello, I'm testing a simple WPF application (Application Under Test or AUT) that I wrote which contains a tab control, a couple tabs, and a custom control of mine. I can get access to the custom control just fine but when I try using the keyboard to send keystrokes to the app, there appears to be no effect in the AUT. I am running Windows 7, VS Studio 2010, and white 0.2. My test code is very simple and I followed the example given in discussion Does anyone have suggestions on what I can try to get the keyboard working? Thanks.
May 28, 2010 at 5:41 PM



what keystrokes do you send?

has the application the focus?



May 28, 2010 at 6:19 PM
Edited May 28, 2010 at 6:23 PM

I am sending two subsequent TABs followed by a number as follows:

var keyb = _mainWindow.Keyboard;




The application does have focus.


May 28, 2010 at 6:25 PM



can you try to click first of one of the tabs?


and try than the tab key?


May 28, 2010 at 7:29 PM
Edited May 28, 2010 at 7:30 PM
To answer your previous question, clicking on the tab first didn't help. Played around some more... When I run the same code in a simple console application, it works just fine. Originally I was running the code as an NUnit test using the GUI runner (sorry I forgot to mention). Is white suppose to work when used under NUnit's GUI runner? If not then what is the common practice when using white with NUnit? Thanks.
May 28, 2010 at 7:30 PM
Edited May 28, 2010 at 7:31 PM
May 28, 2010 at 8:04 PM

there should be no problems running under Nunit.  We use also the latest version, during development I use Resharper Part to run and debug tests.

mmh strange we use Tab key too on a WPF Application and have no problems.


Can you try the following:




instead of _windows.Keyboard


now I leave office, Monday I will be back, if  there is time I will look from home at weekend.




May 28, 2010 at 8:25 PM
Okay, I will give it a try and report back. Thanks for all your advice so far.
Jun 1, 2010 at 1:07 PM
Edited Jun 1, 2010 at 1:55 PM
I tried using the Keyboard.Instance but it still doesn't work. As a further experiment, I tried the same test using NUnit console runner and it didn't work either. -Andy
Jun 1, 2010 at 2:36 PM

are there other keyboard entries possible? and have you tried some of them

mmh last try

is the testmachine x64 OS?

try unit x86 version


Jun 1, 2010 at 4:14 PM
Test machine is x64 OS. Tried the x86 version of NUnit console and GUI runners and it *works* now! Thank so much for all your help. -Andy