Reputation: 8577
I have the next xpath:
//span[text()="Bingo"]/parent::div/parent::div/parent::td/preceding-sibling::td[1]
and it returns two elements.
How I choose one of them (first or second)?
I try:
//span[text()="Bingo"]/parent::div/parent::div/parent::td/preceding-sibling::td[1][1]
But it still gives me two elements.
Upvotes: 0
Views: 2272
Reputation: 241738
Use parentheses over the whole expression, then an index:
(//span[text()="Bingo"]/parent::div/parent::div/parent::td/preceding-sibling::td[1])[1]
Upvotes: 7