python - selenium.common.exceptions.ElementNotInteractableException:消息:不显示元素
问题描述
<DIV class="x-grid3-cell-inner x-grid3-col-column16" style="CURSOR: pointer" unselectable="on">IMG title="Copy password" style="FLOAT: left; MARGIN: 0px 3px 0px 0px; DISPLAY: block" src="images/icons/password_copy.gif" border=0></DIV>
试图通过
elem = driver.find_element_by_xpath("//img[@src='images/icons/password_copy.gif']")
Or elem = driver.find_element_by_xpath("//img[@title='Copy password']")
Elem.click()
- 不工作但无法单击该元素。得到错误:
raise exception_class(message, screen, stacktrace) selenium.common.exceptions.ElementNotInteractableException: Message: Element is not displayed.
有人可以给我解决方法吗
解决方案
解决此问题的方法是使用 Selenium 中提供的 ActionChains
from selenium.webdriver.common.action_chains import ActionChains
elem = driver.find_element #complete xpath
action = ActionChains(driver)
action.move_to_element_with #complete where you want to move element
action.click()
action.perform()
您可以阅读有关 XPath ActionChains 文档的更多信息。
推荐阅读
- mysql - where子句中的MySQL未知列(UNION)
- c++ - 使用 QtCreator 部署自定义构建项目
- java - 即使列表不为空,emptyView 也始终显示
- c# - 使用 EWS 托管 API (Exchange 2010) 访问共享联系人
- python - 使用 tf.data 读取 CSV 文件非常慢,使用 tfrecords 代替?
- javascript - 使用 css 转换 div
- ios - SwiftSpinner 在调用 API 时遇到问题 - swift ios
- xamarin.forms - Xamarin.forms 中的插件与依赖项服务
- mysql - 替代最大查询?
- r - 我该如何正确处理管道?