作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我的网页上有两个具有相同类名的元素,我正在尝试访问第二个元素,但我无法做到这一点。我尝试 [position=1] 并将 [1] 放在我的 xpath 表达式的末尾
driver.find_element_by_xpath("//div[@class='tableType value']")
以上返回以下2个元素
我试过了
driver.find_element_by_xpath("//div[@class='tableType value']")[1]
driver.find_element_by_xpath("//div[@class='tableType value'][position=1]")
有人可以帮我解决这个问题吗?
谢谢
最佳答案
使用
driver.find_element_by_xpath("(//div[@class='tableType value'])[2]")
或
driver.find_element_by_xpath("(//div[@class='tableType value'])[position()=2]")
XPath 从 1 开始计数,所以第二个元素在 position()
2
关于python - 如何访问selenium中具有相同类名的第二个元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23819397/
所以我有这个 UltraTicTacToe 游戏,我正在用 HTML/CSS/JS 编码。它由表中表中的表组成。当您单击 X 或 O 时,我想要突出显示您应该进入的下一个 TicTacToe 牌 ta
Some text Some more text 如何让每个 .example 的 .whatever 包含其 .test 的内容? 例如,如果代码是这样的: Som
我是一名优秀的程序员,十分优秀!