Reputation: 69
I have a table as follows:
<tr class="ng-scope" ng-repeat="client in clients">
<td class="text-left ng-binding">Apu Nahasapeemapetilon</td>
<td class="text-left ng-binding">AN</td>
<td class="text-left">
<span class="ng-scope" ng-repeat="group in client.SecurityGroups">
<a class="label label-info ng-binding" href="#/SecurityGroup/MemberClients/a1cbf118-2c40-4ae7-a9f8-136bec945849/Assistants"> Assistants </a>
<span class="ng-scope" ng-repeat="group in client.SecurityGroups">
<a class="label label-info ng-binding" href="#/SecurityGroup/MemberClients/e4bd1580-3997-4f3d-a975-189e1fdccb4c/Managers"> Managers </a>
I am trying to locate on a link in the third cell. There can be muliple links in this cell. Ideally I want to identify the row by locating on cells 1 or 2.
So the idea given the table data above is: Find row with client code AN (in cell 2), then find the link 'Assistants' on that row (in cell 3).
I have a similar table on my project and the following XPpath will do what im aiming for on that table:
//tr[.//td='AN'] // a[.='Managers']
but it doesnt seem to work on the table above...
If I do:
//tr[.//td='AN'] // a
It will highlight all the links in the cell (i.e links ending Assistants and Managers), for the row containg 'AN', but I just cant seem to get it to locate on an individual link.
Upvotes: 0
Views: 2539
Reputation: 7173
try the following xpath
//tr/td[.='AN']/following-sibling::td[1]//a[contains(@href, 'Assistants')]
the xpath looks for a tr
with a child td
having a value of 'AN'. Then looks at the first following-sibling td
then looks for a descendant a
which has an href
value that contains 'Assistants'
Upvotes: 1