Compare two tables using SeleniumLibrary

Hi,

I need a way to compare two tables containing similar details using Selenium Library. For example I have table like below:

https://www.w3schools.com/html/html_tables.asp
In the above table there are headers and columns I need to first convert them into maps like this

Country is key and values are like below:

{ “Country”: “Germany”, “Mexico”, “Austria”, etc., }

Is there a keyword for it?
and then compare both tables like maps.

Can you please tell me a way.

Thanks,
Anil Gaddam

Hi Anil,

As far as I know there is not a library that handles tables in web pages see this post for why.

In addition to that your “map”? structure doesn’t appear to be a standard structure so robot framework would have trouble comparing it in a way that you might expect

Instead of:
{ “Country”: “Germany”, “Mexico”, “Austria”}

A more standard structure like this will probably give you better results:
{ “Country”: [“Germany”, “Mexico”, “Austria”]}

But you will probably need to build your own keyword that pulls the data from the table in your application into that structure.

If your really lucky though, and this will depend on how your app is written, some web applications pull data from a webservice end point that returns the table data in XML or JSON, so a simple call to the end point may return the data XML or JSON which there are robot framework libraries for and this will save you a heap of time if that is the case.

Dave.