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.
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).
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.
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:
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).
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.
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.
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.
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.
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.
Subscribe to be the first to get our expert-written articles and tutorials for developers!