selenium 访问网页抛出ElementNotVisibleException异常

问题描述:

在使用selenium时遇到如下异常导致程序终止:

selenium.common.exceptions.ElementNotVisibleException: Message: {"errorMessage":"Element is not currently visible and may not be manipulated","request":{"headers":{"Accept":"application/json","Accept-Encoding":"identity","Connection":"close","Content-Length":"81","Content-Type":"application/json;charset=UTF-8","Host":"127.0.0.1:55400","User-Agent":"Python http auth"},"httpVersion":"1.1","method":"POST","post":"{"id": ":wdc:1507345910060", "sessionId": "416c7180-ab0d-11e7-b13e-8162184dcb19"}","url":"/click","urlParsed":{"anchor":"","query":"","file":"click","directory":"/","path":"/click","relative":"/click","port":"","host":"","password":"","user":"","userInfo":"","authority":"","protocol":"","source":"/click","queryKey":{},"chunks":["click"]},"urlOriginal":"/session/416c7180-ab0d-11e7-b13e-8162184dcb19/element/:wdc:1507345910060/click"}}
Screenshot: available via screen

解决办法:

在启动对应浏览器驱动后,添加如下所示深紫色所示内容。(Note:该条语句用于设置窗口显示尺寸规格,最好设置为您当前pc的电脑分辨率

brower = webdriver.Chrome()

brower.set_window_size(1920, 1080)

原文地址:https://www.cnblogs.com/crawer-1/p/7634372.html