码迷,mamicode.com
首页 > Web开发 > 详细

selenium 访问网页抛出ElementNotVisibleException异常

时间:2017-10-07 14:52:35      阅读:235      评论:0      收藏:0      [点我收藏+]

标签:设置   header   prot   charset   pat   http   span   man   web   

问题描述:

在使用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)

selenium 访问网页抛出ElementNotVisibleException异常

标签:设置   header   prot   charset   pat   http   span   man   web   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!