Type action

The Type (keystrokes) action simulates a user entering in individual keystrokes while filling out a text element on a page.

When recording a script, if the Keystrokes option is selected, the Recorder detects and captures each key typed into a valid text element (text input fields, password fields, and text area fields). This capability is especially useful for applications where individual keystrokes may fire off certain events (for example, auto-suggest functionality for search fields).

The following information is stored in the script for each individual keystroke:

keyCode

Corresponds to the key the user pressed. This property is not case-sensitive; for example, lowercase a and uppercase A generate the same key code.

charCode

Corresponds with the character value for the keystroke. This property is case-sensitive; for example, typing lowercase a generates a different charCode than uppercase A.

selectionStart

Index within the text element at which the keystroke begins.

selectionEnd

Index within the text element at which the keystroke ends.

The following properties are included at the action level:

target

The text element with which to interact.

modifiers

Specifies the keystroke modifiers ([Alt], [Shift], [Ctrl], [meta] keys) to apply to the keystrokes for the specific type action. Note that keystroke modifiers are applied only to the keystrokes, and not the ending text value specified in the script.

The modifier does not override the keyCode or charCode values. For example, a script containing keystrokes to spell out cat in all lowercase letters will not change the keystrokes to uppercase CAT if you apply the [Shift] modifier, because the Recorder still uses the charCode values for the lowercase characters.

textValue

Specifies the text assigned to the value attribute of the text element with which you are interacting when the script has reached the final keystroke. This value replaces whatever value was previously spelled out by the individual keystrokes. For example, if a script captured keystrokes to spell out apple and the text value is changed to orange, the script first simulates typing in apple, but ultimately replaces that value with orange.

Keystroke implementation varies from browser to browser, resulting in a slightly different implementation between the different browser agents. You can find more information on keystroke events and browser compatibility at http://www.quirksmode.org/js/keys.html.

IE Agent implementation of the Type action

Locate the target element.

For each keystroke recorded:

Fire the keydown event.

Simulate typing the character.

If it is the last keystroke, set the value of the text element.

Fire the keyup event.

Fire the keypress event.

Fire the change event for the target text element.

Firefox and Chrome Agent implementation of the Type action

Locate the target element.

For each keystroke recorded:

Fire the keydown event.

Simulate typing the character.

Fire the keypress event.

Fire the keyup event.

If it is the last keystroke, set the value of the text element.

Fire the change event for the target text element.