Click on Web Page
Clicks or double-clicks an element on a web page.
Command availability: IBM RPA SaaS and IBM RPA on premises
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.
webClick [--isdoubleclick(Boolean)] [--nowait(Boolean)] --selector(WebElementSelectors) --id(String) --name(String) --css(String) --linktext(String) --innertext(String) --tagname(String) --xpath(String) --class(String) --elementvalue(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 Click on Web Page (webClick
) 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 |
---|---|---|---|---|
Double-click | isdoubleclick |
Optional |
Boolean |
Enable to double left-click in the element interface. |
No wait | nowait |
Optional |
Boolean |
Enable to ignore the timeout. |
Search for | selector |
Required |
WebElementSelectors |
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 and click the element. |
Element name | name |
Required when the Search for parameter is Name, NameAndValue, IdAndName |
Text |
A text that contains the Name attribute value to match and clicks the element. |
CSS | css |
Required when the Search for parameter is CssSelector |
Text |
A text that contains the CSS selector to match and clicks the element. |
Link text | linktext |
Required when the Search for parameter is LinkText |
Text |
A text that contains the link text value to match and clicks the element. |
Element text | innertext |
Required when the Search for parameter is InnerTextAndTag |
Text |
A text that contains the element text content to match and clicks the element. |
Tag name | tagname |
Required when the Search for parameter is InnerTextAndTag |
Text |
A text that contains the tag name attribute value to match and clicks the element. |
XPath | xpath |
Required when the Search for parameter is XPath |
Text |
A text that contains the XML path value to match and clicks the element. |
Class name | class |
Required when the Search for parameter is ClassAndValue |
Text |
A text that contains the class attribute value to match and clicks the element. |
Element value | elementvalue |
Required when the Search for parameter is ClassAndValue, NameAndValue |
Text |
A text that contains the Value attribute value to match and clicks the element. |
Simulate human | simulatehuman |
Optional |
Boolean |
Simulates a human user interaction by moving the mouse cursor to the middle of the element and clicking it. See the simulatehuman limitations. |
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. |
Link text | LinkText |
Matches the element based on the link text attribute value. |
Inner text and control type | InnerTextAndTag |
Matches the element based on the element text content and the tag name attribute value. |
XPath | XPath |
Matches the element based on the XML path in the HTML root. |
Class and value | ClassAndValue |
Matches the element based on the class name and value attribute. |
Name and value | NameAndValue |
Matches the element based on the name and the value attribute. |
Id and name | IdAndName |
Matches the 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 click successfully occurs, otherwise return false . |
Example
The following code example demonstrates how to click a button on the web page. The Click on Web Page (webClick
) command uses the Name
selector to find and click the search button.
defVar --name webpage --type String --value "www.google.com"
// Launches the Google Chrome browser
webStart --name browser --type "Chrome"
// Navigates to the Google web page
webNavigate --url "${webpage}"
// Enters the value "IBM" on the search field
webSet --value "IBM" --selector "Name" --name q
webClick --selector "Name" --name btnK
webClose --name browser --leavebrowseropen
Limitations
In the simulatehuman
input parameter:
- The cursor movements are visible in the Internet Explorer interface only. You can see a single click in the middle of the element.
- To double click the element:
- Inspect the
<input>
element only. - Inspect the
<type>
attribute and thefile
value.
- Inspect the
In the selector
parameter options:
- 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.