Example: Grab rows from table in browser

Anyone have a suggestion on how to get the total rows in a table? Below is what I came up with. It would be great if RPA.Browser had a keyword like RPA.Table has “Get Table Dimensions”.

# Count the number of rows in the table   
${row_count}=    Set Variable    ${0} 
FOR    ${row_count}    IN RANGE   2    100 
    ${results}=      Run Keyword And Ignore Error    Get Table Cell    id:MyTable     ${row_count}    3
    Exit For Loop If    '${results}[0]'!='PASS'
END

# Get the data from each row
FOR    ${i}    IN RANGE   2    ${row_count} 
    ${_lname}=           Get Table Cell    id:MyTable        ${i}   3 
    ${_fname}=           Get Table Cell    id:MyTable       ${i}    5 
    ${_IP_Phone}=     Get Table Cell    id:MyTable        ${i}   6 
    ${_m_phone}=      Get Table Cell    id:MyTable        ${i}   7 
    ${_email}=            Get Table Cell    id:MyTable        ${i}   8 
    ${_workgroups}=  Get Table Cell    id:MyTable        ${i}   9
    ${_title}=               Get Table Cell    id:MyTable        ${i}   10
END

Could you use something like

${num_rows}  Get Element Count  //table[@id='MyTable']//tr
1 Like

Worked great! Adding that wonderful tip to a web browser tutorial page would be good for newbies. I am learning this very quickly and very happy so far.

1 Like

Great suggestion, @luckywolf19! I’ll put aside some time for creating some HTML table examples to docs since this topic is quite relevant to many people!

Here you go, @luckywolf19:

If you have any suggestions, ideas, or questions, please share!

// Jani