last() XPath Function
The last() function in XPath is used to locate the last element in a node set.
It returns the position of the last node.
Explanation:
Helps in selecting the final element among multiple matching elements.
Useful when the total number of elements is unknown.
Practical Demonstration:
(//input)[34] → Selects the 34th input element.
(//input)[last()] → Selects the last input element on the page.
Download
0 formats
No download links available.
87. last() function in XPath Expressions (Selenium Java 2026) | NatokHD