Skip to content

Tables

Interactions with table tag.

Reading the element

Getting the right element class for the xpath

my_table = web.element('//*[id="myTable"]')
type(my_select)
Output
fastrpa.core.elements.TableElement

Try to get a TableElement

my_table = web.button('//*[id="myTable"]')
type(my_select)
Output
fastrpa.core.elements.TableElement

Reference

Get the headers values

my_table.headers
Output
['Company', 'Contact', 'Country']

Get the rows values

my_table.rows
Output
[['Alfreds Futterkiste', 'Maria Anders', 'Germany'],
 ['Centro comercial Moctezuma', 'Francisco Chang', 'Mexico'],
 ...]

Get all values from one column, by column name

my_table.column_values('Company')
Output
['Alfreds Futterkiste',
 'Centro comercial Moctezuma',
 ...]

Get all values from one column, by column index

my_table.column_values(index=0)
Output
['Alfreds Futterkiste',
 'Centro comercial Moctezuma',
 ...]

Check if a value exists in one of the table cells

'Cell content' in my_table
Output
False

Extra needed!

To use this method, you need to install the debug extras, as shown here, with the command pip install "fastrpa[debug]".

my_table.print()
Output
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━┳━━━━━━━━━┓
 Company                       Contact           Country 
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━╇━━━━━━━━━┩
 Alfreds Futterkiste           Maria Anders      Germany 
 Centro comercial Moctezuma    Francisco Chang   Mexico  
 Ernst Handel                  Roland Mendel     Austria 
 Island Trading                Helen Bennett     UK      
 Laughing Bacchus Winecellars  Yoshi Tannamuri   Canada  
 Magazzini Alimentari Riuniti  Giovanni Rovelli  Italy   
└──────────────────────────────┴──────────────────┴─────────┘