selenium.common.exceptions.ElementNotInteractableException:消息:未显示元素

时间:2018-12-10 17:52:57

标签: python selenium selenium-webdriver

<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.

有人可以帮我解决该问题吗

1 个答案:

答案 0 :(得分:0)

一种解决方法是使用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文档的更多信息。