Nexial Automation

Test Automation Platform for everyone!

X

web » typeKeys(locator,value)

Description

This command automates the issuing of keystrokes on the target the web element as specified via locator. Keystrokes maybe alphanumeric, punctuations, control keys (see below), or a combination of them. A combination of keys and controls are supported. If the specified locator does not result in a valid web element, then this command will FAIL.

If the specified value is (empty), then the target element is effectively “cleared out” - meaning, any of its existing text is removed.

Function and Control Key Mapping

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.


Differences between web » typeKeys(locator,value and desktop » typeKeys(os,keystrokes)

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

  • locator - this parameter is the locator of the element.
  • value - this parameter is the key value which need to be sent.

Example

Script:

Output:

See Also