I have such a structure
How does it look visually
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?
[data-qa="page-link"][data-qa-value="55"]
? That way you don't have to build a complicated XPath that could easily go out of date as things move around.[data-qa-rel="last"]
. The point is to rely on useful information not just structure.