Header
(8.4.X) Working of Qualitia PressKeys
On this Page:
Introduction
While doing test automation, you may come across cases where you need to perform an action that uses the keyboard buttons.
For example, you might need to press TAB to traverse from one portion of the page to another, submit any form using ENTER, overlay with the ESCAPE key, and write down words using a combination of texts and numbers.
To achieve this behavior, Qualitia provides an action called PressKeys, which allows specifying keys or key combinations in its parameter. To know the components of this PressKeys action, refer to PressKeys Actions.
You can execute the test cases on both active or inactive screen. An inactive screen is a screen that is minimized or is not visible when execution is happening. It is expected that all the steps in a test case must be properly executed even on the inactive screen. For example, while executing a test case with PressKeys on a VM and then switching to the local machine, the keys must be clicked on the VM (which has an inactive screen) where the test case is being executed.
Different Ways to Automate the PressKeys Action
The keyboard functionality can be automated in Qualitia Automation Studio, which internally uses the following ways for the implementation of PressKeys action:
Using Actions class provided by Selenium Web driver
Selenium has a built-in feature called Actions class for handling the keyboard and mouse events. Handling these events include operations such as drag and drop, clicking on multiple elements with the control key, and many more. These operations are performed using the advanced user interactions API, which mainly consists of actions that are needed while performing these operations.
Refer to the following link on how to press keys using the Actions class of Selenium driver:
Advantages:
Actions class can be used to press keys for active and inactive screens.
It can be used on any OS.
Limitations:
Does not support the following browser-specific shortcut keys, which open anything beyond the current DOM:
Ctrl+Shift+Tab
Ctrl+N
Alt+F4
Ctrl+Shift+T
Ctrl+W
Ctrl+F4
Ctrl+F5
Alt+Home
ctrl+
ctrl-
Ctrl+Shift+Del
Ctrl+J
Ctrl+P
Ctrl+O
Ctrl+U
 The following Keyboard keys that Selenium driver does not support are:
NUMLOCK
CAPSLOCK
SCROLLLOCK
PRTSC
Using Windows shell
Windows Terminal is a command-line front-end., which is hidden deeply within the Windows Script Host’s object model. It is small but it has a powerful method called SendKeys that allows you to send keystrokes to the active window just as if you had manually typed them on the keyboard.
The functionality is achieved by using a script written in a language such as VBScript.
VBScript is an object-based scripting language that defines what is to be done to achieve the functionality.
Refer to the following link, which is an example of pressing keys using WS shell:
Advantages:
Supports all types of keys.
Limitations:
Specific to the Windows operating system.
Windows shell cannot be used to press keys on an inactive screen.
Using ROBOT class
Time plays a major role while testing an application and users need to ensure that test case execution is completed within a specific time.
The robot class provided by Java is used to generate native input events for test automation and other applications where you need control over the mouse and keyboard.
Refer to the following link, which is an example for pressing keys using Robot class:
 Advantages:
Supports all types of keys
Can be used on any OS
Limitations:
The robot class cannot be used to press keys on an inactive screen.
Ways In Qualitia To Press Keys In Inactive Screen
Qualitia incorporates the above defined ways and provides the following two ways to press keys in an inactive screen
Setting the Registry key for Remote Desktop Execution
Windows includes the Remote Desktop component that you can use to connect to a remote computer and work with it as with your local computer.
For instruction on how to set a registry key for Remote Desktop Execution, refer to PressKeys Action Does not Execute on an Inactive Screen.
After setting the registry keys, when you minimize the Remote Desktop Connection or VM window on your computer, this will not affect the VM’s GUI and the press keys will happen, the way it happens on the active screen.
Qualitia recommends a registry key solution for pressing keys on inactive screen because this is a one-time activity and there are no limitations on pressing any key with this approachÂ
Set PressKeysOnInactiveScreen flag in the Associated Execution Profile
Alternatively, if you do not have the access to do registry changes due to company restrictions or no administrative rights, consider the second solution.
If you want to press keys on an inactive screen, then set the value of this flag to true. By default, the value is set to false, and press keys happen on the active screen.
When set to true, Qualitia internally uses the selenium web driver's Actions class to press keys. Selenium does not support some keys, which are mentioned in Using Actions class provided by Selenium Web driver.
Â
References
(8.4.X) General Web Actions | id (8.4.X)GeneralWebActions PressKeys Â
 https://www.selenium.dev/selenium/docs/api/java/org/openqa/selenium/interactions/Actions.html Â
https://docs.oracle.com/javase/7/docs/api/java/awt/Robot.htmlÂ
https://www.vbsedit.com/html/4b032417-ebda-4d30-88a4-2b56c24affdd.aspÂ
Â
Footer