Save HTML table values to Excel

My HTML table has 6 columns and 15 rows. I am using RF 6.1.1 & Python 3.9.13.

${rows}= get element count //table[@id=“issuetable”]/tbody/tr
${cols}= get element count //table[@id=“issuetable”]/thead/tr[1]/th

# Creating a List and append the value
@{list} = Create List
@{myelements}= Get WebElements //table[@id=“issuetable”]/tbody/tr/td
FOR ${element} IN @{myelements}
${text}= Get Text ${element}
Append To List ${list} ${text}
END

Loop the List
FOR ${value} IN @{list}
log to console ${value}
END

How do I save list value to an Excel?

Hi Prashant,

It depends on the level of Excel-ness you need

  • if you just need to be able to open the file containing the data easily in excel and don’t need any formatting, formulas or other more advanced features, then saving as simple text file might do?
    I’d suggest saving as tab separated values (tsv file) as excel will happily this type of text file as though it were a single sheet spreadsheet.
    This can be done with OperatingSystem’s file functions so no need to install anything (great for portability)

  • if you need more than just raw data then robotframework-excel will probably do what you need.
    This will need to be installed on all machines you need to run the test on.

Dave.

Thank you Dave

1 Like