Biraz Dahal
Biraz Dahal

Reputation: 391

How to take the Xpath of last child element of a element in HTML?

I have an html element code and here it is enter image description here

Now I have choose the div with class = 'ui-widget-content slick-row even row_43'. The 43 th row is the last row so next time when the application runs again the last will be 44 beacuse one more row will be added and I have to choose 44. How Can I choose the last row?

(//div[@class='slick-viewport'])[position() = 4]

above is the element of the highlighted part I tried using

(//div[@class='slick-viewport'])[position() = 4]//following-sibling::div

but it didn't help How can i get the element such that always the last div is selected.

Upvotes: 0

Views: 1282

Answers (1)

KunduK
KunduK

Reputation: 33384

Instead of position use last()

(//div[@class='slick-viewport'])[last()]

Upvotes: 2

Related Questions