Reputation: 157
I have what looks to be a table. I have rows, the first column of which is a url title, the second column is a description, the third a date and the last column is a pencil icon that can be clicked to edit the link. That's what I'm after.
What I need to do is to be able to click that edit icon based on the link text of the url title in the first cell.
Here is the HTML for the table.
<table id="doc" class="displaytag-table" style="width: 100%;">
<thead>
<tbody>
<tr class="displaytag-odd"> (this is the first row)
<tr class="displaytag-even"> (second row)
<tr class="displaytag-odd">
<td style="width: 25%">
<a href="/chcfweb/doc/dispatch.do?filename=http%3A%2F%2Fwww.cnn.com&mode=download">Mikes test</a>
</td>
<td style="text-align: left">Mikes test</td>
<td style="text-align: center">12/22/2015</td>
<td style="text-align: center"> </td>
<td style="text-align: center">
<a href="/chcfweb/doc/dispatch.do?docId=644&mode=edit">
<img border="0" alt="Edit" src="/chcfweb/sbc/images/pencil.gif">
</a>
</td>
I.e. there's a url with the link text of "Mikes test". I want to find that row and click that edit icon in that row.
If I simply get it's xpath it's going to say, oh, you want the fourth column in the 13th row. I can't do that, those numbers will change.
I'm not sure how to go about this. Any pointers in the right direction are appreciated.
Upvotes: 0
Views: 167
Reputation: 2148
Using xpath
text() = 'Mikes test'
or
text()[contains(.,'Mikes test')]
you can find your column, then you can use /..
to find the parent (the row) and then you can use
//img[@alt='Edit']
to find your edit button for that row.
Upvotes: 1