Coded UI Test not able to interact with the desktop

If you are running into the following error, Please read the options to enable Coded UI Tests on a remote machine.

Error calling Initialization method for test class NewTitlesPush.NewTitlesPush: Microsoft.VisualStudio.TestTools.UITest.Extension.UITestException: 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.

For the UI tests, the active desktop session has to be opened. We have faced this issue and we have couple of solutions

1. Open a Hyper-V session onto the machine where the UI Tests are running. You can minimize the hyper-V window and the tests will still run fine.

2. If you are running tests in a Lab Environment created from Microsoft Test Manager, Run the tests and open LEViewer[Lab Environment Viewer] to keep the desktop session active.