Selenium和Chrome错误:会话未创建异常

时间:2016-11-23 23:22:05

标签: python-2.7 selenium selenium-webdriver selenium-chromedriver

我正在使用带有铬的硒,直到铬更新到版本54.0

更新后,硒在午餐时崩溃,给出了下一次追溯:

Traceback (most recent call last):
  File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/Users/user/.virtualenvs/venv/lib/python2.7/site-packages/django/core/management/__init__.py", line 385, in execute_from_command_line
    utility.execute()
  File "/Users/user/.virtualenvs/venv/lib/python2.7/site-packages/django/core/management/__init__.py", line 377, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/Users/user/.virtualenvs/venv/lib/python2.7/site-packages/django/core/management/base.py", line 288, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "/Users/user/.virtualenvs/venv/lib/python2.7/site-packages/django/core/management/base.py", line 338, in execute
    output = self.handle(*args, **options)
  File "/Users/user/proyectos_git/venv/backend/venv_backend/venv/management/commands/get_climate_data.py", line 126, in handle
    start_process()
  File "/Users/user/proyectos_git/venv/backend/venv_backend/venv/management/commands/get_climate_data.py", line 105, in start_process
    browser = webdriver.Chrome()  # Initialize webdriver
  File "/Users/user/.virtualenvs/venv/lib/python2.7/site-packages/selenium/webdriver/chrome/webdriver.py", line 69, in __init__
    desired_capabilities=desired_capabilities)
  File "/Users/user/.virtualenvs/venv/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 90, in __init__
    self.start_session(desired_capabilities, browser_profile)
  File "/Users/user/.virtualenvs/venv/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 177, in start_session
    response = self.execute(Command.NEW_SESSION, capabilities)
  File "/Users/user/.virtualenvs/venv/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 236, in execute
    self.error_handler.check_response(response)
  File "/Users/user/.virtualenvs/venv/lib/python2.7/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":1355138,725669}}
  (Session info: chrome=54.0.2840.98)
  (Driver info: chromedriver=2.25.426935 (820a95b0b81d33e42712f9198c215f703412e1a1),platform=Mac OS X 10.12.1 x86_64)

我尝试了什么:

  • 使用不同的chromedriver版本(从2.16到2.25)
  • 降级Chrome应用(版本53,52和51)
  • 删除路径上的默认文件夹

    /Users/user/Library/Application\ Support/Google/Chrome/Default/

有什么建议吗?

1 个答案:

答案 0 :(得分:0)

偶然发现,在寻找我发现的修复解释时,但它似乎是一个语言环境问题。 尝试使用

为命令添加前缀
$ LANG=en_US-UTF8 yourcommand