S.Manko
S.Manko

Reputation: 151

How to write XPATH in nested elements of siblings

I have such DOM structure:

<td>
  <a href="/2"><div class="name">Max</div></a>
</td>
<td>Sales Officer</td>
<td>[email protected]</td>
<td class="links">
  <a class="edit" href="/edit"><i class="second"></i>Edit Profile</a>
</td>

The main goal is to click on Edit button for particular user. And I have different users (they are in another rows of table). I need to get xpath which contains the combination of name Max and text Edit Profile.

The main problem for me that both elements are in sibling td tags. I've never written anything similar before. //a[text()='Max'] //i[text()='Edit Profile'] What should I add between this to xpathes?

Upvotes: 2

Views: 317

Answers (1)

Andersson
Andersson

Reputation: 52685

This one should do the trick:

//td[a="Max"]/following-sibling::td/a[.="Edit Profile"]

Upvotes: 2

Related Questions