首页 > 编程语言 > 详细

python+selenium报错:ElementNotVisibleException: Message: element not interactable

时间:2019-03-01 15:19:21      阅读:1435      评论:0      收藏:0      [点我收藏+]
错误提示:
selenium.common.exceptions.ElementNotVisibleException: Message: element not interactable
错误原因:
可能是因为动态加载过程中,未加载出对应元素从而无法触发到该操作
解决方案:
增加循环判断元素是否加载完成再执行脚本:
def click_element(self,type,locator,timeout=5):
    max_time = time.time() + timeout
    while time.time() < max_time:
        if self.driver.find_element(type,locator):
            self.driver.find_element(type,locator).click()
            break
        time.sleep(0.2)
    else:
        print(locator %s not found % locator)

 

python+selenium报错:ElementNotVisibleException: Message: element not interactable

原文:https://www.cnblogs.com/xiaopeng4Python/p/10456462.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!