xpath for parents sibling

Viewed 78

My Html looks like this

 <tr>
    <td>
        <span>
            <img>fieldId:
        </span>
    </td>
    <td>
        <span>
            <input value="false" type="text">
            <input type="hidden" >
        </span>
    </td>
  <td></td>
  <td></td>
</tr>

I want to find the text input field but i know only fieldId which is present under 1st td/span/img I wrote xpath like this

//span[contains(text(),'fieldId')]/../following-sibling::td

But it finds all the td which is present after 1st td so i tried like this

//span[contains(text(),'fieldId')]/../following-sibling::td[0]

But this is not working

Where am i going wrong ??

please help

2 Answers
Related