如何访问硒中具有相同类名的第二个元素

use*_*233 7 python selenium xpath

我的网页上有两个具有相同类名的元素,我正在尝试访问第二个元素,但我无法做到这一点。我尝试了 [position=1] 并将 [1] 放在我的 xpath 表达式的末尾

driver.find_element_by_xpath("//div[@class='tableType value']")
Run Code Online (Sandbox Code Playgroud)

以上返回以下2个元素

我试过

driver.find_element_by_xpath("//div[@class='tableType value']")[1]
driver.find_element_by_xpath("//div[@class='tableType value'][position=1]")
Run Code Online (Sandbox Code Playgroud)

有人可以帮我解决这个问题吗?

谢谢

hel*_*cha 13

driver.find_element_by_xpath("(//div[@class='tableType value'])[2]")
Run Code Online (Sandbox Code Playgroud)

或者

driver.find_element_by_xpath("(//div[@class='tableType value'])[position()=2]")
Run Code Online (Sandbox Code Playgroud)

XPath 从 1 开始计数,所以第二个元素在position()2