The PressKeys Action Does Not Execute on an Inactive Screen
Problem: The PressKeys action does not work when a test case is executed on an Inactive screen of a VM.
Reason: Either the screen is minimized or VM is disconnected.
Summary: RDP (Remote Desktop Protocol) allows a user to connect with another remote machine using a GUI. Whenever a RDP connection is initiated between the host and VM, the host transfers the data to VM using RDP driver. This driver also manages the GUI.
However, when the VM is disconnected or minimized, the RDP session is closed and no data transfer happens. To perform GUI operations like press keys, mouse movement, and so on, the GUI must be open. So, when the VM is disconnected or minimized, the PressKeys action fails as the GUI is no longer available.
Solution: To perform the PressKeys action on an inactive screen, try the following methods:
A. Using Windows Shell
-
Case 1: When the screen is minimized
-
On your local computer, close all open Remote Desktop sessions.
-
Launch the Registry editor (regedit.exe).
-
Do one of the following:
-
To specify the setting for the current user, open HKEY_CURRENT_USER\Software\Microsoft\Terminal Server Client.
-
To specify the setting for all the users, open HKEY_LOCAL_MACHINE\Software\Microsoft\Terminal Server Client.
-
-
Create a DWORD value as RemoteDesktop_SuppressWhenMinimized and set it to 2 (hexadecimal or decimal).
-
Modify the registry settings on your local (controlling computer) so that minimizing the Remote Desktop window does not affect the GUI of the controlled computer.
-
Close the Registry Editor.
-
-
Case 2: When The VM is disconnected
The press keys functionality is achieved by using a script with the SendKeys action, in VBScript. To open the RDP session, Windows provides the tscon utility which allows to connect to another session on a Remote Desktop session Host server.
To ensure the console RDP session remains open, disconnect the VM by running the following command in cmd as an administrator:
%windir%\System32\tscon.exe RDP-Tcp#NNN /dest:console
Here, RDP-Tcp#NNN is the ID of your current Remote Desktop session, for example, RDP-Tcp#5. You can find this ID under Task Manager > Users > Session.
Pre-requisites:
-
-
Ensure that the connection is alive between host and VM machine
-
Ensure that you have administrator access
-
B. Setting the PressKeysOnInactiveScreen flag in the Associated Execution Profile
You can consider this solution if you do not have the administrative rights. To perform the press keys on an inactive screen, set the value of the PressKeysOnInactiveScreen flag to true. When set to true, Qualitia internally uses the selenium web driver's Actions class to press keys.
Note: Selenium does not support few keys, as mentioned in Working of Qualitia PressKeys | Using-Actions-class-provided-by-Selenium-Web-driver.