Get Web Table
Get the columns, rows, and contents of a data table from 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.
webGetTable [--removehtml(Boolean)] --selector(WebFieldElementSelectors) --id(String) --name(String) --css(String) --xpath(String) [--simulatehuman(Boolean)] [--timeout(TimeSpan)] (DataTable)=value (Numeric)=rows (Numeric)=columns
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 Get Web Table (webGetTable
) 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 |
---|---|---|---|---|
Remove HTML | removehtml |
Optional |
Boolean |
Removes the HTML tags from the data table content. |
Selector Type | selector |
Required |
WebFieldElementSelectors |
Type of selector to identify the 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 the data table element. |
Name | name |
Required when the Selector Type parameter is Name, IdAndName |
Text |
A text that contains the Name attribute value to match the data table element. |
CSS | css |
Required when the Selector Type parameter is CssSelector |
Text |
A text that contains the CSS selector to match the data table element. |
Xpath | xpath |
Required when the Selector Type parameter is XPath |
Text |
A text that contains the XML path value to match the data table element. |
Simulate Human | simulatehuman |
Optional |
Boolean |
Simulates the interaction of a human user by moving the mouse cursor to the center of the element and clicking it. |
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. |
Output parameter
Designer mode label | Script mode name | Accepted variable types | Description |
---|---|---|---|
Data Table | value |
Data Table |
Returns a Data table obtained from the data table on the web page. |
Rows | rows |
Number |
Returns the number of the data table rows. |
Columns | columns |
Number |
Returns the number of the data table columns. |
Example
The following code example demonstrates how to get the data table content and its column and row numbers on the web page. The Get Web Table (webGetTable
) command uses the id
selector to get this content.
defVar --name obtainedTableData --type DataTable
defVar --name rowsNumber --type Numeric
defVar --name columnsNumber --type Numeric
defVar --name webpage --type String --value "https://www.w3schools.com/html/html_tables.asp"
// Launches the Google Chrome browser
webStart --name browser --type "Chrome"
// Navigates to the web page
webNavigate --url "${webpage}"
webGetTable --selector "Id" --id customers --simulatehuman obtainedTableData=value rowsNumber=rows columnsNumber=columns
// Logs the data table content, row, and columns numbers
logMessage --message "Data table content: ${obtainedTableData}\r\nColumns: ${columnsNumber}\r\nRows: ${rowsNumber} " --type "Info"
webClose --name browser --leavebrowseropen