Selenium (Python) 错误:元素不可交互
我试图从该网站单击此特定的 Web 元素: https: //www.milanofinanza.it/quotazioni/ricerca/listino-completo-2ae?refresh_cens
我尝试了很多不同的方法,但仍然遇到相同的错误(元素不可交互)。
我的代码如下所示:
wd.find_element(By.XPATH,"//*[@id='mainbox']/div[2]/div[2]/div[4]/div/div[1]/div/button[4]").click()
该元素实际上已被检测到,但由于某种原因它不可单击。
I am trying to click on this particular web element from this site: https://www.milanofinanza.it/quotazioni/ricerca/listino-completo-2ae?refresh_cens
I have tried in many different ways but i still get the same error (element not interactable).
My code looks like this:
wd.find_element(By.XPATH,"//*[@id='mainbox']/div[2]/div[2]/div[4]/div/div[1]/div/button[4]").click()
The element is actually detected but for some reason it isn't clickable.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我可以想到两种可能的解释:
.click()
期望的相同方法点击。我不熟悉 ng- 属性,所以也许这只是语言本地化的事情,但我怀疑 selenium 可能正在寻找 onclick 属性。我的建议:
//*button[text()=Successiva]
getDataTableNextClick()< /代码>
I can think of two possible explanations:
.click()
expects. I am not familiar withng-
attributes, so maybe it's just a language localization thing, but I suspect that selenium may be looking for anonclick
attribute.My suggestions:
//*button[text()=Successiva]
getDataTableNextClick()
要简单地单击该元素,只需查找带有该文本的按钮即可。
要浏览 15 个页面,您可以这样做
现在,如果您想浏览 15 个页面,此网站会有点棘手,因为分页不会禁用该按钮。
进口:
To simply click on that element just look for the button with that text.
To go through 15 pages you could do
Now this site is a little trickier if you want to go pass the 15 pages since the pagination doesn't disable the button.
Import: