Is there any keyword or widely used library to get entire table content

52 views
Skip to first unread message

Jagan Shankar

unread,
Apr 8, 2020, 8:12:06 AM4/8/20
to robotframework-users
Is there any keyword or widely used library to get entire table content ?

Jagan Shankar

unread,
Apr 16, 2020, 2:10:17 AM4/16/20
to robotframework-users
Any luck for me to get a reply ?

Sounak Saha

unread,
Apr 16, 2020, 2:29:01 AM4/16/20
to jagans...@gmail.com, robotframework-users
Hi Jagan,

There is no inbuilt keyword for the same, maybe due to varying HTML table schema possible. 
But we can create a keyword returning the same using existing selenium library keywords.


--
You received this message because you are subscribed to the Google Groups "robotframework-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to robotframework-u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/robotframework-users/6971b245-a4f6-430e-a0a4-87e23d2bf0ab%40googlegroups.com.


--
Regards
Sounak Saha

Sachin Dhiman

unread,
Apr 16, 2020, 2:29:12 AM4/16/20
to jagans...@gmail.com, robotframework-users
Hey Jagan, 

By Entire Table Content, what do you really mean? 
It is a Html Table or Database table.?


Would it is possible if you can elaborate in detail.?

Thanks
Sachin Dhiman

--

Jagan Shankar

unread,
Apr 16, 2020, 2:46:54 AM4/16/20
to robotframework-users
Thanks Sachin, I meant it is HTML page table.
Thanks for the reply Sonuak.


On Wednesday, 8 April 2020 17:42:06 UTC+5:30, Jagan Shankar wrote:

Dave Amies

unread,
Apr 16, 2020, 8:49:20 AM4/16/20
to robotframework-users
Hi Jagan,

The problem with a predefined keyword is it may not always work as expected, you see a html table is usually mad up of TABLE, TR and TD tags, but can also have TH and TBODY tags. and to make matters worse something on your web page can for all intents and purposes look and act like a "table" but yet be made completly of DIV tags only and not contain any TABLE tags.

So lets assume you have a html table using table tags that looks something like this:

<table id='mytable'>
<tr><th>some text</th><th>some text</th><th>some text</th></tr>
<tr><td>some text</td><td>some text</td><td>some text</td></tr>
<tr><td>some text</td><td>some text</td><td>some text</td></tr>
<tr><td>some text</td><td>some text</td><td>some text</td></tr>
</table>

You could try this, but i'm not sure what this will do:
Get Text id:mytable
Get Text xpath://table[@id='mytable']

You could also try this which will hopefully return you an array of values:
Get Text xpath://table[@id='mytable']//td

Or if you need something specific you could try, replacing <row> and <column> with the row and column numbers:
Get Table Cell id:mytable, <row>, <column>
Get Table Cell xpath://table[@id='mytable'], <row>, <column>


FYI all the Selenium Library keywords are here https://robotframework.org/SeleniumLibrary/SeleniumLibrary.html

If your "table" is just a bunch of DIV's then you will need to look carefully at the html id's and classes to construct an xpath to get what you are after.

Hope that helps,

Dave.

Jagan Shankar

unread,
Apr 20, 2020, 1:09:42 PM4/20/20
to robotframework-users
Thanks Dave for your time and explanation.
Reply all
Reply to author
Forward
0 new messages