硒 chrome 驱动程序 httplib.badstatusline

selenium chrome driver httplib.badstatusline

我使用以下教程安装 selenium、chrome、pyvritualdisplay 和 xvfb: https://christopher.su/2015/selenium-chromedriver-ubuntu/

当我尝试 运行 一个 python selenium 脚本时,我在调用 webdriver.Chrome()

时收到此错误

我正在使用 python2.7.6 Ubuntu 14.04.3 LTS

Traceback (most recent call last):
 File "selenium_python_unittests/attempt_50.py", line 9, in <module>
driver = webdriver.Chrome()
  File "/home/sele/headless/local/lib/python2.7/site-packages/selenium/webdriver/chrome/webdriver.py", line 69, in __init__
desired_capabilities=desired_capabilities)
  File "/home/sele/headless/local/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 92, in __init__
self.start_session(desired_capabilities, browser_profile)
  File "/home/sele/headless/local/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 179, in start_session
response = self.execute(Command.NEW_SESSION, capabilities)
  File "/home/sele/headless/local/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 234, in execute
response = self.command_executor.execute(driver_command, params)
  File "/home/sele/headless/local/lib/python2.7/site-packages/selenium/webdriver/remote/remote_connection.py", line 407, in execute
return self._request(command_info[0], url, body=data)
  File "/home/sele/headless/local/lib/python2.7/site-packages/selenium/webdriver/remote/remote_connection.py", line 439, in _request
resp = self._conn.getresponse()
  File "/usr/lib/python2.7/httplib.py", line 1051, in getresponse
response.begin()
  File "/usr/lib/python2.7/httplib.py", line 415, in begin
version, status, reason = self._read_status()
  File "/usr/lib/python2.7/httplib.py", line 379, in _read_status
raise BadStatusLine(line)
httplib.BadStatusLine: ''

有什么想法吗?这对我来说没有任何意义,因为这个异常发生在我向网站发出网络请求之前

driver.get('http://christopher.su')

正在使用 chrome 驱动程序的过时版本。

如果遇到此问题,请检查您是否使用最新更新的 chrome 驱动程序和 chrome 浏览器。并确保您使用 python2+

谢谢。

更新到新版本的 Chromedriver (2.26) 为我修复了它。