Creating and editing keypress steps in the mabl Trainer
With keypress steps, you can confirm the application under test responds as expected to a specific keyboard event. Examples of common keypress steps include:
- Pressing the escape key to close a modal
- Pressing the enter key to submit a search query
There are two ways to create a keypress step in the mabl Trainer: as a recorded action and as a custom find step.
Recorded keypress steps
When the record button is on, the mabl Trainer automatically records keypress steps.
Mabl can record most single keypresses, including letters, numbers, and many special characters, such as
~. Some special characters are spelled out instead of using the character symbols, including:
If the application under test supports keyboard shortcuts, you can also record keypress steps using modifier keys, such as
alt. Keypresses that do not use modifier keys are collapsed into a single step to save execution time and preserve readability in the Trainer.
Support for keyboard shortcuts
Keyboard shortcuts are only supported for applications that use event listeners for specific key up or key down events.
Global keyboard shortcuts, such as
ctrl + a,
ctrl + c, and
ctrl + v, are handled at the system level and are not supported in mabl browser tests.
Editing keypress steps
There are two ways to edit a recorded keypress step:
- Edit step: if you want to change the key(s) to be pressed, click on the edit pencil and update the keys in the Keypress menu. The Keypress menu includes override options for different operating systems. See the following section on operating system differences for more information.
- Configure Find: if you want to refine the target element that the keypress is sent to, open Configure Find to provide more context about the target element.
Operating system differences
While most mabl-supported browsers run on a Linux OS, there are two browsers that run on different operating systems:
- Safari Legacy tests run on macOS.
- Internet Explorer tests run on a Windows OS.
If a keypress step uses modifier keys and you plan to run the test on Safari Legacy or Internet Explorer, click on the edit pencil to open the Keypress menu and override the default modifier keys.
For example, if an override for macOS is present, mabl uses those keys during Safari Legacy executions. If no overrides are present, the keypress step uses the default at the top of the Keypress menu.
Sunset for Safari Legacy and Internet Explorer
Safari Legacy and Internet Explorer will be formally retired on October 2, 2023.
- The replacement for Safari Legacy is Safari (WebKit), which runs on the Unified Runner.
- Learn more about the Internet Explorer sunset plan here.
Custom find keypress steps
If you cannot target the correct element with a recorded keypress, you may create a custom find keypress step. Custom find keypress steps use a CSS or XPath query to target an element and send a keypress directly to it.
To create a custom find keypress step, follow the steps for creating a custom find step outlined in this guide and select "Send keypress" as the action:
When you click Next, you can enter the key(s) in the Keypress menu. Enter the main key to press in the input box. Supported special keys include:
- For a "space" keypress, enter one space between two square brackets:
Editing custom find keypresses
Click on the pencil icon to edit a custom find keypress step. You can update the query for the target element and the keys to be entered on the Keypress menu.
Updated 19 days ago