Web Send Keys

Sends simulated key presses to an element on the web page.

Command availability: IBM RPA SaaS and IBM RPA on premises

Descriptions

Sends simulated key presses to an element.

Use the keys code pattern to send the key code to the element, for example, {FOO}. If needed, enable the Simulate human parameter to type the key code in the element.

Script syntax

IBM RPA's proprietary scripting language has a syntax similar to other programming languages. The script syntax defines the command's syntax in the script file. You can work with this syntax in IBM RPA Studio's Script mode.

webSendKeys --value(String) --selector(WebFieldElementSelectors) --id(String) --name(String) --css(String) --xpath(String) [--simulatehuman(Boolean)] [--timeout(TimeSpan)] (Boolean)=value

Dependencies

Use the Start Browser (webStart) command to start a browser or use the Find Internet Explorer Browser (findBrowser) command to attach the Microsoft Internet Explorer before using the Web Send Keys (webSendKeys) command.

Input parameter

The following table displays the list of input parameters available in this command. In the table, you can see the parameter name when working in IBM RPA Studio's Script mode and its Designer mode equivalent label.

Designer mode label Script mode name Required Accepted variable types Description
Value value Required Text A text that contains the keys code to send to the element.
To use more than one key code, use a blank space between them, for example, {BACKSPACE} {ENTER}.
You can also define how many times the key is pressed, for example, {BACKSPACE 3} {ENTER 2}. Each key is pressed only once by default.

See the value parameter accepted keys code.
Search for selector Required WebFieldElementSelectors Type of selector to identify the elements in the web page.

See the selector parameter options.
ID id Required when the Search for parameter is Id, IdAndName Text A text that contains the ID attribute value to match the element.
Name name Required when the Search for parameter is Name, IdAndName Text A text that contains the Name attribute value to match the element.
CSS css Required when the Search for parameter is CssSelector Text A text that contains the CSS selector to match the element.
XPath xpath Required when the Search for parameter is XPath Text A text that contains the XML path value to match the element.
Simulate human simulatehuman Optional Boolean Enters each character one by one, simulating a human interaction.

⚠ Attention: If you activate this parameter, you can no longer use key codes 🡥 to input special keys.
Timeout timeout Optional Time Span, Number, Text Maximum waiting time for running the command. When blank, the default timeout is 5 seconds.

selector parameter options

The following table displays the options available for the selector input parameter. The table shows the options available when working in Script mode and the equivalent label in the Designer mode.

Designer mode label Script mode name Description
Id Id Matches the element based on the ID attribute value.
Name Name Matches the element based on the Name attribute value.
Css CssSelector Matches the element based on the CSS selector value.
XPath XPath Matches the element based on the XML path in the HTML root.
Id and name IdAndName Matches the element based on the id and name attribute value.

value parameter accepted keys code

The following table displays the accepted keys code to use in the value input parameter.

Key code Description
{ADD} Matches the numeric pad addition key.
{ALT} Matches the Alt key.
{ARROWDOWN} Matches the down arrow key.
{ARROWLEFT} Matches the left arrow key.
{ARROWRIGHT} Matches the right arrow key.
{ARROWUP} Matches the up arrow key.
{BACKSPACE} Matches the Backspace key.
{CANCEL} Matches the Cancel keystroke.
{CLEAR} Matches the Clear keystroke.
{COMMAND} Matches the function key COMMAND.
{CONTROL} Matches the Control key.
{DECIMAL} Matches the numeric pad decimal separator key.
{DELETE} Matches the Delete key.
{DIVIDE} Matches the numeric pad division key.
{DOWN} Matches the Left arrow key.
{END} Matches the End key.
{ENTER} Matches the Enter key.
{EQUAL} Matches the equal sign key.
{ESCAPE} Matches the Escape key.
{F1} Matches the function key F1.
{F10} Matches the function key F10.
{F11} Matches the function key F11.
{F12} Matches the function key F12.
{F2} Matches the function key F2.
{F3} Matches the function key F3.
{F4} Matches the function key F4.
{F5} Matches the function key F5.
{F6} Matches the function key F6.
{F7} Matches the function key F7.
{F8} Matches the function key F8.
{F9} Matches the function key F9.
{HELP} Matches the Help keystroke.
{HOME} Matches the Home key.
{INSERT} Matches the Insert key.
{LEFT} Matches the left arrow key.
{LEFTALT} Matches the Alt key.
{LEFTCONTROL} Matches the Control key.
{LEFTSHIFT} Matches the Shift key.
{META} Matches the function key META.
{MULTIPLY} Matches the numeric pad multiplication key.
{NULL} Matches the NULL keystroke.
{NUMBERPAD0} Matches the numeric pad zero key.
{NUMBERPAD1} Matches the numeric pad one key.
{NUMBERPAD2} Matches the numeric pad two key.
{NUMBERPAD3} Matches the numeric pad three key.
{NUMBERPAD4} Matches the numeric pad four key.
{NUMBERPAD5} Matches the numeric pad five key.
{NUMBERPAD6} Matches the numeric pad six key.
{NUMBERPAD7} Matches the numeric pad seven key.
{NUMBERPAD8} Matches the numeric pad eight key.
{NUMBERPAD9} Matches the numeric pad nine key.
{PAGEDOWN} Matches the Page Down key.
{PAGEUP} Matches the Page Up key.
{PAUSE} Matches the Pause key.
{RETURN} Matches the Return key.
{RIGHT} Matches the right arrow key.
{SEMICOLON} Matches the semicolon key.
{SEPARATOR} Matches the numeric pad thousands separator key.
{SHIFT} Matches the Shift key.
{SPACE} Matches the Spacebar key.
{SUBTRACT} Matches the numeric pad subtraction key.
{TAB} Matches the Tab key.

Output parameter

Designer mode label Script mode name Accepted variable types Description
Success value Boolean Returns the Boolean value true if the key is pressed successfully, otherwise returns false.

Example

The following code example demonstrates how to send the {ENTER} key code. The Web Send Keys (webSendKeys) command uses the Name selector to send this key code to the field.

defVar --name webpage --type String --value "https://www.google.com.br/"
// Launches the Google Chrome browser
webStart --name browser --type "Chrome"
// Navigates to the web page
webNavigate --url "${webpage}"
// Enters the value `IBM` in the search field
webSet --value IBM --selector "Name" --name q
webSendKeys --value "{ENTER}" --selector "Name" --name q --timeout "00:00:05"
webClose --name browser

Limitations

  • When interacting with a not unique web element, using XPath or CSS selectors, that is inside an IFrame, it is necessary to specify which element inside the IFrame the command will interact with. Otherwise, only the first element will be found.