BrowserTypeKeys Function

Action

This function replays keystrokes as if they were entered directly using the keyboard.

BrowserTypeKeys is synchronized as a whole. If you want to synchronize single keystrokes, you have to use single function calls per keystroke.

The BrowserTypeKeys function uses the Windows API level events to simulate the keystrokes instead of Java script events.

To simulate a modifier key (like SHIFT, CTRL or ALT) pressed and held down while pressing another key, use the following syntax: BrowserTypeKeys("//INPUT[@id='gwt-debug-cwBasicText-textbox']","<LEFT_CTRL+a>"). This will simulate a pressed and held down CTRL key and a pressed a key.

Include file

BrowserAPI.bdh

Syntax

BrowserTypeKeys( uTestObject : in union,
                 sKeyChain   : in string,
                 sTimer      : in string optional,
                 uDelay      : in number optional ): boolean;
Parameter Description
uTestObject The XPath locator or the handle to the DOM element.
sKeyChain The key strokes to be issued. For all characters that have a visual representation, that representation can be used to issue the keystrokes. All other keys are referred to as named keys. Named keys can be replayed by using the name of the key within <> as in the example below.
sTimer Optional: Name of the timer used for page measurements. If this parameter is omitted, no measurements are performed.
uDelay Optional: Delay (in milliseconds) between the separate key strokes. If omitted, there is no delay.

Return value

  • true if successful

  • false otherwise

Example

benchmark SilkPerformerRecorder

use "Kernel.bdh"
use "BrowserAPI.bdh"

dcluser
  user
    VUser
  transactions
    TInit           : begin;
    TMain           : 1;

var

dclrand

dcltrans
  transaction TInit
  begin
  end TInit;

  transaction TMain
  begin
    BrowserStart(BROWSER_MODE_DEFAULT, 800, 600);
    BrowserNavigate("http://demo.borland.com/TestSite/gwt/Showcase.html#CwBasicText");
    
    // set the text to 'Hello!'
    BrowserTypeKeys("//INPUT[@id='gwt-debug-cwBasicText-textbox']", "Hello!!<BACKSPACE><ENTER>");
  end TMain;