Selenium chromedriver 2.25 TimeoutException无法确定加载状态

时间:2016-10-26 23:38:54

标签: python python-3.x selenium selenium-webdriver selenium-chromedriver

我在mac os上使用python3,我已将chrome chromedriverselenium更新为最新版本。我收到了TimeoutException,浏览器正常打开但冻结了。

>>> from selenium import webdriver
>>> driver = webdriver.Chrome()
# opens browser with blank page
>>> driver.get('http://example.com')
# gets first page OK and then driver literally flashes once
>>> driver.get('http://stackoverflow.com')
>>>
# Cursor loading forever... until TimeoutException

抛出此错误:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.5/site-packages/selenium/webdriver/remote/webdriver.py", line 248, in get
    self.execute(Command.GET, {'url': url})
  File "/usr/local/lib/python3.5/site-packages/selenium/webdriver/remote/webdriver.py", line 236, in execute
    self.error_handler.check_response(response)
  File "/usr/local/lib/python3.5/site-packages/selenium/webdriver/remote/errorhandler.py", line 192, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.TimeoutException: Message: timeout: cannot determine loading status
from timeout: Timed out receiving message from renderer: -0.003
  (Session info: chrome=54.0.2840.71)
  (Driver info: chromedriver=2.25.426935 (820a95b0b81d33e42712f9198c215f703412e1a1),platform=Mac OS X 10.12.0 x86_64)

我正在使用:Python 3.5.2Chrome 54.0chromedriver 2.25selenium 3.0.1

我已尝试其他版本的chromedriver但没有成功,我也没有在网上找到任何解决方案。感谢。

修改

仍然从上面得到错误+获得新错误:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.5/site-packages/selenium/webdriver/chrome/webdriver.py", line 69, in __init__
    desired_capabilities=desired_capabilities)
  File "/usr/local/lib/python3.5/site-packages/selenium/webdriver/remote/webdriver.py", line 92, in __init__
    self.start_session(desired_capabilities, browser_profile)
  File "/usr/local/lib/python3.5/site-packages/selenium/webdriver/remote/webdriver.py", line 179, in start_session
    response = self.execute(Command.NEW_SESSION, capabilities)
  File "/usr/local/lib/python3.5/site-packages/selenium/webdriver/remote/webdriver.py", line 236, in execute
    self.error_handler.check_response(response)
  File "/usr/local/lib/python3.5/site-packages/selenium/webdriver/remote/errorhandler.py", line 192, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: session not created exception
from unknown error: bad inspector message: {"method":"Page.loadEventFired","params":{"timestamp":14220,088073}}
  (Session info: chrome=54.0.2840.71)
  (Driver info: chromedriver=2.25.426935 (820a95b0b81d33e42712f9198c215f703412e1a1),platform=Mac OS X 10.12.0 x86_64)

2 个答案:

答案 0 :(得分:11)

  

selenium.common.exceptions.TimeoutException:消息:超时:无法确定加载状态   来自超时:超时从渲染器接收消息:-0.003

Issue817:It looks like this issue has been logged as a bug for Selenium

有人通过使用chrome的--dns-prefetch-disable选项回答了这个问题。

from selenium.webdriver import Chrome
from selenium.webdriver.chrome.options import Options

chrome_options = Options()
chrome_options.add_argument('--dns-prefetch-disable')
driver = Chrome(chrome_options=chrome_options)

If issue still exists follow this thread may be it solves your problem

答案 1 :(得分:0)

env LANG = en_US.UTF-8 ./chromedriver

来自:https://bugs.chromium.org/p/chromedriver/issues/detail?id=1552