【发布时间】:2020-06-23 18:11:55
【问题描述】:
我在尝试打开会话时收到这些错误之一。
selenium.common.exceptions.SessionNotCreatedException:消息:会话未创建 从 chrome 无法访问 (会话信息:chrome=80.0.3987.132)
selenium.common.exceptions.SessionNotCreatedException:消息:会话未创建 从断开连接:无法接收来自渲染器的消息 (会话信息:chrome=80.0.3987.132)
ChromeDriver = 80.0.3987.106
我用谷歌搜索了这些错误,但没有一个解决方案有帮助,这是我当前的代码:(其中一个解决方案建议添加 Chrome 选项)
from selenium import webdriver
class YoutubeBot():
def __init__(self):
chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument('--no-sandbox')
self.driver = webdriver.Chrome('/usr/local/bin/chromedriver', chrome_options=chrome_options)
编辑:我现在发现这个问题是通过使用无头来解决的,我仍然想在编写代码时测试我的代码,也许还有其他解决方案吗? (我在 Arch Linux 上使用 Xfce4 DE)
【问题讨论】:
-
你是在没有桌面的电脑上运行这个吗?您可能需要在无头模式下运行 Chrome。
-
@GregBurghardt 我有一个桌面环境,Chrome 窗口会弹出一两秒,但没有显示任何用处,然后只是因为其中一个错误而崩溃。
-
@GregBurghardt 更新:看起来它在无头模式下不会崩溃,这很奇怪。
-
这肯定很奇怪。
标签: python-3.x selenium google-chrome selenium-webdriver selenium-chromedriver