python - 如何处理 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)
解决方案
这意味着您的 chrome 驱动程序无法启动/生成新的 Chrome 浏览器。它可能由于多种原因而发生,所以我不能 100% 确定,但这是我通常会做的事情:
重新检查 chrome 驱动、jdk 和 selenium 版本,确保它与您计算机上的 Chrome 浏览器兼容
确保系统上的 /etc/hosts 包含以下条目(如果使用 mac 或 linux):
127.0.0.1 localhost.localdomain localhost #or 127.0.0.1 localhost loopback
关闭杀毒软件(有些可能会影响 chrome 驱动程序)
清除所有数据并重新启动系统。
推荐阅读
- git - Visual Studio Code 显示未修改的文件
- python - 使用 Pandas 优化重复选择
- path - Tree-Sitter.py 所有叶子到叶子的路径
- autocomplete - 无法删除原子中的风筝
- python - python tarfile addfile - 存档中的奇怪路径
- python - Python Plotly:Surface autocolorscale 属性为 True,但抛出 Value Error '必须指定为 bool'
- php - 期望“Symfony\Component\Security\Core\User\UserInterface”的实例作为第一个参数
- python - 按两个第一个字符过滤值数组
- windows-7 - Gnuplot 5.2 不加载脚本文件
- c# - C# 表单应用程序尝试更改在运行时创建的组件值