首页 > 解决方案 > 如何处理 SessionNotCreatedException:消息:会话未从断开连接创建异常:无法从渲染器接收消息?

问题描述

操作系统:UBUNTU 20.04 LTS Google chrome -版本 86.0.4240.183(官方构建)(64 位) conda:4.9.1 Selenium:3.141.0

from selenium import webdriver
options = webdriver.ChromeOptions()
options.add_argument('--headless')
options.add_argument('--disable-infobars')
options.add_argument('--disable-dev-shm-usage')
options.add_argument('--no-sandbox')
options.add_argument('--remote-debugging-port=9222')
    driver =webdriver.Chrome(executable_path='/home/blank/Downloads/useless/chromedriver_linux64 (3)/chromedriver',options=options)`

在我不知道是什么问题之前工作了一天。

SessionNotCreatedException:消息:会话未从断开连接创建异常:无法从渲染器接收消息(会话信息:chrome=86.0.4240.183)(驱动程序信息:chromedriver=2.24.417424(c5c5ea873213ee72e3d0929b47482681555340c3),平台=Linux 5.4.0-52-generic x86_64)

标签: pythonseleniumselenium-webdriver

解决方案


这意味着您的 chrome 驱动程序无法启动/生成新的 Chrome 浏览器。它可能由于多种原因而发生,所以我不能 100% 确定,但这是我通常会做的事情:

  1. 重新检查 chrome 驱动、jdk 和 selenium 版本,确保它与您计算机上的 Chrome 浏览器兼容

  2. 确保系统上的 /etc/hosts 包含以下条目(如果使用 mac 或 linux):

127.0.0.1 localhost.localdomain localhost #or 127.0.0.1 localhost loopback

  1. 关闭杀毒软件(有些可能会影响 chrome 驱动程序)

  2. 清除所有数据并重新启动系统。


推荐阅读