python调用selenium打开chrome浏览器失败

查看:840
本文介绍了python调用selenium打开chrome浏览器失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问 题

如题,代码如下:

import socket
socket.setdefaulttimeout(20)

chromepath = os.path.abspath(r"C:\Program Files (x86)\Google\Chrome\Application\chromedriver.exe")
driver = webdriver.Chrome(chromepath)
driver.get("https://www.baidu.com")
print driver.title
driver.close()

报错如下:

Traceback (most recent call last):
  File "C:/Users/CurryXu/Desktop/selenium+phantomjs/experiment/joy.py", line 9, in <module>
    driver.get("https://www.baidu.com")
  File "C:\Python27\lib\site-packages\selenium-3.0.1-py2.7.egg\selenium\webdriver\remote\webdriver.py", line 248, in get
    self.execute(Command.GET, {'url': url})
  File "C:\Python27\lib\site-packages\selenium-3.0.1-py2.7.egg\selenium\webdriver\remote\webdriver.py", line 234, in execute
    response = self.command_executor.execute(driver_command, params)
  File "C:\Python27\lib\site-packages\selenium-3.0.1-py2.7.egg\selenium\webdriver\remote\remote_connection.py", line 407, in execute
    return self._request(command_info[0], url, body=data)
  File "C:\Python27\lib\site-packages\selenium-3.0.1-py2.7.egg\selenium\webdriver\remote\remote_connection.py", line 439, in _request
    resp = self._conn.getresponse()
  File "C:\Python27\lib\httplib.py", line 1136, in getresponse
    response.begin()
  File "C:\Python27\lib\httplib.py", line 453, in begin
    version, status, reason = self._read_status()
  File "C:\Python27\lib\httplib.py", line 409, in _read_status
    line = self.fp.readline(_MAXLINE + 1)
  File "C:\Python27\lib\socket.py", line 480, in readline
    data = self._sock.recv(self._rbufsize)
socket.error: [Errno 10054] 

打开的chrome浏览器显示如下:

请问这是什么原因导致打开浏览器无反应呢

解决方案

更新下驱动,地址
见这个回答

这篇关于python调用selenium打开chrome浏览器失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆