Keyboard commands
Engines 3.0 offer keyboard commands for your tests. Keyboard commands allow Tosca Cloud 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:
-
Single keyboard commands for simple commands
-
Key combinations with the WinForms function SendKeys for more complex user interactions. For instance, if you want to mark all content of an entry field and then delete it.
-
Virtual-key codes to simulate keyboard entries if your application doesn't support single keyboard commands or SendKeys.
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. Tosca Cloud interprets capital letters as SHIFT + lower case letters.
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}.
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 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 |
Note that click operations are not supported.
Use SendKeys
Mobile supports SendKeys commands for BACKSPACE, ENTER, and TAB, as well as SendKeys for typing text.
You can use SendKeys expressions to perform more complex user interactions. For example, to specify key combinations, or to send commands to controls that don't support the direct input of certain commands.
The Tosca Cloud 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, check out Special characters.
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.
If you have specified both parameters, the steering param takes precedence.
Simulate keyboard entries
You can 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.