Telerik blogs
Test StudioT Dark_870x220

Executing UI tests on a remote machine has never been easier. Learn how to save yourself a hassle with the great features for user session configuration in Test Studio.

There is a particular challenge involved with running UI tests. Usually, UI tests involve simulating actions with the mouse or keyboard or sometimes taking screenshots of the current desktop. To ensure these will function correctly, we need to have an active desktop session that renders the GUI.

Most of the time we would want to run our tests on a virtual machine and connect to that machine remotely when an interaction with it is needed. The problem is that when we use Remote Desktop Connection (RDC) to setup the machine and we finally disconnect our RDC session, our session on the remote virtual machine gets locked out and its operating system stops rendering the GUI for the running applications in our session.

The same thing happens if we leave the RDC session open, but the remote OS gets locked due to inactivity, e.g. while waiting for the next test run to start. In that case, UI tests cannot simulate GUI interactions and will fail with a “SendInput: Failed. Win32Error” error. If we try to take a screenshot of the desktop at that moment, it will appear black.

Keep Machine Awake

To ensure our UI tests will be executed, we need, first, to make sure our desktop session does not get locked out, the machine won’t go in sleep mode, and a screensaver will not appear.

The obvious solution to that is to modify the system settings of our machine, but we might not want to permanently change those settings, or we might not even have the proper administration permissions to do that. To save us the hassle of changing our system settings for sleep/lock timeout, Test Studio now has the “Keep Machine Awake” setting.

To access the “Keep Machine Awake” setting, we need to start the Test Studio Execution Server (Click on the Windows Start Button, type “Start Execution Server” and click on the result) and open it from the Windows Task Bar (click ‘Show’ on the Test Studio icon).

Keep Machine Awake - Test Studio

When “Keep Machine Awake” is enabled, this will prevent our Windows machine from falling to sleep, locking or showing a screensaver for as long as the Test Studio Execution Server is running. (Unless, of course, we deliberately lock the machine.) In general, Test Studio will do the same thing that happens when we run a video player on our machine for example. To allow your machine to sleep/lock normally, we need to turn “Keep Machine Awake” off or just stop the Test Studio Execution Server.

The “Keep Machine Awake” option should be used with caution though, since keeping a machine unlocked while being unattended might be a security risk. Any person with physical access to a machine where “Keep Machine Awake” is enabled might be able to interact with the machine.

Reconnect to Console Session

First of all, what is the console session? The console session is the one that we would see on the physical monitor of a Windows computer, working with the physical keyboard and mouse of that computer. In other words, this is the one session that uses the physical console of a computer. Whenever we connect to a Windows computer via Remote Desktop Connection, that would create for us a separate RDP session. So, when we need to disconnect our RDP session, we have to redirect our session to the physical console in order for the GUI of our running applications to keep being rendered.

As we mentioned in the beginning, keeping an active desktop session while working with a virtual machine via RDC has been a challenge so far. Until now, there have been several options to solve that problem:

  • One option would be to use an additional virtual machine as a “proxy” (as described in this article) and keep an always open RDP session to our execution machines. While this approach still works, it introduces an additional level of complexity in the process of maintaining execution machines.
  • Another option would be to install a VNC server on the execution machine and configure it to run as a service. VNC uses the console session and even if we are not connected to that machine from a VNC client, our UI tests would still have access to the GUI. The problem with this approach is that on non-Server editions of Windows, only one active session is allowed. Therefore, whenever a user connects to that machine via RDP, that will force VNC’s console session to be locked and our UI tests would fail.
  • Finally, we could end each RDC session by invoking the following command from Windows Command Prompt to switch to console session: 

    %windir%\System32\tscon.exe RDP-Tcp#<<add-your-session-ID-here>> /dest:console

    This approach is error prone though, as it requires the user to remember to quit their session using the command instead of just closing their RDC session.

The “Reconnect to Console on Disconnect” option makes things much simpler. Just like the “Keep Machine Awake” setting that we discussed above, to enable “Reconnect to Console on Disconnect,” we need to start the Test Studio Execution (Click on the Windows Start Button, type “Start Execution Server” and click on the result) and open it from the Windows Task Bar (click ‘Show’ on the Test Studio icon).

Reconnect to Console on Disconnect - Test Studio

With the “Reconnect to Console on Disconnect” option enabled, Test Studio will automatically reconnect our RDP session to the console session every time we close the Remote Desktop Connection window. We can connect to the execution machine with RDP as many times as we need and every time we disconnect, our UI tests will be able to continue running without interruption.


When “Reconnect to Console on Disconnect” is enabled, Test Studio will reconnect our RDP session to console in an unlocked state. That means that whatever we were seeing when working with Remote Desktop Connection, will be displayed on the physical monitor of the execution machine (if there is one). Any person standing next to the execution machine’s physical console will be able to interact with it. Please have this in mind in case this could be a security risk for your organization.

Minimizing the RDC Window

There is one case when “Reconnect to Console on Disconnect” will not be able to help us to keep our UI tests running. That is when we are using RDC and minimize its window on our machine instead of closing it. This will not disconnect the RDP session and Test Studio will not be able to switch it to console. At the same time, the Windows OS of our client machine will force the remote session to switch to GUI-less mode and will stop displaying windows and controls. To overcome that limitation, we would need a little tweak in the registry settings of our local client machine. Please check our KB article on how to do that.

Monitor Session State

Once we have our execution machines set up, we can monitor their state from the Remote Execution Status window. While the “Status” column shows the overall state of the machine (whether it is alive and reachable), the “User Session” column shows the state of the user session. This lets us inspect from a single place if all execution machines are properly configured and ready to execute tests.

Remote Execution Status - Test Studio

If an execution machine is shown with User Session “Disconnected,” that means that the last RDP connection to that machine was disconnected, but the “Reconnect to Console on Disconnect” setting is not enabled. Therefore this machine will not be able to render GUI and tests that depend on it would fail.

We're always working to make testing easier for you on the Test Studio team, and we hope this post has given you a good overview of how you can easily execute UI tests on a remote machine with Test Studio. If you're new to Test Studio, you can get started with a free 30-day trial today.

About the Author

Oleg Georgiev

Oleg is a Software Developer in the Progress Testing Division. He joined the company in the beginning of 2011 as one of the first QA trainers in Telerik Academy. Since then he has been through several teams and technologies as a QA Engineer and Software Developer, working on products like TeamPulse, Progress Telerik Platform and Test Studio. 

Related Posts


Comments are disabled in preview mode.