Keyboard commands

Engines 3.0 offer keyboard commands for your tests. Keyboard commands allow Tricentis Tosca to act like a user: It navigates your application, typing on the keyboard. Typically, you will combine keyboard commands with click operations.

You can use the following types of keyboard commands:

You can also steer entire windows rather than individual elements in a window. To do so, use the Module TBox Send Keys of the Standard subset.

Enter text and numbers

To insert letters or numbers, simply enter the letters or numbers.

You can use uppercase or lowercase letters. Tricentis Tosca interprets capital letters as SHIFT + lower case letters.

Enter Jane and Smith into two different text boxes

Some applications might not accept the input of several text characters at once.

In this case, use the syntax {TEXTINPUT["<Unicode characters>"]} to enter your text as Unicode characters.

Use single keyboard commands

To perform single keyboard commands, use the syntax {COMMAND}.

Single keyboard command to press F6

The following commands are available:

Command

Action

BACKSPACE

Backspace

BREAK

Break

CAPSLOCK

Caps Lock

CLEAR

Clear

DEL

Delete

DOWN

END

End

ENTER

Enter

ESCAPE or ESC

Esc

HELP

Help

HOME

Home

INSERT

Ins

LEFT

<-

NUMLOCK

Num Lock

PRINT

Print Screen

RETURN

RIGHT

->

SCROLLLOCK

Scroll Lock

TAB

Tab

UP

SHIFT, LSHIFT, RSHIFT

SHIFT, Left SHIFT, Right SHIFT

CTRL, LCTRL, RCTRL

CTRL, Left CTRL, Right CTRL

ALT, LALT, RALT

ALT, Left ALT, Right ALT

F1 ... F24

F1 ... F24

LWIN

Left Windows key

RWIN

Right Windows key

APPS

Windows context menu key

Commands with click operations

You can also enter commands that use click operations:

Command

Action

ALTCLICK

Left-click while holding ALT

LALTCLICK

Left-click while holding the left ALT key

RALTCLICK

Left-click while holding the right ALT key

CTRLCLICK

Left-click while holding CTRL

LCTRLCLICK

Left-click while holding the left CTRL key

RCTRLCLICK

Left-click while holding the right CTRL key

SHIFTCLICK

Left-click while holding SHIFT

LSHIFTCLICK

Left-click while holding the left SHIFT key

RSHIFTCLICK

Left-click while holding the right SHIFT key

Use SendKeys

This expression allows you to perform more complex user interactions. Use it to specify key combinations, or to send commands to controls that don't support the direct input of certain commands.

The Tosca SendKeys expression uses the WinForms function SendKeys.

Syntax:

{SENDKEYS["<Microsoft SendKeys command>"]}

For a list of available SendKeys commands and their syntax, see the Microsoft SendKeys documentation: http://msdn.microsoft.com/en-us/library/system.windows.forms.sendkeys.aspx

The double quotation marks " that enclose the SendKeys command escape any special characters within the command. If your command contains double quotation marks as a special character, you need additional escaping. For more information on working with special characters, see chapter "Special characters".

In this example, you want to enter the value (ABC) into the text box TextBox:

Keyboard commands for TextBox

The double quotation marks escape the special characters { and }.

In this example, you want to highlight the entire content of the text box user and then delete it.

First, you need to allow Tricentis Tosca to use the control user multiple times.

To do so, modify the Module. Set the ModuleAttribute property Cardinality of the control user to 1-N.

In the TestStep that you create from the Module, enter the following values.

Keyboard commands for user

The double quotation marks escape the special characters { and }.

In some cases, your application may need some time to process between commands. You can specify a delay in milliseconds with the steering param SendKeysDelay or the test configuration parameter SendKeysDelay.

If you have specified both parameters, the steering param takes precedence.

Simulate keyboard entries

This expression allows you to simulate keyboard entries by using virtual-key codes.

To use virtual-key codes in your expressions, use the syntax {KEYPRESS[<Virtual-key code>]}.

For a list of available virtual-key codes, see the Microsoft virtual-key codes documentation: http://msdn.microsoft.com/en-us/library/windows/desktop/dd375731(v=vs.85).aspx.

You need to enter virtual-key codes without the prefix VK_.

For instance: {KEYPRESS[RETURN]} instead of {KEYPRESS[VK_RETURN]}.

If you want to perform key combinations, use the syntax {KEYDOWN[<Virtual-key code>]} for pressing the key and {KEYUP[<Virtual-key code>]} for releasing it.

In this example, you want to highlight the entire content of the textbox Order with CTRL + A and then delete it.

Virtual-key commands for Order

  • {KEYDOWN[CONTROL]} presses down the CTRL key

  • {KEYPRESS[A]} presses A

  • {KEYUP[CONTROL]} releases CTRL

  • {KEYPRESS[DELETE]} presses the DEL key