Set Value to Field

Sets a value to a field located in a web application.

Command availability: IBM RPA SaaS and IBM RPA on premises

Description

Sets a value to a field located in a web application using a selector type to identify the field to set the value.

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.

webSet --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 Set Value to Field (webSet) 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 Value to assign to the field.
Selector Type selector Required WebFieldElementSelectors Type of selector to identify the web elements in the web page.

See the selector parameter options.
Id id Required when the Selector type parameter is Id, IdAndName Text A text that contains the ID attribute value to match and set a value to the field.
Field Name name Required when the Selector type parameter is Name, IdAndName Text A text that contains the Name attribute value to match and set a value to the field.
Css css Required when the Selector type parameter is CssSelector Text A text that contains the Name attribute value to match and set a value to the field.
XPath xpath Required when the Selector type parameter is XPath Text A text that contains the XML path value to match and set a value to the field.
Simulate human simulatehuman Optional Boolean Enters each character one by one, simulating a human interaction.
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 web element based on the ID attribute value.
Name Name Matches the web element based on the Name attribute value.
Css CssSelector Matches the web element based on the CSS selector value.
XPath XPath Matches the web element based on the XML path in the HTML root.
Id and name IdAndName Matches the web element based on the id and name attribute value.

Output parameter

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

Example

Enter the Quantum computing value into the IBM website search field.

webStart --name browser --type "Chrome"
webNavigate --url "https://www.ibm.com/"
webSet --value "Quantum computing" --selector "Id" --id q --simulatehuman
// Use the element id to find the field to assign the value..
webClose --name browser --leavebrowseropen
// Keep the browser open.

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.
  • This command is used just to assign values to editable fields.