rims
rims

Reputation: 15

click on a link based on a specific td value in selenium

This is the source :

<tr style="">
    <td class="lrml">
       <div class="lrmnw">
        <a class="nclk" onclick="hashNavigate(1132763013,true,'\x26rdrctGoBack\x3dY\x26Id\x3dACOA\x2dDA5MG');"    href="javascript:void(0)">Restore</a>
          </div>
         </td>
      <td/>
    <td>Account</td>
   <td>TestDelete</td>
<td>4/30/2014 02:39 AM</td>

I want to be able to click on "restore" based on the td value "TestDelete". I have been struggling with this without any successful output.

Upvotes: 0

Views: 136

Answers (3)

h4k3r
h4k3r

Reputation: 91

Better to use a CSS selector

css=a.nclk

Or:

css=a:contains('Restore')

Upvotes: -1

SiKing
SiKing

Reputation: 10329

I would use the XPath //td[text()='TestDelete']/preceding-sibling::td//a[text()='Restore']. It is more precise, and actually describes exactly what you said.

Upvotes: 2

Sitam Jana
Sitam Jana

Reputation: 3129

Following xpath worked for me: //td[text()='TestDelete']//parent::tr//a[text()='Restore']

Upvotes: 0

Related Questions