Selecting a cell in a table with no name (CSS or otherwise?)

109 views
Skip to first unread message

Eric Snyder

unread,
Dec 5, 2013, 9:07:04 PM12/5/13
to robotframe...@googlegroups.com
I am new to both Python and Robot Framework and am trying to figure out a way to Get Table Cell on a specific cell, when neither the table itself nor any of the rows/cells have names to identify them.  The table I have to work with looks something like:

<table class="table table-bordered table-striped">
     <thead>
          <tr>
               <th></th>
               <th>Email</th>
               <th>Username</th>
               <th>Moid</th>
          </tr>
     </thead>
     <tbody>
          <tr>
               <td>
               <td>[email address]</td>
               <td>name</td>
               <td>44</td>
          </tr>
          <tr>
               <td>
               <td>[email address]</td>
               <td>name</td>
               <td>45</td>
          </tr>
     </tbody>
</table>

What I would like to do is be able to get cell contents for the second cell [email address] of the first row, but since the only way I know how to retrieve anything is by name or id, I'm at a bit of a loss here.

Any help would be greatly appreciated.  Thanks in advance!

Jan Zdunek

unread,
Dec 6, 2013, 6:27:32 AM12/6/13
to robotframe...@googlegroups.com
Hi!

I assume that you're using the Selenium2 Testlibrary. In that case "Get Table Cell" is your friend. But you still need a table locator. Without an id or a name you might want to use XPath. E.g. if it is the only table in your html page "Get Table Cell    xpath=//table    3    2" should do the trick.


Regards
Jan

Eric Snyder

unread,
Dec 6, 2013, 5:57:48 PM12/6/13
to robotframe...@googlegroups.com
Thank you, Jan.  Yes, using Selenium2.  If I try to use that, though, i wind up with an error stating that "No keyword with name 'Get Table Cell    xpath=//table    3    2' found

Unfortunately, I haven't had any real resources available locally and am trying to learn this stuff "freestyle"; so I don't quite get what the proper syntax would be.  

What I'd love to be able to do is something like ${foo} = Get Table Cell and then ${foo} Should Be Equal <email address>

Eric Snyder

unread,
Dec 6, 2013, 6:34:59 PM12/6/13
to robotframe...@googlegroups.com
Ok, nevermind; thanks again for your time, Jan!  I figure out my problem...it's the loose nut between the keyboard and the chair.  I wasn't tab separating my arguments and they were getting read as part of the keyword.

Kumar Prem WSA

unread,
Dec 8, 2013, 1:02:09 PM12/8/13
to robotframe...@googlegroups.com
try this , hope it work 

Open Browser http://moz.com/top500
Assign Id to Element xpath=//*[@id="top-500"] temp_id
${cell_A} Get Table Cell temp_id 5 5
log ${cell_A}

Eric Snyder

unread,
Dec 9, 2013, 3:51:47 PM12/9/13
to robotframe...@googlegroups.com
Thanks for checking in, Kumar!  Jan's suggestion worked for what I needed, once I got my head out.
Reply all
Reply to author
Forward
0 new messages