desktop » typeKeys(os,keystrokes)
Description
This command instructs Nexial to automate a series of keystrokes
to the current execution environment. Multiple
keystrokes
may be specified in multiple lines (optional). Since there isn’t an universal standard for key input
(different keyboards, key mapping, etc.), this command uses the os
parameter to limit its execution to the matching
operating system(s). For example,
The first command indicates that {ALT}{F4}
is only supported on Windows and hence will only execute on a Windows
operating system. The second command is designated for Mac OSX and will only run when the current execution is running
on a Mac operating system.
The supported operating systems are (case-insensitive):
Windows
Mac
orMacOSX
Linux
*
(special case: specified keystrokes supported by all OS)
Use nexial.textDelim
to indicate the support for multiple operating
systems. For example the following means that these keystrokes
are supported by Linux and Windows:
Function and Control Key Mapping
Nexial's key mapping supports all common PC-104 and Mac keyboard keys. Modifiers and function keys are enclosed within{...}
(see below). Regular keys can be expressed as is.Modifiers
(may be use in combination, such as{CONTROL}{ALT}F
)
{SHIFT}
{CONTROL}
,{CTRL}
{ALT}
{WINDOWS}
,{WIN}
(PC-104 keyboard only){COMMAND}
,{META}
(Mac keyboard only)
Function keys
{F1}
through{F12}
{ESCAPE}
,{ESC}
{BACKSPACE}
,{BKSP}
{INSERT}
{DELETE}
,{DEL}
{TAB}
{SPACE}
{ENTER}
Directional keys
{HOME}
{END}
{PAGEUP}
{PAGEDOWN}
{UP}
{DOWN}
{LEFT}
{RIGHT}
Legacy desktop application support
The key mapping described above should suffice for most desktop application as well as modern browser. However,
there are some older applications where these key mapping might not yield the desired effect. Older, or
legacy, applications tend to use "ASCII-based" key mapping instead of the
newer
Unicode PUA (Private Use Area) code points (which, incidentally, is what Selenium is based on).
In order to properly simulate key presses on legacy applications, or applications that only support
ASCII-based key mapping, one would enable such feature via the System variable
nexial.desktop.useAsciiKey
by
setting it to true
. The default for this System variable is false
.
Caution
This command do not check or make any effort that AUT is currently present or in display in the foreground. It simply issues the specified keystrokes in the order provided without any regard to how the system or application might react to them. Hence it is critical to design one’s automation such that the intended application/window is appropriately positioned as the active/foreground window PRIOR to executing this command.
The issue of each keystroke (or combination of modifiers and a key) will additionally incur roughly 100 ms. Hence if
additional time is needed to account for the intended reaction from the target application, it might be best to break
up into multiple commands with base » waitFor(waitMs)
commands between them.
Differences between web » typeKeys(locator,value
and desktop » typeKeys(os,keystrokes)
web » typeKeys(locator,value) |
desktop » typeKeys(os,keystrokes)
|
---|---|
This web command targets the web element associated to the specified locator. | This desktop command is associated to currently active desktop UI element. Such UI element may be something on a web page or something on a desktop app (platform-independent). |
This web command will check if the target web element is present on active browser window. If target web element is not present, this command will fail. | This desktop command will not check if the target application is active or in foreground. It simply issues keystrokes on the application active in foreground. |
This web command accepts two parameters, First parameter locator is locator of the target
web element and second parameter is value/keystroke which to be entered in web element.
|
This desktop also accepts two parameters, First parameter os is execution environment in
which provided keystrokes are supported e.g. Windows,Linux,Mac. While the second parameter is keystrokes
i.e. shortcut keys to be pressed on active window.
|
If the locator resolves to more than one web element, only the first matched web element will be affected. | This command is not associated with any desktop element. |
This command will send keys via the underlying webdriver. | This command will send keys via native key emulator. It is independent of Winium driver or any webdriver. |
Parameters
- os - the operating system(s) that will support the specified keystrokes. Unmatched OS will omit such execution.
- keystrokes - the keys to issue upon the current operating system. Longer keystrokes can be broken down to multiple lines.
Example
See above