On this Page:
Table of Contents |
---|
Introduction
While doing test automation, you may come across cases where you need to perform an action that uses the keyboard buttons.
...
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.
...
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.
...
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 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.
...
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.
...
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
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
...