Search code examples
geb

How to click on a link in a table with Geb


I have the following table in the page I'm trying to test. I can't seem to get a handle on the link in the second td tag to click on it. I've tried everything I can think of. I have put the table into a module, I have tried to drill down to it manually, and nothing. I'm pretty new to Geb so I'm sure I'm just not doing it right. What is the best method?

<div id="list-authority" class="content scaffold-list" role="main">
    <h1>query = pn:smith
    </h1>

    <table id="record-list">

        <tbody>

        <tr class="even">
            <td>438819</td>
            <td id="0"><a href="The link I want to test">20000422 06:42:42.000Z 00438819 c 3</a></td>
            <td>100 1␣ $a Abel-Smith, Brian</td>
        </tr>


        <tr class="odd">
            <td>2000911</td>
            <td id="1"><a href="The link I want to test">19900530 09:45:42.500Z 02000911 c 3</a></td>
            <td>100 1␣ $a Acklen, Joseph Alexander Smith, $d 1816-1863</td>
        </tr>

        </tbody>
    </table>

</div>

Solution

  • The easiest way to click the link in the second td tag which is also the first link inside of your table is:

    $("#record-list a", 0).click()