我试图用一个URL启动chrome浏览器,浏览器启动后,它什么也不做。

1分钟后我看到如下错误:

Unable to open browser with url: 'https://www.google.com' (Root cause: org.openqa.selenium.WebDriverException: unknown error: DevToolsActivePort file doesn't exist
  (Driver info: chromedriver=2.39.562718 (9a2698cba08cf5a471a29d30c8b3e12becabb0e9),platform=Windows NT 10.0.15063 x86_64) (WARNING: The server did not provide any stacktrace information)

我的配置:

Chrome浏览器:66 ChromeBrowser: 2.39.56

又及,在Firefox中一切都很好


当前回答

我被这个问题困扰了很长一段时间,最后通过添加一个额外的选项来解决它:

options.addArguments(”——crash-dumps-dir = / tmp”)

其他回答

TL;DR:如果你使用VirtualBox共享文件夹,不要在那里创建Chrome配置文件!


我在Debian 10下遇到了这个错误,但在Ubuntu 18.04下没有发生。

在我的Selenium测试中,我想安装一个扩展,并使用以下Chrome选项:

chromeOptions.addArguments(
  `load-extension=${this.extensionDir}`,
  `user-data-dir=${this.profileDir}`,
  `disable-gpu`,
  `no-sandbox`,
  `disable-setuid-sandbox`,
  `disable-dev-shm-usage`,
);

问题是,我试图在一个非标准目录下创建一个Chrome配置文件,这是VirtualBox共享文件夹的一部分。尽管使用的是完全相同版本的Chrome和Chromedriver,但在Debian下却无法运行。

解决方案是在其他地方选择一个概要目录(例如~/chrome-profile)。

I started seeing this problem on Monday 2018-06-04. Our tests run each weekday. It appears that the only thing that changed was the google-chrome version (which had been updated to current) JVM and Selenium were recent versions on Linux box ( Java 1.8.0_151, selenium 3.12.0, google-chrome 67.0.3396.62, and xvfb-run). Specifically adding the arguments "--no-sandbox" and "--disable-dev-shm-usage" stopped the error. I'll look into these issues to find more info about the effect, and other questions as in what triggered google-chrome to update.

ChromeOptions options = new ChromeOptions();
        ...
        options.addArguments("--no-sandbox");
        options.addArguments("--disable-dev-shm-usage");

日期9/16/2021

在docker托管的ubuntu容器中使用python在本地运行chrome和selenium,一切都很好。当试图运行从Jenkins上面的错误返回WebDriverException:未知错误:DevToolsActivePort

环境:

-Ubuntu21.04在docker容器内,支持RDP访问。

chrome版本:93

解决方案: 在启动浏览器的python文件中,我必须使用以下行设置DISPLAY环境变量:

import os

os.environ['DISPLAY'] = ':10.0'
#DISPLAY_VAR = os.environ.get('DISPLAY')
#print("DISPLAY_VAR:", DISPLAY_VAR)

在尝试在Linux服务器上运行selenium时遇到了同样的问题,尝试降级你的chrome版本,它对我有用吗

从这里选择版本

http://170.210.201.179/linux/chrome/deb/pool/main/g/google-chrome-stable/

在我的例子中,当我试图使用我的默认用户配置文件时,它发生了:

...
options.addArguments("user-data-dir=D:\\MyHomeDirectory\\Google\\Chrome\\User Data");
...

这触发chrome重用已经在后台运行的进程,以这种方式,由chromedriver.exe启动的进程简单地结束。

解决方法:关闭所有在后台运行的chrome.exe进程。