In the general case, it is impossible to run a user interface test if the desktop is locked, the user has not logged in, if there is a screen saver, etc. The workarounds that I saw to avoid these problems are to turn off the screen saver and set the computer to automatically log in so that the user is always registered. To make the machine ready for testing, you can restart it; after a few minutes, he should be sitting on the unlocked screen with a registered user of the test.
Please note that you should only do this for a test client computer and not for a server that is intended to be used for important, safe, or critical tasks .
source share