Skip to main content
edited title
Link
Michael Durrant
  • 25.2k
  • 3
  • 41
  • 113

How can I use selenium to get the last itemelement in a list?

deleted 1 character in body
Source Link
João Farias
  • 11k
  • 2
  • 20
  • 40

I have such a structure

enter image description here

How does it look visually

enter image description here

I'm trying to get the last item and click on it, but the 4th item is selected.

driver.findElement(By.xpath(("//*[@id=\"page- body\"]/div/div[2]/ul[last()]"))).click();

How do I click on the last item and on 55?

I have such a structure

enter image description here

How does it look visually

enter image description here

I'm trying to get the last item and click on it, but the 4th item is selected.

driver.findElement(By.xpath(("//*[@id=\"page- body\"]/div/div[2]/ul[last()]"))).click();

How do I click on the last item and on 55?

I have such a structure

enter image description here

How does it look visually

enter image description here

I'm trying to get the last item and click on it, but the 4th item is selected.

driver.findElement(By.xpath(("//*[@id=\"page-body\"]/div/div[2]/ul[last()]"))).click();

How do I click on the last item and on 55?

Source Link
Temp13
  • 27
  • 1
  • 1
  • 5

How to get the last item

I have such a structure

enter image description here

How does it look visually

enter image description here

I'm trying to get the last item and click on it, but the 4th item is selected.

driver.findElement(By.xpath(("//*[@id=\"page- body\"]/div/div[2]/ul[last()]"))).click();

How do I click on the last item and on 55?