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.
Sending an [ENTER] keypress
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.
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.
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:
Custom find keypress step
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.