You typically get this error when the test is run from a scheduled task with the Run whether user is logged on or not option. The error occurs because in this case the test is run in a non-interactive session and cannot interact with the GUI.
To resolve the problem, do the following:
-
Modify properties of the scheduled task to use the Run only when the user is logged on option and specify the user account under which the task will be run.
-
Make sure that the specified user is logged into the system when the task is triggered.
See Also
Scheduling Automated Tests
Running Tests via Remote Desktop
Running Tests on Locked Computers