I'm trying to automate the testing of an application, and I'm stuck on an issue that I'm struggling to troubleshoot.
The application has standard windows buttons, and I've tried with both AutoIT and the User32 dll to click some of these buttons. Sometimes the buttons are clicked properly (yay!) and sometimes they fail (boo!) - but what's worse, AutoIT is convinced that it clicked the button (double-boo!) which then generates false-positives (triple-boo!). When I saw that it's convinced, I mean it returns that the click was successful when it wasn't.
I'm running the application on Win Server 2K8, there is nothing special about this application other than it uses MDI windows, and some of the buttons are contained in MDI windows. Some though, are not within MDI windows (login window, for example, before the parent window is created).
Here's my order of commands:
Find the button in the window (success, always) Bring the window the foreground (success) Activate the window (success) Active the button (success) Focus the button (success) If the button is focused, and the button is enabled, then click it. (Success/Failure, unpredictable behavior. I can't narrow down why it succeeds sometimes, and why it fails sometimes...)
Other details:
Sometimes the order has the button being clicked, which should open another window. That window is closed, then the button is clicked again - and this time around, nothing happens. Other times it works as expected.
I'm running as Administrator, and UAC is fully disabled.
It's not a timing issue, to my knowledge, because I do make sure the button is focused, and enabled before trying to click on it, and I see that the button does get the focused highlight around it.
And as I mentioned, I've also been trying this with just a simple User32/SendMessage call, and this also fails.
Last, but not least, this doesn't happen when I manually interact with the application. I have always had actual button clicks work.
Any thoughts?
UPDATE
Here's another variable to the equation I should have mentioned - this is happening on a VM (because that's where I need to run it). I can do some limited testing on my own machine, but to get some true testing, it needs to be on the VM. Clicking on my own dev box seems to be reliable, which makes this all the more puzzling.
I've been trying this out on another VM, and it also seems to be working there. As far as the two VMs going, they're running the same version of Windows, same version of my application, same version of AutoIT, etc.
I've reduced it down to one detail - which, as luck would have it, I'm not able to configure myself, and have to put in a ticket to change any configuration. The difference in configurations is this:
On the VM that isn't working, the device manager shows a mouse that is a vmware mouse. On the VM that is working, the device manager shows a mouse that is PS/2 mouse. Obviously both are software mice, but I'm wondering now if the VMWare mouse could be acting differently, and causing the button clicks to not always work. I'm not sure how likely this is as the solution, because from my understanding of it, using the User32 SendMessage call doesn't actually use the mouse, but instead sends the same message the mouse would have sent, but it's worth a shot...