I’m trying to reach a nested class, originally I used xPath but it returned an empty list, so I went through the classes individually, and one of them has an issue where selenium can’t find it.
Up until Price4
it works fine, but it can’t seem to find Price5
Advertisement
Answer
So, if you want to get the text from the last element containing the price you can define
String lastPriceXpath = "(//*[@class='css-1m1f8hn'])[last()]"
String lastPrice = driver.findElement(By.xpath(lastPriceXpath)).getText()
The syntax above is in Java
but I hope you will be able to convert it to python
, it’s quite similar