I'm using White to automate the BDD testing of our C# WPF UI.
My first couple of tests are working well on my development machine (running Windows 7). However, when I try and run the same code on the build server (virtual machine running Windows server 2003 R2) it doesn't work correctly. In both cases the tests are run from the command line and the tests are using the Cuke4Nuke framework. In the case of the server I am accessing the server via Remote Desktop Connection.
The code looks like:
var application = Application.Launch("whiteApp.exe");
var initializeOption = InitializeOption.NoCache;
var windowCriteria = SearchCriteria.ByText("whiteApp");
var window = application.GetWindow(criteria, initializeOption);
var criteria = SearchCriteria.ByAutomationId("rightButton");
var button = (Button) window.Get(criteria);
button.click();
The problem is that the buttons click event is not fired when it is run on the server. The button can be clicked (using the mouse) if the UI is left open after White has finished executing. One interesting point is that after the click method is run that the button does show evidence of being clicked as in the picture below, in the case of other buttons the mouse over effect is shown.
I'm not sure if this is your problem or not, but I've noticed that White has a few issues when it is used by applications built using the AnyCPU
platform and run on an 64-bit system. For some reason, anytime it attempts to move the mouse under these conditions, it automatically pushes the mouse to the bottom of the screen instead of the requested location. This means a click command misses the button it was told to click on.
If you build the automation application as an x86
application, White automates the mouse properly.
At my local windows 7 x64 machine it does the same.
Don't know if it's usefull, but using button.RaiseClickEvent(); seems to work ok. I assume this raises the event without clicking the button or smt.
I know this is an old question, but I bumped into it the other day and thought my answer might be useful to others...
I'm running Project White with NUnit on a 64-bit Win7 machine. To make it work for me I had to ensure that the tests were run in a 32-bit process.
I was using the TestDriven.Net plugin. It has an option to run Any CPU tests as either 32-bit or 64-bit.
As Harry mentioned in his answer, forcing the automation application (test application) in x86 mode does work.
However, the real problem is created by White itself. On White's discussion pages on codeplex, Hachima posted a modification of the source code of White to ensure it works under x86 as well as x64: http://white.codeplex.com/discussions/228433
来源:https://stackoverflow.com/questions/5631461/white-uiautomation-click-stops-working-on-different-platform