Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

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.

...

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.

...

  1. 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

  2.  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.

...

  1. Specific to the Windows operating system.

  2. 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.

...

  1. 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.

...

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

  1. General Web Actions  

  2.  https://www.selenium.dev/selenium/docs/api/java/org/openqa/selenium/interactions/Actions.html  

  3. https://docs.oracle.com/javase/7/docs/api/java/awt/Robot.html 

  4. https://www.vbsedit.com/html/4b032417-ebda-4d30-88a4-2b56c24affdd.asp