Selenium ElementNotVisibleException: Message: element not interactable

出现异常:ElementNotVisibleException: Message: element not interactable

50%原因一:元素没找对,很可能是层级问题,遮挡住了
和stack overflow 有一个问题一样
https://stackoverflow.com/questions/53330380/selenium-elementnotvisibleexception-message-element-not-interactable

出现这种情况,直接用chrome找到xpath

或者用firefox的xpath插件匹配一下数量,若数量>1,试试点击第二个元素
find_ements_byXpath()[1].click()

原因二(元素定位成功):
元素定位成功,但是.location是{x:0,y:0}和.text是空白!

解决方法1(send_keys()):
使用selenium向type='hidden’的隐藏元素发送.click()或者.send_keys()

document.write("");
document.write("");
document.write("");

解决方法2(用js点击):

button = self.driver.find_element_by_xpath("/html/body/div[3]/div[3]/div[4]/div[2]/div[4]/a[2]")

你可能感兴趣的:(Selenium ElementNotVisibleException: Message: element not interactable)