【发布时间】:2020-07-15 11:04:11
【问题描述】:
我试图单击一个按钮,但收到以下错误消息: 我尝试单击的元素确实存在于页面上,但我不确定为什么它说该元素不存在:
Message: no such element: Unable to locate element: {"method":"xpath","selector":"//button[@class="vote_button mfp-voteText"]"}
下面是我的代码:
driver.get('https://trupanion.com/canada/members/contest?pixlee_album_photo_id=427049511')
time.sleep(10)
try:
vote = driver.find_element_by_xpath('//button[@class="vote_button mfp-voteText"]')
vote.click()
except Exception as e:
print(e)
下面是 chrome 开发工具中的 XPath,它显示它是正确的:
【问题讨论】:
-
可能是因为网页没有加载?我看到错误:错误 1020 此网站正在使用安全服务来保护自己免受在线攻击。
-
元素已加载。我确实在错误后检查了它,但它就在那里。有什么解决办法吗?
标签: python selenium selenium-webdriver iframe webdriverwait