Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

emulate key presses for system tests using NVDA directly #11581

merged 9 commits into from
Sep 10, 2020


Copy link

Link to issue number:


Summary of the issue:

Currently, system tests use pyautogui to send key presses to NvDA and the OS. However, a limitation of pyautogui is that it cannot send extended keys. For example, it is impossible to send a downArrow key press for the extended arrows (upside down t). It supports "down" but that is on the numberpad.
Also, the strings it uses for keys vary quite a bit from NvDA's identifiers.
There are system tests that require sending extended keys. The first being in pr #11569

Description of how this pull request fixes the issue:

Rather than sending keys with pyautogui, instead send them via NVDA's own input gesture framework.

  • Add an emulateKeyPress method to the Robot spy object, which takes an NVDA kb identifier, and emulates the gesture. Using inputCore.manager.emulateGesture means that either a script will be executed, or the key will be sent on to the OS.
    Also, this new method by default blocks until the action has definitely been executed. It does this by first inserting a function into NVDA's event queue after emulating the gesture, and then waiting on that function to be executed. Finally, it then waits on NVDA's core to fall asleep (meaning that no more events or speech is being processed). This makes the tests much more robust as in some cases if a key press resulted in two or more speak calls to the synth, only the first would be waited for. Again, this is necessary for pr Announce entering a listItem when moving by character or word in contentEditables and browse mode  #11569

Testing performed:

All the system tests pass.

Known issues with pull request:


Change log entry:

Changes for developers:
System tests can send keys using spy.emulateKeyPress, which takes a key identifier that conforms to NvDA's own key names.

…ork, so that key press strings confirm to NVDA, and we block on key presses until the actual is actually executed.

This comment has been minimized.

feerrenrut previously approved these changes Sep 10, 2020
Copy link

@feerrenrut feerrenrut left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good @michaelDCurran

@michaelDCurran michaelDCurran merged commit adff1e4 into master Sep 10, 2020
@michaelDCurran michaelDCurran deleted the systemTestKeyEmulation branch September 10, 2020 22:08
@nvaccessAuto nvaccessAuto added this to the 2020.4 milestone Sep 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
None yet

Successfully merging this pull request may close these issues.

None yet

4 participants