当前位置: 首页 > 知识库问答 >
问题:

Selenium“DevToolsActivePort文件不存在”错误[重复]

刘焱
2023-03-14

我有以下代码

from selenium import webdriver
from selenium.webdriver.chrome.options import Options

options = Options()
options.add_argument("start-maximized")
options.add_argument("enable-automation")
options.add_argument("--no-sandbox")
options.add_argument("--disable-dev-shm-usage")
options.add_argument("--disable-infobars")
options.add_argument("--disable-gpu")
options.add_argument("--disable-browser-side-navigation")
driver = webdriver.Chrome(options=options)

它返回错误:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.6/dist-packages/selenium/webdriver/chrome/webdriver.py", line 81, in __init__
    desired_capabilities=desired_capabilities)
  File "/usr/local/lib/python3.6/dist-packages/selenium/webdriver/remote/webdriver.py", line 157, in __init__
    self.start_session(capabilities, browser_profile)
  File "/usr/local/lib/python3.6/dist-packages/selenium/webdriver/remote/webdriver.py", line 252, in start_session
    response = self.execute(Command.NEW_SESSION, parameters)
  File "/usr/local/lib/python3.6/dist-packages/selenium/webdriver/remote/webdriver.py", line 321, in execute
    self.error_handler.check_response(response)
  File "/usr/local/lib/python3.6/dist-packages/selenium/webdriver/remote/errorhandler.py", line 242, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: unknown error: Chrome failed to start: exited abnormally
  (unknown error: DevToolsActivePort file doesn't exist)
  (The process started from chrome location /usr/bin/chromium-browser is no longer running, so ChromeDriver is assuming that Chrome has crashed.)

如果我使用options.add_arguments("--Headless")运行,我不会收到任何错误。不幸的是,我真的不能在无头状态下运行我想运行的东西。有人有什么想法吗?

共有1个答案

苗学民
2023-03-14

ChromeDriver没有找到它需要与Chrome讨论的端口。

解决方案:检查您的chrome浏览器版本,然后您可以从以下位置下载chromedriver。

https://chromedriver.chromium.org/downloads

有用链接:https://sites.google.com/a/chromium.org/chromedriver/downloads/version-selection

 类似资料:
  • iam运行一个硒脚本,并继续得到上述错误。这是代码: 所以代码中的注释行对我不起作用。当我添加这一行时,我总是得到这个错误: 并且代码在没有添加上述代码行的情况下也能正常工作。 以下是关于该错误的更多信息: 系统信息: 视窗 7 SP-1 64 位 Chrome信息:版本71.0.3578.98(官方版本)(64位) Java 版本: 10.0.1 请帮我做这件事。

  • 我有一个ubuntu服务器也有UI。U可以通过启动mvn test命令来执行测试用例。但问题是,当我通过另一台机器的终端对机器执行ssh时,我会得到以下错误- 但是,如果我通过remmina远程控制机器,然后执行该机器终端的相同命令,则相同的命令将成功启动chrome。

  • 使用Selenium的Python脚本无法创建Chrome的实例,尽管版本是正确的并且安装了UI。 我已经在这里看了类似的线程,似乎没有一个解决了这个问题。代码在Windows上工作 - 一旦我尝试在Linux上执行它,它就不再有效。我的预期目标是让它在视觉上打开Chrome,因此我不是在寻找涉及虚拟显示器的解决方案。 我有谷歌浏览器75.0.3770.100安装我也有ChromeDriver 7

  • 当我同时使用参数和时。硒升高异常。如果只使用其中的一个,那么一切都可以按需工作。 我试着交换论点,去掉其中一些。指定了chromedriver的完整路径。exe。这些都没有帮助。 Chromeoptions.add_argument("--disable-dev-shm使用")没有帮助我。

  • 我得到下面的错误,而试图执行我的selenium代码如下所示: 错误-异常在线程"main"java.lang.IllegalStateExcture:驱动程序可执行文件不存在:C:\Selenium\简介\C:\chromeDriverScom.google.common.base.Preconditions.check状态(Preconditions.java:585)在org.openqa.

  • 问题内容: 我正在尝试使用URL启动chrome,浏览器启动,此后它什么也不做。 1分钟后,我看到以下错误: 我的配置: Chrome:66 Chrome浏览器:2.39.56 PS 在Firefox中一切正常 问题答案: 更新: 我可以解决问题,现在可以使用所需的网址访问Chrome。 尝试提供的解决方案的结果: 我尝试了上面提供的所有设置,但无法解决问题 有关问题的说明: 根据我的观察,当ch