首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >SessionNotCreatedException:消息:未从断开连接创建的会话:无法使用Linux 7服务器上的Chromedriver连接到呈现程序

SessionNotCreatedException:消息:未从断开连接创建的会话:无法使用Linux 7服务器上的Chromedriver连接到呈现程序
EN

Stack Overflow用户
提问于 2020-02-19 11:37:23
回答 1查看 2K关注 0票数 3

我正在使用带有selenium和python的Linux 7服务器上的无头铬。在试图激活驱动程序时,我得到了以下错误:

代码语言:javascript
运行
复制
Traceback (most recent call last):
  File "send_notif_marktplaats.py", line 128, in <module>
    main()
  File "send_notif_marktplaats.py", line 117, in main
    driver = activate_driver()
  File "send_notif_marktplaats.py", line 42, in activate_driver
    driver = webdriver.Chrome(executable_path="/usr/local/bin/chromedriver", chrome_options=optionsChrome)
  File "/usr/lib/python2.7/site-packages/selenium/webdriver/chrome/webdriver.py", line 81, in __init__
    desired_capabilities=desired_capabilities)
  File "/usr/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 157, in __init__
    self.start_session(capabilities, browser_profile)
  File "/usr/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 252, in start_session
    response = self.execute(Command.NEW_SESSION, parameters)
  File "/usr/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 321, in execute
    self.error_handler.check_response(response)
  File "/usr/lib/python2.7/site-packages/selenium/webdriver/remote/errorhandler.py", line 242, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.SessionNotCreatedException: Message: session not created
from disconnected: unable to connect to renderer
  (Session info: headless chrome=80.0.3987.116)

我的版本:

  • Chromedriver版本80.3987.106
  • 谷歌铬80.3987.116

有人能帮我吗?

EN

回答 1

Stack Overflow用户

发布于 2020-02-19 12:31:29

这个错误信息..。

代码语言:javascript
运行
复制
selenium.common.exceptions.SessionNotCreatedException: Message: session not created
from disconnected: unable to connect to renderer
  (Session info: headless chrome=80.0.3987.116)

...implies表示ChromeDriver v80.0无法启动/生成一个新的浏览上下文,即ChromeDriver会话。

正如讨论WebDriver 80.0.3987.16不能在Linux上打开Chrome @triciac更新的那样,ChromeDriver v80.0的实现按照以下顺序查找Chrome:

  1. locations->push_back(base::FilePath("/usr/local/sbin"));
  2. locations->push_back(base::FilePath("/usr/local/bin"));
  3. locations->push_back(base::FilePath("/usr/sbin"));
  4. locations->push_back(base::FilePath("/usr/bin"));
  5. locations->push_back(base::FilePath("/sbin"));
  6. locations->push_back(base::FilePath("/bin"));
  7. locations->push_back(base::FilePath("/opt/google/chrome"));//最后一次尝试使用默认安装位置。

@johnchen证实,r708243无意中更改了Linux上的二进制搜索顺序,目的是使配置Chrome二进制文件的名称更容易,但也意外地更改了搜索顺序。

ChromeDriver团队已经通过这个修订 / 提交更新了ChromeDriver以解决这个问题。

解决方案

上述解决方案可通过以下方式获得:

临时解决方案

一个临时解决方案是使用binary_location 属性,您可以在Selenium: WebDriverException:Chrome启动失败:当google-chrome不再运行时崩溃,因此ChromeDriver假设Chrome已经崩溃中找到详细的讨论。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/60299503

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档