I wrote a auto UI test project (using Coded UI framework) and deployed it on a server.
I want to schedule the testing task, to run every night say 12:00.
My problem is when the server is locked (the user is still logged on), it cannot run successfully and the error message is:
Automation engine is unable to playback the test because it is not
able to interact with the desktop. This could happen if the computer
running the test is locked or it’s remote session window is minimized.
Is there any way I can schedule the Coded UI test on the server too always run?
In general it is not possible to run a UI test if the desktop is locked, a user is not logged in, if there is a screen saver running, etc. The workarounds I’ve seen to avoid these problems are to disable the screen saver and set auto-logon for the computer so that there is always a user logged in. To ensure the machine is ready for testing, you can reboot it; a few minutes later, it should be sitting at an unlocked screen with a logged in test user.
Note that you should only do this for a test client machine and not a server that is intended to be used for sensitive, secure, or critical tasks.