Automating UI Testing on a Locked PC

talks about QA Wizard Pro on June 04, 2009

Automating UI tests has the down side of needing to be able to control the mouse and the keyboard as well as needing to be able to see the application running on the screen. This can cause trouble if you need to use the computer for other things or want to keep the workstation secure while the tests are running. Luckily, there are tools available to allow you to automate in a virtual environment and still be able to use or lock the hosting computer.

To set up an example virtual environment, I installed Microsoft Virtual PC. It’s available from Microsoft as a free download, all you need is a way to install an operating system that you want to use to test on it. The operating system doesn’t even need to be the same as your host computer. In my tests, I used Windows Vista to run a Virtual PC with Windows XP SP2.

I installed the virtual machine additions by using the “Install or Update Virtual Machine Additions” item in the “Actions” menu. This allows you to resize the virtual PC in the same manner as you resize other windows on your desktop. It also allows the mouse to cross into and out of the virtual PC window seamlessly. This mouse feature will cause the automation problems however, as you need to allow the virtual PC to completely control the mouse if you want it to test the UI. You can turn off the mouse capture by going to “Settings” in the “Edit” menu. From the dialog, select “Mouse” and uncheck the box labeled “Use pointer integration”. Note that this can only be done while the virtual machine is running.

Virtual PC Mouse Settings

Within the virtual machine, I would also recommend turning off any screen savers and setting the power options to “Always On” so you can be certain that your automated tests will be able to run uninterrupted.

Now that the virtual machine is set up, you can start your automated UI tests within the environment. After the test has started, pressing the right-hand Alt key will release the mouse from being locked in the virtual machine and allow you to continue to use the host PC as normal. This includes locking the host machine, or even running another copy of the virtual machine to run multiple tests at the same time.

Multiple Virtual PCs

Comments are closed.