【发布时间】:2018-03-15 10:45:17
【问题描述】:
这是我的 HTML 代码:
<button class="_qv64e _gexxb _r9b8f _njrw0">Follow</button>
但是,当我尝试点击这个时,出现了这个错误:
selenium.common.exceptions.NoSuchElementException:消息:无法 定位元素:span._qv64e _gexxb _r9b8f _njrw0
它以我使用的任何方式发生,例如在 xpath、CSS 选择器、标签名称和 ... 中。此错误已通过此代码发生:
driver.find_element_by_css_selector("span._qv64e _gexxb _r9b8f _njrw0").click()
【问题讨论】:
-
为什么不能使用 xpath?
-
不是
span,而是button
标签: python python-3.x selenium-webdriver xpath css-selectors